-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
78 lines (41 loc) · 1.43 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
FROM python:3.13.1-slim AS base
LABEL Github="hibare"
# Build frontend assets
FROM node:23 AS frontend
ENV NODE_OPTIONS=--openssl-legacy-provider
ENV BUILD_DIR=/frontend
WORKDIR ${BUILD_DIR}
COPY ./frontend/package*.json ${BUILD_DIR}/
RUN npm install
COPY ./frontend ${BUILD_DIR}
RUN npm run build
# Build backend deps
FROM base AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
RUN apt-get update && apt-get install -y build-essential python3-dev libpq-dev libssl-dev libffi-dev rustc
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY backend/requirements.txt .
RUN pip install -U pip setuptools wheel && pip install -r requirements.txt
# Build final image
FROM base
ENV USER=ghost
ENV APP_DIR=/home/${USER}/app
RUN apt-get update && apt-get install -y libpq5
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN useradd -ms /bin/bash ${USER}
USER ${USER}
RUN mkdir -p ${APP_DIR}
WORKDIR ${APP_DIR}
COPY --chown=${USER}:${USER} backend .
# Copy assets
COPY --from=frontend --chown=${USER}:${USER} /frontend/dist/static ${APP_DIR}/moni/assets/static/
# Copy templates
COPY --from=frontend --chown=${USER}:${USER} /frontend/dist/*.html ${APP_DIR}/moni/assets/templates
# Copy favicon
COPY --from=frontend --chown=${USER}:${USER} /frontend/dist/favicon.png ${APP_DIR}/moni/assets/static/img/
RUN python manage.py collectstatic --no-input
EXPOSE 8000
CMD ["sh", "entrypoint.sh"]