dockernanoc

The While running Docker container getting error "current working directory, nor any of its parents, seems to be a Nanoc site"


My docker file

FROM ruby:latest

# Create app directory
WORKDIR /usr/src/app

COPY Gemfile .

# Copy the files
COPY . ./docs

RUN bundler install    
RUN bundle exec nanoc

EXPOSE 5300 
CMD [ "nanoc", "view" ]

While Running the build container:

Step : 1

Successfully built 2fa7cc6d083b

Step : 2

 root@ubuntu:/var/docs# docker run -p 0.0.0.0:4300:4300 --name nanoc-latest -t -d nanoc:latest                                                                                                

414b227902d15bbe831d8c77f7c68a3c2ca48ae20c9f20e68f92d52f55350b31

Step : 3

root@ubuntu:/var/docs# docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED   STATUS              PORTS               NAMES                                                                                                                       

Step : 4

root@ubuntu-s-2vcpu-2gb-sgp1-01:/var/docs# docker ps -a

CONTAINER ID IMAGE COMMAND CREATED
STATUS PORTS NAMES

414b227902d1        nanoc:latest        "/bin/sh -c /usr/loc…"   9 seconds ago    Exited (1) 6 seconds ago  nanoc-latest                                                                                                                

Step : 5

root@ubuntu:/var/docs# sudo docker logs 414b227902d1

A Gemfile was detected, but Bundler is not loaded. This is probably not what you want. To run Nanoc with Bundler, use bundle exec nanoc.

Error:The current working directory, nor any of its parents, seems to be a Nano c site.

I tried to open the nanoc image container

root@ubuntu:/var/docs#   docker run -ti --entrypoint=sh nanoc   
# ls  
Gemfile  Gemfile.lock  docs   
# cd docs    
# ls   
Dockerfile  Gemfile  m1  m2  m3  m6

So no nanoc file.


Solution

  • Docker file:

    FROM ruby:2.3
    RUN mkdir -p /user/src/app
    COPY . /usr/src/app
    WORKDIR /usr/src/app/docs
    
    RUN bundle install
    RUN bundle exec nanoc
    EXPOSE 3000
    CMD bundle exec nanoc view
    

    Docker build command:

    docker build -f Dockerfile -t nanoc:latest .
    docker run -p 0.0.0.0:3000:3000 --name nanoc-latest -t -d nanoc:latest
    

    Successfully you get the deployed index.html file