Skip to content

Commit 2b4a585

Browse files
committed
Configure compose for supported Python versions
1 parent 11d441b commit 2b4a585

File tree

13 files changed

+1091
-84
lines changed

13 files changed

+1091
-84
lines changed

.dockerignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/*.csv
2+
**/*.csv.bz2
3+
**/*.csv.gz
4+
**/*.csv.xz
5+
**/*.ods
6+
**/*.pyc
7+
**/*.xls
8+
**/*.xlsx
9+
**/*.zip
10+
**/__pycache__
11+
*.dump
12+
*.dump.gz
13+
.dockerignore
14+
.git
15+
.gitignore
16+
.pytest_cache
17+
.tags
18+
Dockerfile
19+
README.md
20+
build/
21+
collected-static/
22+
data/
23+
dist/
24+
docker/data/
25+
public/

Dockerfile

+40-19
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,43 @@
1-
FROM python:3.7
2-
MAINTAINER Álvaro Justen <https://github.com/turicas>
1+
ARG PYTHON_IMAGE="python"
2+
ARG PYTHON_VERSION="3.13"
3+
ARG DEBIAN_VERSION="bookworm"
4+
FROM ${PYTHON_IMAGE}:${PYTHON_VERSION}-slim-${DEBIAN_VERSION}
5+
LABEL org.opencontainers.image.authors="Álvaro Justen <[email protected]>"
6+
LABEL org.opencontainers.image.url="https://github.com/turicas/rows/"
37

4-
# Install system dependencies
5-
RUN apt-get update
6-
RUN apt-get install --no-install-recommends -y \
7-
build-essential git locales python3-dev libsnappy-dev \
8-
libxml2-dev libxslt-dev libz-dev libmupdf-dev && \
9-
apt-get clean && \
10-
pip install --no-cache-dir -U pip
8+
ENV PYTHONUNBUFFERED=1
9+
WORKDIR /app
10+
VOLUME /data
1111

12-
# Configure locale (needed to run tests)
13-
RUN echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen
14-
RUN echo 'pt_BR.UTF-8 UTF-8' >> /etc/locale.gen
15-
RUN /usr/sbin/locale-gen
12+
# Create a non-root user
13+
RUN addgroup --gid ${GID:-1000} python \
14+
&& adduser --disabled-password --gecos "" --home /app --uid ${UID:-1000} --gid ${GID:-1000} python \
15+
&& chown -R python:python /app
1616

