Skip to content

Commit

Permalink
Merge pull request #118 from Gaardsholt/non-root
Browse files Browse the repository at this point in the history
Making sure the files aren't owned by root
  • Loading branch information
karpikpl authored Nov 21, 2024
2 parents 6dab436 + df1daec commit 223cb4f
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions api.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
# Stage 1: Build the Vue.js application
FROM node:14 as build-stage
FROM node:14 AS build-stage

USER node
WORKDIR /app
COPY package*.json ./

COPY --chown=1000:1000 package*.json ./
RUN npm install
COPY . .
COPY --chown=1000:1000 . .
# this will tokenize the app
RUN npm run build

# Stage 2: Prepare the Node.js API
FROM node:14 as api-stage
FROM node:14 AS api-stage
WORKDIR /api
# Copy package.json and other necessary files for the API
COPY api/package*.json ./
RUN npm install
COPY --chown=1000:1000 api/package*.json ./
RUN npm install \
&& chown -R 1000:1000 /api

# Copy the rest of your API source code
COPY api/ .
COPY --chown=1000:1000 api/ .

# Copy the built Vue.js app from the previous stage
COPY --from=build-stage /app/dist /api/public
COPY --from=build-stage /app/dist/assets/app-config.js /api/app-config.template.js
COPY --chown=1000:1000 --from=build-stage /app/dist /api/public
COPY --chown=1000:1000 --from=build-stage /app/dist/assets/app-config.js /api/app-config.template.js

# install gettext-base for envsubst
RUN apt-get update && apt-get install -y gettext-base
Expand All @@ -28,4 +33,6 @@ EXPOSE 3000

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

USER node
ENTRYPOINT ["/api/docker-entrypoint.api/entrypoint.sh"]

0 comments on commit 223cb4f

Please sign in to comment.