Docker image build fails due to missing directories
bartmanus opened this issue · comments
Description
Dockerfile explicitly copies dirs dist
and storybook-static
into the image but these directories do not exist.
To Reproduce
Steps to reproduce the behavior:
- Clone repo:
git clone https://github.com/vuesion/vuesion
(current tip is 3877aaa) - Build image:
docker build --tag vuesion .
Expected behavior
Build succeeds.
Error Log
docker build --tag vuesion .
Sending build context to Docker daemon 11.75MB
Step 1/12 : FROM node:10-alpine
10-alpine: Pulling from library/node
cbdbe7a5bc2a: Pull complete
2b94f5c25d22: Pull complete
aadffac7f58b: Pull complete
4a934b75286f: Pull complete
Digest: sha256:4fbb0d66d68fef894effdb1676e8833365748432060eeeabd1be17b55bb6ea23
Status: Downloaded newer image for node:10-alpine
---> 57006130ce4b
Step 2/12 : ENV NODE_ENV=production
---> Running in 97004f7011e1
Removing intermediate container 97004f7011e1
---> b8d19d4e6e52
Step 3/12 : ENV PORT=3000
---> Running in 7d10979865db
Removing intermediate container 7d10979865db
---> 060d27d43535
Step 4/12 : RUN mkdir /logs
---> Running in 3a73fdb2ab91
Removing intermediate container 3a73fdb2ab91
---> c5e6995520b1
Step 5/12 : COPY ./package* ./
---> 49c78b447f20
Step 6/12 : COPY ./dist ./dist
COPY failed: stat /var/lib/docker/tmp/docker-builder520679416/dist: no such file or directory
Desktop (please complete the following information):
- OS: MacOS X Catalina 10.15.7
- Docker:
❯ docker version
Client: Docker Engine - Community
Cloud integration 0.1.18
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 16:58:31 2020
OS/Arch: darwin/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.12
API version: 1.40 (minimum version 1.12)
Go version: go1.13.10
Git commit: 48a66213fe
Built: Mon Jun 22 15:49:35 2020
OS/Arch: linux/amd64
Experimental: false
Additional Info
Running npm install
creates the /dist
dir but /storybook-static
is still missing. The docker build gets further along but fails at step 9:
---> 0d8f869667f2
Step 9/12 : COPY ./storybook-static ./storybook-static
COPY failed: stat /var/lib/docker/tmp/docker-builder745152828/storybook-static: no such file or directory
hey @bartmanus.
As documented in line 2 of the file: https://github.com/vuesion/vuesion/blob/master/Dockerfile#L2 the build happens in the CI and the docker image uses the directories from the CI environment. The Dockerfile is used to deploy vuesion to heroku. It's up to you how you want to handle deployment and your build pipeline.
in your case you would need to run npm run ci
befor building the dockerfile
Hey, thanks for the patient explanation. I did manage to figure the process out from the Circleci configuration and built a multi-stage Dockerfile.
Would you be interested in a PR which would refactor the CirceCI config and also make the Dockerfile buildable standalone?
I don't know. I think CI/CD is very different for each project. E.g. I like to build only once and then re-use the build in the Dockerfile. Other people don't event use docker or circle-ci. But I think you can create the PR and we can discuss it in the PR. The PR should be based on the next
branch, please be aware that the next branch looks completely different from the master
branch since version 4 will be a complete re-write.
Thanks. I'll close this issue since it is irrelevant.