-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (37 loc) · 1.73 KB
/
Copy pathDockerfile
File metadata and controls
51 lines (37 loc) · 1.73 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
# Dockerfile for the USAspending Backend API
# When built with docker compose --profile usaspending build,
# it will be built and tagged with the name in the image: key of the docker compose services that use this default Dockerfile
# Since requirements are copied into the image at build-time, this MUST be rebuilt if Python requirements change
# See docker-compose.yml file and README.md for docker compose information
FROM python:3.10.12-slim-bullseye
COPY --from=ghcr.io/astral-sh/uv:0.7.19 /uv /uvx /bin/
WORKDIR /dockermount
RUN apt update && apt install -y \
ca-certificates \
curl \
gcc \
libpq-dev \
openssl \
postgresql-13
RUN update-ca-certificates
##### The following ENV vars are optimizations from https://github.com/astral-sh/uv-docker-example/blob/main/Dockerfile
##### and https://docs.astral.sh/uv/guides/integration/docker/#optimizations
# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1
# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy
# Use the system Python environment since the container is already isolated
ENV UV_PROJECT_ENVIRONMENT=/usr/local
ENV UV_SYSTEM_PYTHON=1
# Install 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 --extra server --extra ansible --extra awscli --extra spark --locked --no-install-project --no-dev
# Copy the project into the image
COPY . /dockermount
# Sync the project
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --extra server --extra ansible --extra awscli --extra spark --locked --no-dev
##### Ensure Python STDOUT gets sent to container logs
ENV PYTHONUNBUFFERED=1