Reputation: 755
I got best practice of vue dockerfile like this :
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
I wonder what is the different of the target like first COPY ./ and second COPY . ?
Upvotes: 0
Views: 86
Reputation: 8646
When you have several sources, you are obligated to use ./
form, which explicitly specifies that the target is a folder, into which all sources are copied. So, COPY a b ./
will make ./a
and ./b
inside container.
When you have single source like COPY . .
this command merges source folder content into destination folder or replaces the file (if source is a file).
Best shown in an example. Lets say you have:
a/
a.txt
b/
b.txt
Dockerfile
hello.txt
Dockerfile
COPY hello.txt ./hello1 # will create/replace ./hello1 FILE in container
COPY hello.txt ./hello2/ # will create ./hello2/hello.txt
COPY a . # now you have ./a.txt in container
COPY b . # now you have ./a.txt and ./b.txt in container
Finally you get in container:
hello1
hello2/hello.txt
a.txt
b.txt
Upvotes: 3