Skip to content

Commit 8b26bc7

Browse files
Jonatan CastroJonatan Castro
authored andcommitted
Fix container privileges and Arcane deployment
1 parent 45557fe commit 8b26bc7

5 files changed

Lines changed: 27 additions & 7 deletions

File tree

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG PYTHON_BASE=python:3.12-slim@sha256:804ddf3251a60bbf9c92e73b7566c40428d54d0e79d3428194edf40da6521286
2-
ARG VERSION=0.1.1
2+
ARG VERSION=0.1.2
33
ARG BUILD_DATE=unknown
44
ARG VCS_REF=unknown
55
ARG SOURCE_URL=https://github.com/jonatan/stopliga
@@ -25,7 +25,7 @@ RUN pip install --upgrade pip==26.0.1 setuptools==82.0.1 wheel==0.46.3 \
2525

2626
FROM ${PYTHON_BASE} AS runtime
2727

28-
ARG VERSION=0.1.1
28+
ARG VERSION=0.1.2
2929
ARG BUILD_DATE=unknown
3030
ARG VCS_REF=unknown
3131
ARG SOURCE_URL=https://github.com/jonatan/stopliga

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,10 @@ UNIFI_API_KEY_FILE=/run/secrets/unifi_api_key
211211
El `docker-compose.yml` del repo está simplificado para producción normal:
212212

213213
- imagen `bluepr0/stopliga:latest`
214-
- `uid/gid 1000`
214+
- arranca como root solo para preparar `/data` y baja a `uid/gid 1000`
215215
- volumen `./data:/data`
216216
- secretos en `./secrets:/run/secrets:ro`
217+
- healthcheck desactivado en compose para evitar bloqueos del gestor de despliegue
217218

218219
Prueba puntual:
219220

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ services:
1616
read_only: true
1717
tmpfs:
1818
- /tmp
19+
healthcheck:
20+
disable: true
1921
cap_drop:
2022
- ALL
2123
security_opt:

docker/entrypoint.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,26 @@ def _ensure_writable_paths(uid: int, gid: int) -> None:
4949

5050

5151
def _drop_privileges(uid: int, gid: int) -> None:
52-
os.setgroups([])
53-
os.setgid(gid)
54-
os.setuid(uid)
52+
try:
53+
os.setgroups([])
54+
except PermissionError:
55+
pass
56+
57+
if os.getegid() != gid:
58+
try:
59+
os.setgid(gid)
60+
except PermissionError as exc:
61+
raise PermissionError(
62+
f"Unable to switch group to {gid}; run the container as that user/group or allow SETGID"
63+
) from exc
64+
65+
if os.geteuid() != uid:
66+
try:
67+
os.setuid(uid)
68+
except PermissionError as exc:
69+
raise PermissionError(
70+
f"Unable to switch user to {uid}; run the container as that user/group or allow SETUID"
71+
) from exc
5572

5673

5774
def main() -> int:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "stopliga"
7-
version = "0.1.1"
7+
version = "0.1.2"
88
description = "Synchronize a UniFi policy-based route with a public GitHub IP feed."
99
readme = "README.md"
1010
requires-python = ">=3.11"

0 commit comments

Comments
 (0)