-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
70 lines (42 loc) · 1.42 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Stage 1: Base setup
FROM node:20-slim AS base
FROM base as test
WORKDIR /app
COPY /project/package*.json ./
RUN npm ci && npm install -g @angular/[email protected]
# Install Google Chrome for headless testing
RUN apt-get update && apt-get install -y \
wget \
gnupg2 \
&& wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update \
&& apt-get install -y google-chrome-stable \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV CHROME_BIN="/usr/bin/google-chrome"
# Stage 2: Test
COPY /project/ .
RUN ng test --watch=false --browsers=ChromeHeadlessNoSandbox
# Stage 3: Build
FROM base as build
WORKDIR /app
COPY /project/ .
RUN npm ci
# Build both the client and server-side parts
RUN npm run build
#FROM nginx:latest as nginx
#COPY nginx.conf /etc/nginx/nginx.conf
# Copy static assets from the build
#COPY --from=build /app/dist/project/browser/ /usr/share/nginx/html/
# Stage 4: Server
FROM base AS server
WORKDIR /app
# Copy the compiled server-side application from the build stage
COPY --from=build /app/dist/project/ /app/dist/
# Install only production dependencies
COPY /project/package*.json ./
RUN npm ci --only=production
EXPOSE 4000
# Start the Node.js server to handle SSR
CMD ["node", "dist/server/server.mjs"]