This repository has been archived by the owner on Dec 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathDockerfile
97 lines (66 loc) · 2.49 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
#
# Dockerfile for self-hosted traceo. This image contains builders:
#
# - app-builder -> public/packages/app (frontend)
# - backend-builder -> lib (backend lol)
# - worker-builder -> relay-worker (worker)
#
# At the end everything from builders are copied to final image and up with bash scripts (and pm2).
#
# Final image is hosted also in docker registry as: traceo/traceo:${TAG:latest}
#
ARG NODE_IMAGE=node:16-alpine3.15
ARG FINAL_IMAGE=alpine:3.15
# APP
FROM ${NODE_IMAGE} as app-builder
WORKDIR /traceo
COPY ./public .
RUN yarn workspace @traceo/app install --frozen-lockfile
ENV REACT_APP_API_URL=host.docker.internal \
REACT_APP_SOCKET_URL=host.docker.internal \
NODE_ENV=production \
NODE_OPTIONS=--max_old_space_size=8000
RUN yarn workspace @traceo/app build:prod
# BACKEND
FROM ${NODE_IMAGE} as backend-builder
WORKDIR /traceo
RUN apk add curl
ENV NODE_ENV=production \
NODE_OPTIONS=--max_old_space_size=8000 \
APP_ORIGIN=host.docker.internal
COPY /lib/package*.json ./
COPY /public/packages/shared/traceo-types /public/packages/shared/traceo-types
RUN yarn install --production=true && yarn global add typescript
COPY /lib .
RUN tsc -p tsconfig.build.json
# RELAY WORKER
FROM ${NODE_IMAGE} as worker-builder
WORKDIR /traceo
RUN apk add curl
COPY /relay-worker/package*.json ./
COPY /public/packages/shared/traceo-types /public/packages/shared/traceo-types
RUN yarn install --production=true && yarn global add typescript
COPY /relay-worker .
RUN tsc -p tsconfig.build.json
# FINAL
FROM ${FINAL_IMAGE}
WORKDIR /traceo
# RUN apk add --no-cache ca-certificates bash tzdata musl-utils
# RUN apk add --no-cache openssl ncurses-libs ncurses-terminfo-base --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main
RUN apk --no-cache add nodejs --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
RUN apk --no-cache add npm
RUN npm install -g pm2
ENV NODE_OPTIONS=--max_old_space_size=8000 \
NODE_ENV=production \
# Generate random UUID with unix uuidgen and pass as JWT_SECRET
JWT_SECRET=$(uuidgen)
COPY --from=app-builder /traceo/packages/app/build ./app
COPY --from=backend-builder /traceo/dist ./dist
COPY --from=backend-builder /traceo/node_modules ./node_modules
COPY --from=backend-builder /public/packages/shared/traceo-types ./node_modules/@traceo/types
COPY --from=worker-builder /traceo/dist ./worker/dist
COPY --from=worker-builder /traceo/node_modules ./worker/node_modules
# bash scripts
COPY ./bin ./bin/
EXPOSE 3000
CMD ["sh", "./bin/docker"]