forked from iamrony777/javinfo-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.build
77 lines (54 loc) · 2.06 KB
/
Dockerfile.build
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
# Build
FROM python:alpine AS build
VOLUME [ "/data" ]
WORKDIR /app
COPY pyproject.toml /app/
# Build deps - alpine
ENV COMMON_DEPS='libffi-dev git ca-certificates linux-headers musl-dev gcc build-base libxml2-dev libxslt-dev openssl-dev' \
PILLOW_DEPS='freetype-dev fribidi-dev harfbuzz-dev jpeg-dev lcms2-dev libimagequant-dev openjpeg-dev tcl-dev tiff-dev tk-dev zlib-dev' \
WATCHFILES_DEPS='rust cargo'
# https://github.com/rust-lang/cargo/issues/10230#issuecomment-1120018227
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true \
CARGO_BUILD_RUSTFLAGS="-O"
# Build deps - python
RUN apk add --no-cache ${COMMON_DEPS} ${PILLOW_DEPS} ${WATCHFILES_DEPS} && \
pip install --no-cache-dir -U pip setuptools wheel poetry && \
poetry config virtualenvs.create false && \
poetry export --output requirements.txt --without-hashes --without=dev
RUN MAKEFLAGS="-j$(nproc)" SETUPFLAGS="-j$(nproc)" ; pip wheel --wheel-dir=/app/wheels -r requirements.txt
# Production
FROM python:alpine AS prod
VOLUME [ "/data" ]
WORKDIR /app
COPY ./ /app/
COPY --from=build /app/wheels /app/wheels
COPY --from=build /app/requirements.txt /app/requirements.txt
# Common (Required)
ARG CREATE_REDIS
ARG PLATFORM=container
# Optional , Platform based
ARG APP_NAME
ARG RAILWAY_STATIC_URL
ARG RENDER_EXTERNAL_URL
ENV RUNTIME_DEPS="curl jq tmux ca-certificates bash libjpeg redis"
ENV PYTHONPATH=. \
PLATFORM=${PLATFORM} \
OVERMIND_NO_PORT=1 \
API_USER=admin \
API_PASS=admin \
CREATE_REDIS=${CREATE_REDIS:-false} \
LOG_REQUEST=${LOG_REQUEST:-false} \
TZ=${TZ:-UTC} \
INACTIVITY_TIMEOUT=300
RUN apk add --no-cache ${RUNTIME_DEPS} && \
chmod +x install.sh && bash /app/install.sh && \
pip install --no-cache-dir /app/wheels/* && \
rm -rf /app/wheels && \
python -m compileall -q .
RUN mkdocs build -f /app/conf/mkdocs.yml && \
pip uninstall mkdocs-material -y
EXPOSE ${PORT}
HEALTHCHECK --interval=5m --timeout=30s --start-period=5s --retries=5 \
CMD HEALTHCHECK_PROVIDER=local /app/api/scripts/ping.py
SHELL [ "/bin/bash", "-c" ]
CMD ["./start.sh"]