-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (44 loc) · 1.53 KB
/
Dockerfile
File metadata and controls
60 lines (44 loc) · 1.53 KB
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
## FRONTEND BUILD STAGE
FROM node:18-bullseye as frontend-build-stage
WORKDIR /frontend
ADD frontend .
ENV UV_USE_IO_URING 0
RUN npm install && npm run build
# BACKEND BUILD STAGE
FROM ghcr.io/astral-sh/uv:python3.13-trixie-slim AS backend-build-stage
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
UV_PYTHON_DOWNLOADS=0
RUN apt-get update && \
apt-get install --no-install-recommends -y gcc linux-libc-dev libc6-dev
WORKDIR /code
COPY mchub /code/mchub
COPY migrations /code/migrations
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --locked --no-dev
FROM python:3.13-slim-trixie as base-server
COPY --from=backend-build-stage /code /code
## Magic Castle User
RUN adduser --disabled-password mcu && \
mkdir -p /home/mcu && \
chown -R mcu:mcu /home/mcu
ENV PATH="/code/.venv/bin:$PATH"
FROM base-server as cleanup-daemon
USER mcu
WORKDIR /home/mcu
CMD python -m mchub.services.cull_expired_cluster
## PRODUCTION IMAGE
FROM base-server as production-server
USER root
COPY --from=frontend-build-stage /frontend/dist /code/frontend
USER mcu
WORKDIR /home/mcu
RUN mkdir -p /home/mcu/clusters /home/mcu/database /home/mcu/credentials
ENV MCH_DIST_PATH=/code/frontend
ENV FLASK_APP="mchub:create_app"
CMD flask db upgrade && \
python -m mchub.schema_update && \
python -m mchub.init_clusters && \
python -m gunicorn --workers 5 --bind 0.0.0.0:5000 --worker-class gevent "mchub:create_app()"