-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
79 lines (58 loc) · 2.48 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
## 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 python:3.11-slim-bullseye as backend-build-stage
RUN apt-get update && \
apt-get install --no-install-recommends -y curl git gcc linux-libc-dev libc6-dev unzip && \
pip install poetry
ENV MAGIC_CASTLE_PATH=/magic_castle
ENV MAGIC_CASTLE_VERSION=14.0.0-beta.2
RUN curl -L https://github.com/ComputeCanada/magic_castle/releases/download/${MAGIC_CASTLE_VERSION}/magic_castle-openstack-${MAGIC_CASTLE_VERSION}.tar.gz -o magic_castle.tar.gz && \
tar xvf magic_castle.tar.gz && \
mv magic_castle-* ${MAGIC_CASTLE_PATH} && \
chown -R root:root ${MAGIC_CASTLE_PATH}
ENV TERRAFORM_VERSION 1.5.7
RUN TERRAFORM_URL="https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_$(dpkg --print-architecture).zip" && \
curl -L ${TERRAFORM_URL} -o terraform.zip && \
unzip terraform.zip -d /usr/local/bin
ENV POETRY_VIRTUALENVS_CREATE=false \
POETRY_NO_INTERACTION=1 \
POETRY_CACHE_DIR='/var/cache/pypoetry' \
POETRY_HOME='/usr/local'
WORKDIR /code
ADD poetry.lock pyproject.toml /code/
COPY mchub /code/mchub
RUN poetry install --no-dev --no-ansi && \
pip uninstall -y poetry
FROM python:3.11-slim-bullseye as base-server
COPY --from=backend-build-stage /code /code
COPY --from=backend-build-stage /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
## Magic Castle User
RUN adduser --disabled-password mcu && \
mkdir -p /home/mcu && \
chown -R mcu:mcu /home/mcu
FROM base-server as cleanup-daemon
USER mcu
WORKDIR /home/mcu
CMD python3 -m mchub.services.cull_expired_cluster
## PRODUCTION IMAGE
FROM base-server as production-server
USER root
COPY --from=backend-build-stage /magic_castle /magic_castle
COPY --from=backend-build-stage /usr/local/bin/terraform /usr/local/bin/terraform
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 /home/mcu/.terraform.d/plugin-cache
ADD .terraformrc /home/mcu
ENV MAGIC_CASTLE_PATH=/magic_castle
ENV MAGIC_CASTLE_VERSION=14.0.0-beta.2
ENV MCH_DIST_PATH=/code/frontend
CMD python3 -m mchub.schema_update --clean && \
python3 -m mchub.init_clusters && \
python3 -m gunicorn --workers 5 --bind 0.0.0.0:5000 --worker-class gevent "mchub:create_app()"
#CMD python3 -m mchub.wsgi