-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
192 lines (128 loc) · 4.8 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
ARG BUILDKIT_SBOM_SCAN_CONTEXT=true
FROM node:21.7.3-bullseye-slim AS base
ARG BUILDKIT_SBOM_SCAN_STAGE=true
ARG NETWORK_NAME
ARG NPM_LOCAL_CACHE=.cache
RUN apt-get update && apt-get install -y openssh-client
FROM base AS sandbox-builder
ARG BUILDKIT_SBOM_SCAN_STAGE=true
WORKDIR /app
RUN npm install -g turbo
COPY . .
RUN turbo prune --scope=sandbox --scope=common --docker
FROM base AS sandbox-installer
ARG BUILDKIT_SBOM_SCAN_STAGE=true
ARG NETWORK_NAME
ENV VITE_NETWORK_NAME=$NETWORK_NAME
ARG IS_PUBLIC
ENV VITE_IS_PUBLIC=$IS_PUBLIC
WORKDIR /app
COPY .gitignore .gitignore
COPY aliases.js aliases.js
COPY --from=sandbox-builder /app/out/json/ .
COPY --from=sandbox-builder /app/out/package-lock.json ./package-lock.json
RUN npm ci --ignore-scripts
COPY --from=sandbox-builder /app/out/full/ .
COPY turbo.json turbo.json
RUN npx turbo run build:prod --filter=sandbox
RUN rm -f .npmrc
FROM base AS console-builder
ARG BUILDKIT_SBOM_SCAN_STAGE=true
WORKDIR /app
RUN npm install -g turbo
COPY . .
RUN turbo prune --scope=console --scope=ui --scope=common --docker
FROM base AS console-installer
ARG BUILDKIT_SBOM_SCAN_STAGE=true
WORKDIR /app
COPY .gitignore .gitignore
COPY aliases.js aliases.js
COPY --from=console-builder /app/out/json/ .
COPY --from=console-builder /app/out/package-lock.json ./package-lock.json
RUN npm ci
COPY --from=console-builder /app/out/full/ .
RUN echo "PUBLIC_NETWORK_NAME=$NETWORK_NAME" >> apps/console/.env.production
RUN cat apps/console/.env.production
COPY turbo.json turbo.json
RUN npx turbo run prepare
RUN npx turbo run build:prod --filter=console
RUN rm -f .npmrc
FROM base AS dashboard-builder
ARG BUILDKIT_SBOM_SCAN_STAGE=true
RUN apt-get update && apt-get install -y libc6 openssl
WORKDIR /app
RUN npm install -g turbo
COPY . .
RUN turbo prune --scope=dashboard --scope=ui --scope=common --docker
FROM base AS dashboard-installer
ARG BUILDKIT_SBOM_SCAN_STAGE=true
RUN apt-get update && apt-get install -y libc6
WORKDIR /app
COPY .gitignore .gitignore
COPY aliases.js aliases.js
COPY --from=dashboard-builder /app/out/json/ .
COPY --from=dashboard-builder /app/out/package-lock.json ./package-lock.json
RUN npm ci
COPY --from=dashboard-builder /app/out/full/ .
RUN echo "PUBLIC_NETWORK_NAME=$NETWORK_NAME" >> apps/dashboard/.env.production
RUN cat apps/dashboard/.env.production
COPY turbo.json turbo.json
RUN npx turbo run prepare
RUN npx turbo run build:prod --filter=dashboard
RUN rm -f .npmrc
FROM node:21.7.3-bullseye-slim AS dashboard
ARG BUILDKIT_SBOM_SCAN_STAGE=true
WORKDIR /app
COPY --from=dashboard-installer /app/apps/dashboard/prisma/ prisma
COPY --from=dashboard-installer /app/apps/ apps
COPY --from=dashboard-installer /app/packages/ packages
COPY --from=dashboard-installer /app/node_modules node_modules
RUN npm install pm2 -g && \
pm2 install pm2-metrics
CMD ["pm2-runtime","apps/dashboard/build/index.js"]
FROM base AS storybook-builder
ARG BUILDKIT_SBOM_SCAN_STAGE=true
WORKDIR /app
RUN npm install -g turbo
COPY . .
RUN turbo prune --scope=ui --scope=common --docker
FROM base AS storybook-installer
ARG BUILDKIT_SBOM_SCAN_STAGE=true
RUN apt-get update && apt-get install -y libc6
WORKDIR /app
COPY .gitignore .gitignore
COPY aliases.js aliases.js
COPY --from=storybook-builder /app/out/json/ .
COPY --from=storybook-builder /app/out/package-lock.json ./package-lock.json
RUN npm ci
COPY --from=dashboard-builder /app/out/full/ .
RUN echo "PUBLIC_NETWORK_NAME=$NETWORK_NAME" >> packages/ui/.env.production
RUN cat packages/ui/.env.production
COPY turbo.json turbo.json
RUN npx turbo run prepare
RUN npx turbo run build:prod --filter=ui
RUN rm -f .npmrc
FROM nginx:alpine AS storybook
ARG BUILDKIT_SBOM_SCAN_STAGE=true
WORKDIR /app
COPY --from=storybook-installer /app/packages/ui/storybook-static /usr/share/nginx/html
COPY --from=storybook-installer /app/packages/ui/nginx/mime.types /etc/nginx/mime.types
COPY --from=storybook-installer /app/packages/ui/nginx/default.conf /etc/nginx/conf.d/default.conf
FROM nginx:alpine AS sandbox
ARG BUILDKIT_SBOM_SCAN_STAGE=true
WORKDIR /app
RUN rm -rf /usr/share/nginx/html/*
COPY --from=sandbox-installer /app/apps/sandbox/dist /usr/share/nginx/html
COPY --from=sandbox-installer /app/apps/sandbox/.nginx/nginx.conf /etc/nginx/nginx.conf
COPY --from=sandbox-installer /app/apps/sandbox/src/assets/favicon.png /usr/share/nginx/html/assets/favicon.png
COPY --from=sandbox-installer /app/apps/sandbox/src/assets/sandbox_icon.png /usr/share/nginx/html/assets/sandbox_icon.png
FROM node:21.7.3-bullseye-slim AS console
ARG BUILDKIT_SBOM_SCAN_STAGE=true
WORKDIR /app
COPY --from=console-installer /app/apps/ apps
COPY --from=console-installer /app/packages/ packages
COPY --from=console-installer /app/node_modules node_modules
RUN npm install pm2 -g && \
pm2 install pm2-metrics
EXPOSE 3000
CMD ["pm2-runtime","apps/console/build/index.js"]