17-
# Clone the repository and install Python dependencies
18-
RUN git clone https://github.com/turicas/rows.git /rows
19-
RUN cd /rows && \
20-
git checkout master && \
21-
pip install --no-cache-dir -r requirements-development.txt && \
22-
pip install --no-cache-dir -e .
17+
# Configure locale (required to run tests)
18+
RUN echo -e 'en_US.UTF-8 UTF-8\npt_BR.UTF-8 UTF-8' > /etc/locale.gen
19+
20+
# Upgrade and install required system packages
21+
RUN apt update \
22+
&& apt upgrade -y \
23+
&& apt install --no-install-recommends -y build-essential libfreetype-dev libmagic1 libmupdf-dev libpq-dev \
24+
libsnappy-dev libxml2-dev libxslt-dev libz-dev locales postgresql-client \
25+
python3-dev wget \
26+
&& apt purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
27+
&& apt clean \
28+
&& rm -rf /var/lib/apt/lists/*
29+
30+
# Upgrade pip and install (if needed) expensive-to-build, big packages and the ones from other indexes (for caching)
31+
RUN --mount=type=cache,target=/var/cache/pip pip install --cache-dir /var/cache/pip -U pip
32+
33+
# Install requirements
34+
COPY --chown=python:python requirements.txt requirements-development.txt /app/
35+
RUN --mount=type=cache,target=/var/cache/pip \
36+
pip install --cache-dir /var/cache/pip -Ur /app/requirements.txt \
37+
&& pip install --cache-dir /var/cache/pip -Ur /app/requirements-development.txt
38+
39+
# Copy all needed files and set permissions
40+
COPY --chown=python:python . /app/
41+
RUN pip install -e .
42+
USER python
43+
CMD ["rows"]

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
MAKEFLAGS += --always-make
2+
PYTHON_VERSIONS = 27 35 36 37 38 39 310 311 312 313
3+
TEST_PY_TARGETS = $(foreach version, $(PYTHON_VERSIONS), test-py$(version))
4+
BUILD_PY_TARGETS = $(foreach version, $(PYTHON_VERSIONS), build-py$(version))
5+
16
envtest: clean
27
nosetests tests/
38

compose.yml

+119-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,127 @@
11
services:
2-
db:
2+
3+
py313:
4+
profiles: [py313]
5+
env_file:
6+
- path: "docker/env/python"
7+
required: true
8+
- path: "docker/env/python.local"
9+
required: false
310
user: "${UID:-1000}:${GID:-1000}"
11+
build:
12+
context: .
13+
dockerfile: "Dockerfile"
14+
args:
15+
PYTHON_IMAGE: "python"
16+
PYTHON_VERSION: "3.13"
17+
DEBIAN_VERSION: "bookworm"
18+
image: turicas/rows-py313:dev
19+
pull_policy: build
20+
volumes:
21+
- ${PWD}/docker/data/python/:/data/
22+
- ${PWD}/:/app/
23+
depends_on:
24+
postgres:
25+
condition: service_healthy
26+
27+
py312:
28+
profiles: [py312]
29+
extends:
30+
service: py313
31+
build:
32+
args:
33+
PYTHON_VERSION: "3.12"
34+
image: turicas/rows-py312:dev
35+
36+
py311:
37+
profiles: [py311]
38+
extends:
39+
service: py313
40+
build:
41+
args:
42+
PYTHON_VERSION: "3.11"
43+
image: turicas/rows-py311:dev
44+
45+
py310:
46+
profiles: [py310]
47+
extends:
48+
service: py313
49+
build:
50+
args:
51+
PYTHON_VERSION: "3.10"
52+
image: turicas/rows-py310:dev
53+
54+
py39:
55+
profiles: [py39]
56+
extends:
57+
service: py313
58+
build:
59+
args:
60+
PYTHON_VERSION: "3.9"
61+
image: turicas/rows-py39:dev
62+
63+
py38:
64+
profiles: [py38]
65+
extends:
66+
service: py313
67+
build:
68+
args:
69+
PYTHON_VERSION: "3.8"
70+
image: turicas/rows-py38:dev
71+
72+
py37:
73+
profiles: [py37]
74+
extends:
75+
service: py313
76+
build:
77+
args:
78+
PYTHON_VERSION: "3.7"
79+
image: turicas/rows-py37:dev
80+
81+
py36:
82+
profiles: [py36]
83+
extends:
84+
service: py313
85+
build:
86+
args:
87+
PYTHON_IMAGE: "turicas/python"
88+
PYTHON_VERSION: "3.6"
89+
image: turicas/rows-py36:dev
90+
91+
py35:
92+
profiles: [py35]
93+
extends:
94+
service: py313
95+
build:
96+
args:
97+
PYTHON_IMAGE: "turicas/python"
98+
PYTHON_VERSION: "3.5"
99+
image: turicas/rows-py35:dev
100+
101+
py27:
102+
profiles: [py27]
103+
extends:
104+
service: py313
105+
build:
106+
args:
107+
PYTHON_IMAGE: "turicas/python"
108+
PYTHON_VERSION: "2.7"
109+
image: turicas/rows-py27:dev
110+
111+
postgres:
4112
env_file:
5-
- "docker/env/db"
6-
- "docker/env/db.local"
7-
image: postgres:16-bullseye
8-
command: -c "config_file=/etc/postgresql/postgresql.conf"
9-
shm_size: 4g
113+
- path: "docker/env/postgres"
114+
required: true
115+
- path: "docker/env/postgres.local"
116+
required: false
117+
user: "${UID:-1000}:${GID:-1000}"
118+
shm_size: "4g"
119+
image: "postgres:17.4-bookworm"
120+
command: ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]
10121
volumes:
11-
- ${PWD}/docker/data/db:/var/lib/postgresql/data
12-
- ${PWD}/docker/conf/db/postgresql.dev.conf:/etc/postgresql/postgresql.conf
122+
- ${PWD}/docker/data/postgres/:/data/
123+
- ${PWD}/docker/conf/postgres/postgresql.dev.conf:/etc/postgresql/postgresql.conf
13124
healthcheck:
14125
test: ["CMD-SHELL", "pg_isready -U postgres"]
15126
interval: 3s
16127
retries: 5
17-
ports:
18-
- "42001:5432"

0 commit comments

Comments
 (0)