Skip to content

Commit 484ef3b

Browse files
Update Node.js version to 24-alpine (#77)
* Update Node.js version to 24-alpine * Change CMD to run app.js with node * Implement multi-stage build in Dockerfile Refactor Dockerfile to use multi-stage builds for better optimization and separation of build and production environments. --------- Co-authored-by: Stefano Germano <2128484+stefanogermano@users.noreply.github.com>
1 parent 30dfae5 commit 484ef3b

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

Dockerfile

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1-
FROM node:20-alpine
1+
# Stage 1: Build
2+
FROM node:24-alpine AS builder
23
WORKDIR /app
4+
COPY package*.json ./
5+
RUN npm ci
36
COPY . .
47

5-
RUN npm install
8+
# Stage 2: Production
9+
FROM node:24-alpine
10+
WORKDIR /app
11+
12+
COPY --from=builder /app ./
13+
14+
# Install only production dependencies
15+
RUN npm ci --omit=dev
616

7-
CMD npm start
17+
# Get version from package.json and set as label
18+
ARG APP_VERSION
19+
LABEL org.opencontainers.image.version="${APP_VERSION}"
20+
LABEL org.opencontainers.image.title="LoIDE-API-Server"
21+
LABEL org.opencontainers.image.description="An API server for LoIDE clients"
22+
LABEL org.opencontainers.image.source="https://github.com/DeMaCS-UNICAL/LoIDE-API-Server"
823

24+
CMD ["node", "app.js"]

0 commit comments

Comments
 (0)