generated from Datawheel/template-tesseract-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
35 lines (22 loc) · 876 Bytes
/
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
FROM python:3.10 as builder
RUN pip install setuptools wheel poetry==1.8.3
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache
WORKDIR /app
COPY pyproject.toml poetry.lock ./
RUN touch README.md
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --without dev --no-root
FROM python:3.10-slim-buster as runtime
ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
WORKDIR /app
# create runtime user; install required dependencies
RUN useradd --system --uid 1001 tesseract &&\
chown -R tesseract:tesseract /app
COPY --chown=tesseract --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
COPY --chown=tesseract . /app
# change user to tesseract user
USER tesseract
CMD exec granian --interface asgi --host 0.0.0.0 --port 7777 --respawn-failed-workers app:layer