Skip to content

Commit b0963b1

Browse files
authored
Merge pull request #17 from AllianceBioversityCIAT/staging
Staging
2 parents 06f2085 + 97b5368 commit b0963b1

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

server/app-authorization/Dockerfile

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#################### DEVELOPMENT STAGE ####################
2-
# Base image
32
FROM --platform=linux/amd64 node:20.13.1-alpine AS development
43

54
# Create app directory
@@ -8,25 +7,23 @@ WORKDIR /usr/src/app
87
# Create non-root user for better security
98
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
109

11-
# A wildcard is used to ensure both package.json AND package-lock.json are copied
10+
# Copy all necessary files as root
1211
COPY package*.json ./
13-
14-
# Install app dependencies
15-
RUN npm i --ignore-scripts
16-
17-
# Bundle app source
1812
COPY src ./src
1913
COPY tsconfig*.json ./
2014
COPY nest-cli.json ./
21-
COPY package*.json ./
2215
COPY eslint.config.mjs ./
2316

24-
# Creates a "dist" folder with the production build
25-
RUN npm run build
17+
# Install dependencies, build the app, and fix permissions in one step
18+
RUN npm install --ignore-scripts \
19+
&& npm run build \
20+
&& chown -R appuser:appgroup /usr/src/app
21+
22+
# Switch to non-root user
23+
USER appuser
2624

2725
# Expose the port on which the app will run
2826
EXPOSE 3000
2927

3028
# Start the server using the production build
31-
CMD ["npm", "run", "start"]
32-
29+
CMD ["npm", "run", "start"]

0 commit comments

Comments
 (0)