This is what I came up with but it seems clunky to me. Is there a way to streamline the COPY command? Note that not all the folders need to copied.
I did check out Docker's documentation regarding, and it seems like this may be the only way? I was just checking if anyone else had a brighter idea. Thanks!
# Copy files to container
COPY src/ /opt/build_area/src/
COPY public/ /opt/build_area/public/
COPY app.js doc* .en* tag-push.sh react-0.3.1.tgz package.json .npmrc /opt/build_area/
This is the folder structure:
$ tree -L 1
.
├── .dockerignore
├── .env
├── .env.development
├── .git/
├── .gitignore
├── .npmrc
├── Dockerfile
├── Dockerfile-build
├── README.md
├── app.js
├── azure-pipelines-static.yml
├── azure-pipelines.yml
├── docker/
├── docker-compose-run.yml
├── docker-compose.yml
├── node_modules/
├── package-lock.json
├── package.json
├── public/
├── react-0.3.1.tgz
├── src/
├── tag-push.sh
└── test-azure-pipelines-static.yml
5 directories, 18 files
CodePudding user response:
This is what I came up with helpful comments from @TahaNaqvi and @DavidMaze. This is much easier to read.
# Copy files to container
WORKDIR /opt/build_area/
COPY src/ ./src/
COPY public/ ./public/
COPY app.js \
.npmrc \
doc* .en* \
tag-push.sh \
package.json \
react-0.3.1.tgz /opt/build_area/
CodePudding user response:
dockerignore file can be used just like gitignore file. You can specify files folders to be ignored which will not be copied by COPY command. More doc here - https://docs.docker.com/engine/reference/builder/#dockerignore-file
