Skip to content

Commit 45557fe

Browse files
Jonatan CastroJonatan Castro
authored andcommitted
Prepare Docker Hub publishing and production compose
1 parent 647ae66 commit 45557fe

File tree

6 files changed

+97
-16
lines changed

6 files changed

+97
-16
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ UNIFI_HOST=192.168.1.1
55
# UNIFI_API_KEY_FILE=/run/secrets/unifi_api_key
66
UNIFI_USERNAME=admin
77
UNIFI_PASSWORD=change-me
8+
# UNIFI_USERNAME_FILE=/run/secrets/unifi_username
89
# UNIFI_PASSWORD_FILE=/run/secrets/unifi_password
910

1011
# Optional but recommended for plug-and-play route creation
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish Docker Image
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
env:
10+
IMAGE_NAME: bluepr0/stopliga
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up QEMU
21+
uses: docker/setup-qemu-action@v3
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Log in to Docker Hub
27+
uses: docker/login-action@v3
28+
with:
29+
username: ${{ secrets.DOCKERHUB_USERNAME }}
30+
password: ${{ secrets.DOCKERHUB_TOKEN }}
31+
32+
- name: Set build date
33+
id: build_date
34+
run: echo "value=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
35+
36+
- name: Extract Docker metadata
37+
id: meta
38+
uses: docker/metadata-action@v5
39+
with:
40+
images: ${{ env.IMAGE_NAME }}
41+
flavor: |
42+
latest=true
43+
tags: |
44+
type=semver,pattern={{version}}
45+
type=semver,pattern={{major}}.{{minor}}
46+
labels: |
47+
org.opencontainers.image.title=StopLiga
48+
org.opencontainers.image.description=Synchronize a UniFi policy-based route with a public GitHub IP feed.
49+
50+
- name: Build and push
51+
uses: docker/build-push-action@v6
52+
with:
53+
context: .
54+
platforms: linux/amd64,linux/arm64
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
build-args: |
59+
VERSION=${{ steps.meta.outputs.version }}
60+
BUILD_DATE=${{ steps.build_date.outputs.value }}
61+
VCS_REF=${{ github.sha }}

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.0
2+
ARG VERSION=0.1.1
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.0
28+
ARG VERSION=0.1.1
2929
ARG BUILD_DATE=unknown
3030
ARG VCS_REF=unknown
3131
ARG SOURCE_URL=https://github.com/jonatan/stopliga

README.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,15 @@ STOPLIGA_RUN_MODE=loop
150150
docker build -t stopliga .
151151
```
152152

153+
### Publicar en Docker Hub
154+
155+
La release automática usa [publish-docker.yml](/Users/jonatan/Code/stopliga/.github/workflows/publish-docker.yml:1) y se dispara al hacer push de una tag `v*`.
156+
157+
Secrets requeridos en GitHub:
158+
159+
- `DOCKERHUB_USERNAME`
160+
- `DOCKERHUB_TOKEN`
161+
153162
### One-shot
154163

155164
```bash
@@ -172,25 +181,39 @@ docker run -d \
172181

173182
## Docker Compose
174183

175-
El proyecto incluye [docker-compose.yml](/Users/jonatan/Nextcloud/AI/Claude/Apps/StopLiga/docker-compose.yml:1).
184+
El proyecto incluye [docker-compose.yml](/Users/jonatan/Code/stopliga/docker-compose.yml:1).
176185

177186
```bash
178187
cp .env.example .env
179188
mkdir -p secrets
180-
docker compose up -d --build
189+
docker compose pull
190+
docker compose up -d
181191
```
182192

183193
Si quieres evitar secretos en variables de entorno:
184194

185195
```bash
186196
printf '%s\n' 'replace-me' > secrets/unifi_api_key
197+
printf '%s\n' 'admin' > secrets/unifi_username
187198
printf '%s\n' 'change-me' > secrets/unifi_password
188-
chmod 600 secrets/unifi_api_key secrets/unifi_password
199+
chmod 600 secrets/unifi_api_key secrets/unifi_username secrets/unifi_password
200+
```
201+
202+
Y en `.env` deja solo `UNIFI_HOST` y referencia los ficheros:
203+
204+
```dotenv
205+
UNIFI_API_KEY_FILE=/run/secrets/unifi_api_key
206+
# o, si usas login local:
207+
# UNIFI_USERNAME_FILE=/run/secrets/unifi_username
208+
# UNIFI_PASSWORD_FILE=/run/secrets/unifi_password
189209
```
190210

191-
Y en `.env` deja solo `UNIFI_HOST` y, si aplica, `UNIFI_USERNAME`.
211+
El `docker-compose.yml` del repo está simplificado para producción normal:
192212

193-
El `docker-compose.yml` del repo ya viene preparado para Linux con `STOPLIGA_UID=1000` y `STOPLIGA_GID=1000` por defecto. Si tu host usa otro UID/GID, cámbialos en `.env`.
213+
- imagen `bluepr0/stopliga:latest`
214+
- `uid/gid 1000`
215+
- volumen `./data:/data`
216+
- secretos en `./secrets:/run/secrets:ro`
194217

195218
Prueba puntual:
196219

docker-compose.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
services:
22
stopliga:
3-
build: .
4-
image: stopliga:local
3+
image: bluepr0/stopliga:latest
54
container_name: stopliga
65
init: true
76
restart: unless-stopped
87
env_file:
9-
- path: .env
10-
required: false
8+
- .env
119
environment:
12-
STOPLIGA_UID: ${STOPLIGA_UID:-1000}
13-
STOPLIGA_GID: ${STOPLIGA_GID:-1000}
14-
UNIFI_API_KEY_FILE: /run/secrets/unifi_api_key
15-
UNIFI_PASSWORD_FILE: /run/secrets/unifi_password
10+
STOPLIGA_UID: 1000
11+
STOPLIGA_GID: 1000
1612
command: ["--loop"]
1713
volumes:
1814
- ./data:/data

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.0"
7+
version = "0.1.1"
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)