-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (45 loc) · 1.91 KB
/
Dockerfile
File metadata and controls
59 lines (45 loc) · 1.91 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
# build python app
FROM python:3.13-slim AS builder
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
WORKDIR /app
# install R (with build dependencies)
RUN rm -f /etc/apt/apt.conf.d/docker-clean; \
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt update \
&& apt install -y --no-upgrade --no-install-recommends \
r-base-dev \
git \
build-essential
ENV UV_LINK_MODE=copy \
UV_HTTP_TIMEOUT=300
# install only the dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --locked --no-install-project --no-editable --no-dev
# add project files and install the project
COPY ohsome_quality_api ohsome_quality_api
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --locked --no-editable --no-dev
RUN uv run pybabel compile -d ohsome_quality_api/locale
FROM python:3.13-slim
WORKDIR /app
ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
# install R (without build dependencies)
RUN rm -f /etc/apt/apt.conf.d/docker-clean; \
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt update \
&& apt install -y --no-upgrade --no-install-recommends \
r-base
# copy environment but not the source code
COPY --from=builder --chown=app:app $VIRTUAL_ENV $VIRTUAL_ENV
EXPOSE 8000/tcp
# run the application
CMD ["/app/.venv/bin/uvicorn","ohsome_quality_api.api.api:app","--host","0.0.0.0"]