run backend docker commands as node instead of root

This commit is contained in:
Maidul Islam
2023-08-08 09:48:27 -04:00
committed by GitHub
parent ec21e35f8c
commit fc9393b77f
+7
View File
@@ -3,6 +3,8 @@ FROM node:16-alpine AS build
WORKDIR /app WORKDIR /app
ENV npm_config_cache /home/node/.npm
COPY package*.json ./ COPY package*.json ./
RUN npm ci --only-production RUN npm ci --only-production
@@ -14,10 +16,13 @@ FROM node:16-alpine
WORKDIR /app WORKDIR /app
ENV npm_config_cache /home/node/.npm
COPY package*.json ./ COPY package*.json ./
RUN npm ci --only-production RUN npm ci --only-production
COPY --from=build /app . COPY --from=build /app .
RUN chown -R node:node /app
RUN apk add --no-cache bash curl && curl -1sLf \ RUN apk add --no-cache bash curl && curl -1sLf \
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.alpine.sh' | bash \ 'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.alpine.sh' | bash \
@@ -28,4 +33,6 @@ HEALTHCHECK --interval=10s --timeout=3s --start-period=10s \
EXPOSE 4000 EXPOSE 4000
USER node
CMD ["npm", "run", "start"] CMD ["npm", "run", "start"]