-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
112 lines (85 loc) · 2.74 KB
/
Copy pathDockerfile
File metadata and controls
112 lines (85 loc) · 2.74 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
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
# TEKST-WEB BUILDER IMAGE
FROM node:24.1.0-alpine3.20 AS web-builder
WORKDIR /tekst
COPY Tekst-Web/ ./Tekst-Web/
COPY Tekst-API/openapi.json ./Tekst-API/openapi.json
RUN cd Tekst-Web && npm install && npm run build-only -- --base=./
# PYTHON ALPINE BASE IMAGE
FROM python:3.13-alpine3.21 AS py-base
ENV PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_DEFAULT_TIMEOUT=100 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
PIP_ROOT_USER_ACTION=ignore
# TEKST-API BUILDER IMAGE
FROM py-base AS api-builder
WORKDIR "/tekst"
COPY --from=ghcr.io/astral-sh/uv:0.12.13 /uv /uvx /bin/
COPY Tekst-API/tekst/ ./tekst/
COPY Tekst-API/uv.lock* \
Tekst-API/pyproject.toml \
Tekst-API/README.md \
Tekst-API/LICENSE \
./
RUN uv run pip install --upgrade \
pip \
setuptools \
wheel
RUN uv export \
--locked \
--no-group dev \
--no-hashes \
--no-progress \
--format requirements-txt \
--output-file requirements.txt
RUN uv run pip wheel \
--requirement requirements.txt \
--wheel-dir deps
RUN uv build --wheel
# FINAL PRODUCTION IMAGE
FROM py-base AS prod
ENV FASTAPI_ENV=production
WORKDIR "/tekst"
RUN set -x && \
addgroup -g 1111 -S tekst && \
adduser -u 1111 -S tekst -G tekst
RUN apk update && \
apk add --no-cache curl caddy
HEALTHCHECK \
--interval=2m \
--timeout=5s \
--retries=3 \
--start-period=30s \
CMD curl http://localhost:8000/status || exit 1
COPY --from=api-builder /tekst/deps/ api/deps/
COPY --from=api-builder /tekst/dist/ api/dist/
COPY --from=web-builder /tekst/Tekst-Web/dist/ /var/www/html/
RUN chown -R tekst:tekst /var/www/html/
RUN python3 -m pip install \
--no-index \
--find-links api/deps/ \
api/dist/*.whl && \
rm -rf api
RUN python3 -m pip install \
"uvicorn[standard]==0.51.0" \
"gunicorn==26.0.0"
COPY docker/caddy/Caddyfile /etc/caddy/Caddyfile
COPY docker/gunicorn/gunicorn_conf.py /etc/gunicorn/
COPY docker/entrypoint.sh /usr/local/bin/
VOLUME /var/www/tekst/static/
EXPOSE 8080
USER tekst
ARG TEKST_VERSION=unknown
LABEL \
org.opencontainers.image.title="Tekst" \
org.opencontainers.image.description="A collaborative research platform for resources on natural language texts" \
org.opencontainers.image.documentation="https://vedawebproject.github.io/Tekst/" \
org.opencontainers.image.url="https://github.com/VedaWebProject/Tekst" \
org.opencontainers.image.source="https://github.com/VedaWebProject/Tekst" \
org.opencontainers.image.licenses="AGPL-3.0-or-later" \
org.opencontainers.image.version="$TEKST_VERSION"
ENTRYPOINT ["entrypoint.sh"]
CMD ["gunicorn", "tekst.app:app", "--config", "/etc/gunicorn/gunicorn_conf.py"]