-
Notifications
You must be signed in to change notification settings - Fork 135
/
Copy pathDockerfile
43 lines (36 loc) · 1.8 KB
/
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
36
37
38
39
40
41
42
43
ARG PYTHON_IMAGE="python"
ARG PYTHON_VERSION="3.13"
ARG DEBIAN_VERSION="bookworm"
FROM ${PYTHON_IMAGE}:${PYTHON_VERSION}-slim-${DEBIAN_VERSION}
LABEL org.opencontainers.image.authors="Álvaro Justen <[email protected]>"
LABEL org.opencontainers.image.url="https://github.com/turicas/rows/"
ENV PYTHONUNBUFFERED=1
WORKDIR /app
VOLUME /data
# Create a non-root user
RUN addgroup --gid ${GID:-1000} python \
&& adduser --disabled-password --gecos "" --home /app --uid ${UID:-1000} --gid ${GID:-1000} python \
&& chown -R python:python /app
# Configure locale (required to run tests)
RUN bash -c 'echo -e "en_US.UTF-8 UTF-8\npt_BR.UTF-8 UTF-8" > /etc/locale.gen'
# Upgrade and install required system packages
RUN apt update \
&& apt upgrade -y \
&& apt install --no-install-recommends -y build-essential libffi-dev libfreetype-dev libmagic1 libmupdf-dev \
libpq-dev libsnappy-dev libxml2-dev libxslt-dev libz-dev locales \
postgresql-client python3-dev sqlite3 wget \
&& apt purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*
# Upgrade pip and install (if needed) expensive-to-build, big packages and the ones from other indexes (for caching)
RUN --mount=type=cache,target=/var/cache/pip pip install --cache-dir /var/cache/pip -U pip
# Install requirements
COPY --chown=python:python requirements.txt requirements-development.txt /app/
RUN --mount=type=cache,target=/var/cache/pip \
pip install --cache-dir /var/cache/pip -Ur /app/requirements.txt \
&& pip install --cache-dir /var/cache/pip -Ur /app/requirements-development.txt
# Copy all needed files and set permissions
COPY --chown=python:python . /app/
RUN pip install -e .
USER python
CMD ["rows"]