-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
107 lines (72 loc) · 2.84 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
# ------------------------------------------------------
# FRONTEND
# ------------------------------------------------------
FROM node:lts-buster-slim AS frontend-builder
WORKDIR /frontend
# Cache dependencies
COPY frontend/package.json /frontend/package.json
COPY frontend/yarn.lock /frontend/yarn.lock
RUN yarn install --frozen-lockfile
ARG REACT_APP_COMMUNICATIONS_BASE_URI=
COPY frontend /frontend
ENV NODE_ENV=production
ENV NODE_OPTIONS=--openssl-legacy-provider
ENV SKIP_PREFLIGHT_CHECK=true
ENV DISABLE_ESLINT_PLUGIN=true
RUN yarn build
# ------------------------------------------------------
# BACKEND
# ------------------------------------------------------
FROM python:3.11-slim-bullseye AS backend-builder
WORKDIR /terry
COPY backend/requirements.txt /terry/requirements.txt
RUN pip install -I -r requirements.txt
COPY backend /terry
RUN ./setup.py install
# ------------------------------------------------------
# COMMUNICATION
# ------------------------------------------------------
FROM rust:1.69 as communication-builder
COPY communication/src /build/src
COPY communication/Cargo.toml /build
COPY communication/Cargo.lock /build
COPY communication/schema.sql /build
COPY communication/.cargo /build
WORKDIR /build
RUN cargo build --release
# ------------------------------------------------------
# FINAL IMAGE
# ------------------------------------------------------
FROM python:3.11-slim-bullseye AS without-communication
# Install system dependencies and task dependencies
RUN apt-get update && \
apt-get install -y curl nginx procps zip '^python3?$' '^python3?-(wheel|pip|numpy|sortedcontainers)$' && \
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2 && \
pip2 install numpy sortedcontainers
# Frontend
COPY --from=frontend-builder /frontend/build /app
# Backend
COPY --from=backend-builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=backend-builder /usr/local/bin /usr/local/bin
COPY docker/default.config.yaml /default.config.yaml
# Nginx
COPY docker/nginx.conf /etc/nginx/nginx.conf
# Startup script
EXPOSE 80
COPY docker/start.sh /start.sh
CMD ["/start.sh"]
# ------------------------------------------------------
# FINAL IMAGE WITH COMMUNICATION
# ------------------------------------------------------
FROM without-communication AS with-communication
COPY --from=communication-builder /build/target/release/terry-communication-backend /terry-communication-backend
VOLUME [ "/data" ]
# ------------------------------------------------------
# FINAL IMAGE ONLY COMMUNICATION
# ------------------------------------------------------
FROM debian:stable-slim AS only-communication
ADD communication/docker/start.sh /
COPY --from=communication-builder /build/target/release/terry-communication-backend /terry-communication-backend
VOLUME [ "/data" ]
EXPOSE 1236
CMD ["/start.sh"]