Skip to content

Commit df1daec

Browse files
committed
Update Dockerfile to set user permissions and improve file ownership
Signed-off-by: Lasse Gaardsholt <[email protected]>
1 parent c948d4c commit df1daec

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

api.Dockerfile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
# Stage 1: Build the Vue.js application
2-
FROM node:14 as build-stage
2+
FROM node:14 AS build-stage
3+
4+
USER node
35
WORKDIR /app
4-
COPY package*.json ./
6+
7+
COPY --chown=1000:1000 package*.json ./
58
RUN npm install
6-
COPY . .
9+
COPY --chown=1000:1000 . .
710
# this will tokenize the app
811
RUN npm run build
912

1013
# Stage 2: Prepare the Node.js API
11-
FROM node:14 as api-stage
14+
FROM node:14 AS api-stage
1215
WORKDIR /api
1316
# Copy package.json and other necessary files for the API
14-
COPY api/package*.json ./
15-
RUN npm install
17+
COPY --chown=1000:1000 api/package*.json ./
18+
RUN npm install \
19+
&& chown -R 1000:1000 /api
20+
1621
# Copy the rest of your API source code
1722
COPY --chown=1000:1000 api/ .
1823

@@ -28,4 +33,6 @@ EXPOSE 3000
2833

2934
# Command to run your API (and serve your Vue.js app)
3035
RUN chmod +x /api/docker-entrypoint.api/entrypoint.sh
36+
37+
USER node
3138
ENTRYPOINT ["/api/docker-entrypoint.api/entrypoint.sh"]

0 commit comments

Comments
 (0)