2
votes

I'm having problems when I build the container with MongoDB, when using the docker-compose up I get the following error ERROR: Service 'app' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder367230859/entrypoint.sh: no such file or directory

I tried to change the mongo to PostgreSQL, but continue. my files are below, thanks in advance

that Dockerfile

version: '3'

services:
  web:
    image: nginx
    restart: always
#    volumes:
#      - ${APPLICATION}:/var/www/html
#      - ${NGINX_HOST_LOG_PATH}:/var/log/nginx
#      - ${NGINX_SITES_PATH}:/etc/nginx/conf.d
    ports:
      - "80:80"
      - "443:443"
    networks:
      - web
  mongo:
    image: mongo
    environment:
      MONGO_INITDB_ROOT_USERNAME: admin
      MONGO_INITDB_ROOT_PASSWORD: password
    ports:
       - "27017:27017"
    # volumes:
    #   - data:/data/db
    networks:
      - mongo
  app:
    build: .
    volumes:
      - .:/mm_api
    ports:
      - 3000:3000
    depends_on:
      - mongo
networks:
  web:
    driver: bridge
  mongo:
    driver: bridge´´

that docker-compose

FROM ruby:2.7.0
RUN apt-get update -qq && apt-get install -y nodejs
RUN mkdir /mm_api
WORKDIR /mm_api
COPY Gemfile /mm_api/Gemfile
COPY Gemfile.lock /mm_api/Gemfile.lock
RUN bundle install
COPY . /mm_api

COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh

ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000

CMD ["bundle", "exec", "puma", "-C", "config/puma,rb"]
#CMD ["rails", "server", "-b", "0.0.0.0"]

that entry point

#!/bin/bash
set -e
rm -f /mm_api/tmp/pids/server.pid
exec "$@"
1
That error means the entrypoint.sh file isn't in the same directory as the Dockerfile. You should be able to reproduce the same error running docker build ., without the docker-compose.yml file. - David Maze

1 Answers

0
votes

I had a similar issue when working on a Rails 6 application using Docker.

When I run docker-compose build, I get the error:

Step 10/16 : COPY Gemfile Gemfile.lock ./
ERROR: Service 'app' failed to build : COPY failed: stat /var/lib/docker/tmp/docker-builder408411426/Gemfile.lock: no such file or directory

Here's how I fixed it:

The issue was that the Gemfile.lock was missing in my project directory. I had deleted when I was having some issues with my gem dependencies.

All I had to do was to run the command below to install the necessary gems and then re-create the Gemfile.lock:

bundle install

And then this time when I ran the command docker-compose build everything worked fine again.

So whenever you encounter this issue endeavour to check if the file is present in your directory and most importantly if the path you specified to the file is the correct one.

That's all.

I hope this helps