dockerode-compose icon indicating copy to clipboard operation
dockerode-compose copied to clipboard

COPY command causes compose.up process to fail

Open neg-0 opened this issue 2 years ago • 1 comments

I'm using the following Dockerfile inside of a nodejs repository.

  # Pull base image
  FROM node:latest

  # Set working directory
  WORKDIR /usr/src/app

  # Install app dependencies
  COPY package*.json ./
  RUN npm install

  # Copy app files
  COPY . .

  # Start the app
  EXPOSE 3000

  # Run the app
  CMD [ "npm", "start" ]

The COPY package*.json ./ command causes the compose.up() function to fail due to the way source files are configured in serviceTools.js

https://github.com/apocas/dockerode-compose/blob/7875946d6b57a0eddcfadfccd4a6aeae187166cd/lib/servicesTools.js#L650-L658

According to the dockerode docs https://github.com/apocas/dockerode#building-an-image, the value of src must include ALL files that will be referenced in a command such as COPY. Is there a workaround or plan to include files other than Dockerfile in the source files array?

neg-0 avatar Nov 22 '23 04:11 neg-0

Dove more into the servicesTools.buildDockerImage function and saw that it uses the tarball method if a dockerfile is not specified in the docker-compose.yml. I removed the dockerfile (which was pointing to the default 'Dockerfile' name anyway) and it seems to be working now.

What is the intended use of defining a dockerfile?

neg-0 avatar Nov 22 '23 05:11 neg-0