|
| 1 | +# syntax=docker/dockerfile:1.7 |
| 2 | + |
| 3 | +# Stage 1 — builder: same base as runtime so the venv's interpreter symlink |
| 4 | +# (/usr/bin/python3) is valid in the runtime stage. We install build deps to |
| 5 | +# compile any wheels that lack a musllinux build, then drop them. |
| 6 | +# |
| 7 | +# Caddy >= 2.8 is required: Caddyfile.auth uses the renamed `basic_auth` |
| 8 | +# directive (was `basicauth` in 2.7 and earlier). The `caddy:2-alpine` tag |
| 9 | +# tracks the latest 2.x and is well past 2.8 at the time of writing. |
| 10 | +FROM --platform=$TARGETPLATFORM caddy:2-alpine AS builder |
| 11 | + |
| 12 | +RUN apk add --no-cache \ |
| 13 | + python3 \ |
| 14 | + py3-pip \ |
| 15 | + && apk add --no-cache --virtual .build-deps \ |
| 16 | + gcc \ |
| 17 | + musl-dev \ |
| 18 | + libffi-dev \ |
| 19 | + openssl-dev \ |
| 20 | + python3-dev \ |
| 21 | + make |
| 22 | + |
| 23 | +COPY backend/requirements.txt /tmp/requirements.txt |
| 24 | + |
| 25 | +RUN python3 -m venv /opt/venv \ |
| 26 | + && /opt/venv/bin/pip install --no-cache-dir --upgrade pip \ |
| 27 | + && /opt/venv/bin/pip install --no-cache-dir -r /tmp/requirements.txt |
| 28 | + |
| 29 | +# Stage 2 — runtime. Same base, only python3/py3-pip installed (no compilers). |
| 30 | +FROM --platform=$TARGETPLATFORM caddy:2-alpine |
| 31 | + |
| 32 | +RUN apk add --no-cache \ |
| 33 | + python3 \ |
| 34 | + supervisor \ |
| 35 | + ca-certificates \ |
| 36 | + tini |
| 37 | + |
| 38 | +COPY --from=builder /opt/venv /opt/venv |
| 39 | + |
| 40 | +ENV PATH="/opt/venv/bin:${PATH}" \ |
| 41 | + PYTHONUNBUFFERED=1 \ |
| 42 | + PYTHONDONTWRITEBYTECODE=1 \ |
| 43 | + PYTHONPATH=/app |
| 44 | + |
| 45 | +WORKDIR /app |
| 46 | + |
| 47 | +COPY backend/ /app/backend/ |
| 48 | +COPY frontend/ /srv/frontend/ |
| 49 | +COPY Caddyfile /etc/caddy/Caddyfile |
| 50 | +COPY Caddyfile.auth /etc/caddy/Caddyfile.auth |
| 51 | +COPY supervisord.conf /etc/supervisor/conf.d/mihomo-webui.conf |
| 52 | +COPY start-caddy.sh /usr/local/bin/start-caddy.sh |
| 53 | +RUN chmod +x /usr/local/bin/start-caddy.sh |
| 54 | + |
| 55 | +ENV WEBUI_PORT=80 \ |
| 56 | + BACKEND_HOST=127.0.0.1 \ |
| 57 | + BACKEND_PORT=8000 \ |
| 58 | + MIKROTIK_HOST="" \ |
| 59 | + MIKROTIK_USER="" \ |
| 60 | + MIKROTIK_PASSWORD="" \ |
| 61 | + MIKROTIK_VERIFY_TLS=false \ |
| 62 | + MIKROTIK_CONTAINER_COMMENT=MihomoProxyRoS \ |
| 63 | + MIKROTIK_ENVS_LIST=MihomoProxyRoS \ |
| 64 | + WEBUI_USER="" \ |
| 65 | + WEBUI_PASSWORD_HASH="" |
| 66 | + |
| 67 | +EXPOSE 80 |
| 68 | + |
| 69 | +ENTRYPOINT ["/sbin/tini", "--"] |
| 70 | +CMD ["supervisord", "-c", "/etc/supervisor/conf.d/mihomo-webui.conf", "-n"] |
0 commit comments