-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
121 lines (83 loc) · 3.31 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
#
# Node container for frontend build ("build")
#
FROM node:current-bookworm-slim@sha256:2bf48899bbba183a33b362842c9a9832f19c99896159551f9a0420c53ec27522 AS www-build
RUN set -x \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
brotli wget ca-certificates unzip
WORKDIR /tmp/extjsresources
COPY misc/download_external_resources.sh /tmp/download_external_resources.sh
RUN /tmp/download_external_resources.sh
COPY www /opt/sertifikatsok/www
WORKDIR /opt/sertifikatsok/www/
RUN ["cp", "--preserve=all", "-R", "/tmp/extjsresources/.", \
"/opt/sertifikatsok/www/public/resources/external" ]
RUN npm install
ARG SERTIFIKATSOK_VERSION
RUN ["npm", "run", "build"]
RUN [ "find", "dist", "-type", "f", "-not", "-name", "*.woff2", \
"-not", "-name", "*.woff", "-execdir", "brotli", "{}", ";" ]
#
# Python base container
#
FROM python:3.12.7-slim-bookworm@sha256:032c52613401895aa3d418a4c563d2d05f993bc3ecc065c8f4e2280978acd249 AS python-base
#
# Build base container
#
FROM python-base AS build-base
RUN set -x \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
gcc curl libc6-dev
#
# Python container for building the Rust lib
#
FROM build-base AS rust-build
# Download and install rustup
RUN set -x && curl https://sh.rustup.rs -sSf | sh -s -- -y \
--default-toolchain stable --profile minimal
ENV PATH="/root/.cargo/bin/:${PATH}"
RUN set -x && python3 -m venv /opt/sertifikatsok/rust-venv
RUN set -x && /opt/sertifikatsok/rust-venv/bin/pip --no-cache-dir --disable-pip-version-check install --upgrade pip
COPY requirements/ruldap3.txt /tmp/ruldap-requirements.txt
RUN set -x \
&& /opt/sertifikatsok/rust-venv/bin/pip install --require-hashes -r /tmp/ruldap-requirements.txt
COPY ruldap3 /opt/sertifikatsok/ruldap3
RUN set -x \
&& /opt/sertifikatsok/rust-venv/bin/maturin build --release -m /opt/sertifikatsok/ruldap3/Cargo.toml --manylinux off
#
# Python container for building
#
FROM build-base AS build
# Create venv for the app
RUN set -x && python3 -m venv /opt/sertifikatsok/venv
RUN set -x && /opt/sertifikatsok/venv/bin/pip --no-cache-dir --disable-pip-version-check install --upgrade pip
ENV PATH="/opt/sertifikatsok/venv/bin:${PATH}"
COPY requirements/main.txt /tmp/requirements.txt
RUN set -x \
&& cd /tmp \
&& /opt/sertifikatsok/venv/bin/pip install --require-hashes -r /tmp/requirements.txt
#
# Python container for testing
#
FROM build AS test
COPY requirements/dev.txt /tmp/requirements.dev.txt
RUN set -x \
&& cd /tmp \
&& /opt/sertifikatsok/venv/bin/pip install --require-hashes -r /tmp/requirements.dev.txt
COPY --from=rust-build /opt/sertifikatsok/ruldap3/target/wheels /opt/sertifikatsok/ruldap3/target/wheels
RUN pip install /opt/sertifikatsok/ruldap3/target/wheels/*
#
# PROD container
#
FROM python-base
ARG SERTIFIKATSOK_VERSION
ENV PATH="/opt/sertifikatsok/venv/bin:${PATH}" SERTIFIKATSOK_VERSION="${SERTIFIKATSOK_VERSION}"
WORKDIR /opt/sertifikatsok/api
COPY --from=www-build /opt/sertifikatsok/www/dist /opt/sertifikatsok/www/
COPY --from=build /opt/sertifikatsok/venv/ /opt/sertifikatsok/venv/
COPY --from=rust-build /opt/sertifikatsok/ruldap3/target/wheels /opt/sertifikatsok/ruldap3/target/wheels
RUN pip install /opt/sertifikatsok/ruldap3/target/wheels/*
COPY api /opt/sertifikatsok/api
ENTRYPOINT ["python", "-um", "sertifikatsok"]