Skip to content

Commit 223cb4f

Browse files
authored
Merge pull request #118 from Gaardsholt/non-root
Making sure the files aren't owned by root
2 parents 6dab436 + df1daec commit 223cb4f

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

api.Dockerfile

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
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
17-
COPY api/ .
22+
COPY --chown=1000:1000 api/ .
1823

1924
# Copy the built Vue.js app from the previous stage
20-
COPY --from=build-stage /app/dist /api/public
21-
COPY --from=build-stage /app/dist/assets/app-config.js /api/app-config.template.js
25+
COPY --chown=1000:1000 --from=build-stage /app/dist /api/public
26+
COPY --chown=1000:1000 --from=build-stage /app/dist/assets/app-config.js /api/app-config.template.js
2227

2328
# install gettext-base for envsubst
2429
RUN apt-get update && apt-get install -y gettext-base
@@ -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
31-
ENTRYPOINT ["/api/docker-entrypoint.api/entrypoint.sh"]
36+
37+
USER node
38+
ENTRYPOINT ["/api/docker-entrypoint.api/entrypoint.sh"]

0 commit comments

Comments
 (0)