Skip to content

Commit 74ac9d2

Browse files
committed
fix(docker): updated docker file
1 parent 79c4ef6 commit 74ac9d2

1 file changed

Lines changed: 19 additions & 41 deletions

File tree

Dockerfile

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,37 @@
1-
# Build
2-
FROM node:22-alpine AS build
3-
1+
# Dependencies stage
2+
FROM node:22-alpine AS deps
43
WORKDIR /app
5-
64
COPY package*.json ./
7-
RUN npm install
5+
RUN npm ci --no-audit --no-fund
86

7+
# Build stage (SSR build output)
8+
FROM deps AS build
99
COPY . .
10+
RUN NG_BUILD_OPTIMIZE_CHUNKS=1 npx ng build --configuration=ssr --verbose
1011

11-
RUN npm link @angular/cli
12-
RUN NG_BUILD_OPTIMIZE_CHUNKS=1 ng build --verbose
13-
14-
# Dist
15-
FROM node:22-alpine AS dist
16-
17-
WORKDIR /code
18-
19-
COPY --from=build /app/dist /code/dist
20-
21-
# SSR
22-
FROM node:22-alpine AS ssr
23-
12+
# SSR runtime stage
13+
FROM build AS ssr
2414
WORKDIR /app
25-
26-
COPY package*.json ./
27-
RUN npm install
28-
29-
COPY . .
30-
31-
RUN npm link @angular/cli
32-
RUN NG_BUILD_OPTIMIZE_CHUNKS=1 ng build --configuration=ssr --verbose
33-
34-
RUN npm ci --omit=dev --ignore-scripts --no-audit --no-fund
35-
15+
RUN npm prune --omit=dev --no-audit --no-fund
3616
EXPOSE 4000
37-
3817
ENV PORT=4000
39-
4018
CMD ["node", "dist/osf/server/server.mjs"]
4119

42-
# Dev - run only
43-
FROM build AS dev
20+
# Static dist artifact stage
21+
FROM node:22-alpine AS dist
22+
WORKDIR /code
23+
COPY --from=build /app/dist /code/dist
4424

25+
# Dev server stage
26+
FROM deps AS dev
27+
COPY . .
4528
EXPOSE 4200
29+
CMD ["npx", "ng", "serve", "--host", "0.0.0.0"]
4630

47-
CMD ["ng", "serve"]
48-
49-
# Local Development - coding
31+
# Local development stage
5032
FROM node:22-alpine AS local-dev
5133
WORKDIR /app
52-
53-
# Install deps in the image (kept in container)
5434
COPY package*.json ./
55-
# COPY package-lock.docker.json ./package-lock.json
5635
RUN npm ci --no-audit --no-fund
57-
58-
# Expose Angular dev server
5936
EXPOSE 4200
37+
CMD ["npx", "ng", "serve", "--host", "0.0.0.0"]

0 commit comments

Comments
 (0)