Skip to content

Commit f7b96c4

Browse files
build: remove src code from container image
Signed-off-by: Nicklas Silversved <nicklas.silversved@digg.se>
1 parent 287267d commit f7b96c4

File tree

4 files changed

+325
-380
lines changed

4 files changed

+325
-380
lines changed

.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-FileCopyrightText: 2025 diggsweden/rest-api-profil-lint-processor
2+
#
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
node_modules
6+
dist
7+
.git
8+
.gitignore
9+
.vscode
10+
coverage
11+
*.log
12+
.env
13+
.DS_Store

Containerfile

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,32 @@
22
#
33
# SPDX-License-Identifier: CC0-1.0
44

5-
FROM node:22.20.0-slim@sha256:d943bf20249f8b92eff6f605362df2ee9cf2d6ce2ea771a8886e126ec8714f08 AS packages
6-
ENV NODE_ENV=staging
5+
FROM node:22.20.0-slim@sha256:d943bf20249f8b92eff6f605362df2ee9cf2d6ce2ea771a8886e126ec8714f08 AS build
6+
WORKDIR /app
7+
8+
COPY package*.json ./
9+
10+
RUN npm ci --no-audit --no-fund --ignore-scripts
11+
12+
COPY . .
713

14+
RUN npm run build
15+
16+
RUN npm prune --omit=dev
17+
18+
FROM node:22.20.0-slim@sha256:d943bf20249f8b92eff6f605362df2ee9cf2d6ce2ea771a8886e126ec8714f08 AS runtime
19+
ENV NODE_ENV=production
820
WORKDIR /app
921

10-
COPY --chown=node:node ["./","./"]
22+
COPY --from=build /app/dist ./dist
23+
COPY --from=build /app/node_modules ./node_modules
24+
COPY --from=build /app/package*.json ./
25+
26+
COPY --from=build /app/document ./document
27+
COPY --from=build /app/README.md ./README.md
28+
COPY --from=build /app/GUIDELINES.md ./GUIDELINES.md
29+
30+
RUN chown -R node:node /app
31+
USER node
1132

12-
#RUN npm config set strict-ssl false
13-
RUN npm install --omit=dev --verbose
14-
RUN npm install ts-node typescript --omit=dev --verbose
15-
ENTRYPOINT ["npm", "start", "--"]
33+
ENTRYPOINT ["node", "dist/app.js"]

0 commit comments

Comments
 (0)