Skip to content

Commit b1ca00a

Browse files
committed
Add GHCR compose, CI smoke test, and docs
Add docker-compose.ghcr.yml to run the published GitHub Container Registry image and introduce LABELIMG_IMAGE_TAG in .env.example to control image tag. Update README with instructions for using the prebuilt GHCR image and clarify local build steps. Enhance CI (/.github/workflows/docker.yml) to build a test image, run a smoke test that checks the /api/health and root page, and adjust build/push tagging (including latest for default branch) and cache settings. Add .gitkeep files for data and models/plugins and update .gitignore to ignore plugin files while preserving the .gitkeep placeholders.
1 parent ff1109a commit b1ca00a

7 files changed

Lines changed: 102 additions & 10 deletions

File tree

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
LABELIMG_PORT=8000
22
LABELIMG_DATASETS_DIR=./datasets
3+
LABELIMG_IMAGE_TAG=main

.github/workflows/docker.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,52 @@ jobs:
4141
with:
4242
images: ${{ env.IMAGE_NAME }}
4343
tags: |
44+
type=raw,value=latest,enable={{is_default_branch}}
4445
type=ref,event=branch
4546
type=ref,event=pr
4647
type=semver,pattern={{version}}
4748
type=semver,pattern={{major}}.{{minor}}
4849
type=sha
4950
51+
- name: Build image for smoke test
52+
uses: docker/build-push-action@v6
53+
with:
54+
context: .
55+
load: true
56+
tags: labelimg-next:ci
57+
cache-from: type=gha
58+
cache-to: type=gha,mode=max
59+
60+
- name: Smoke test image
61+
run: |
62+
set -euo pipefail
63+
64+
container_id="$(docker run --rm -d -p 127.0.0.1:18000:8000 labelimg-next:ci)"
65+
66+
cleanup() {
67+
docker rm -f "$container_id" >/dev/null 2>&1 || true
68+
}
69+
trap cleanup EXIT
70+
71+
for attempt in {1..30}; do
72+
if curl -fsS http://127.0.0.1:18000/api/health >/tmp/labelimg-health.json; then
73+
grep -q '"status":"ok"' /tmp/labelimg-health.json
74+
curl -fsS http://127.0.0.1:18000/ >/tmp/labelimg-index.html
75+
grep -qi '<!doctype html' /tmp/labelimg-index.html
76+
exit 0
77+
fi
78+
sleep 1
79+
done
80+
81+
docker logs "$container_id"
82+
exit 1
83+
5084
- name: Build and publish image
85+
if: github.event_name != 'pull_request'
5186
uses: docker/build-push-action@v6
5287
with:
5388
context: .
54-
push: ${{ github.event_name != 'pull_request' }}
89+
push: true
5590
tags: ${{ steps.meta.outputs.tags }}
5691
labels: ${{ steps.meta.outputs.labels }}
5792
cache-from: type=gha

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ tmp.*
5050
ehthumbs.db
5151
Thumbs.db
5252
/data/plugin-runtime-sources
53-
/models/plugins
53+
/models/plugins/*
54+
!/models/plugins/.gitkeep
5455
/datasets/*
5556
!/datasets/.gitkeep

README.md

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,59 @@
44

55
## Start
66

7-
### Docker
7+
### Docker: prebuilt image
8+
9+
Use the published GitHub Container Registry image when you only want to run the
10+
app and do not need to rebuild it from source.
11+
12+
```bash
13+
git clone https://github.com/SunOner/react_labelimg.git
14+
cd react_labelimg
15+
cp .env.example .env
16+
docker compose -f docker-compose.ghcr.yml pull
17+
docker compose -f docker-compose.ghcr.yml up
18+
```
19+
20+
On Windows PowerShell:
21+
22+
```powershell
23+
git clone https://github.com/SunOner/react_labelimg.git
24+
cd react_labelimg
25+
Copy-Item .env.example .env
26+
docker compose -f docker-compose.ghcr.yml pull
27+
docker compose -f docker-compose.ghcr.yml up
28+
```
29+
30+
The default image tag is `main`:
31+
32+
```bash
33+
ghcr.io/sunoner/react_labelimg:main
34+
```
35+
36+
The Docker workflow publishes `main` and `latest` for default branch builds.
37+
Tagged releases such as `v0.1.0` publish version tags such as `0.1.0` and
38+
`0.1`.
39+
40+
### Docker: build from source
841

942
Docker is the simplest way to run the app on Windows and Ubuntu. It builds the
1043
React frontend, installs the FastAPI backend dependencies and serves everything
1144
from one container.
1245

13-
Copy the example environment file and set the host folder that contains your
14-
images:
46+
Clone the repository, copy the example environment file and set the host folder
47+
that contains your images:
1548

1649
```bash
50+
git clone https://github.com/SunOner/react_labelimg.git
51+
cd react_labelimg
1752
cp .env.example .env
1853
```
1954

2055
On Windows PowerShell:
2156

2257
```powershell
58+
git clone https://github.com/SunOner/react_labelimg.git
59+
cd react_labelimg
2360
Copy-Item .env.example .env
2461
```
2562

@@ -51,15 +88,12 @@ Stop the app:
5188
docker compose down
5289
```
5390

54-
Build a release image manually:
91+
Build a local image manually:
5592

5693
```bash
57-
docker build -t labelimg-next:0.1.0 .
94+
docker build -t labelimg-next:local .
5895
```
5996

60-
Tagged GitHub releases such as `v0.1.0` are also built by the Docker workflow
61-
and published to GitHub Container Registry as `ghcr.io/<owner>/<repo>:0.1.0`.
62-
6397
### Local Python/Node
6498

6599
On Windows, run the project from inside WSL (WSL2 recommended). Open a WSL

data/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

docker-compose.ghcr.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
services:
2+
labelimg-next:
3+
image: ghcr.io/sunoner/react_labelimg:${LABELIMG_IMAGE_TAG:-main}
4+
pull_policy: always
5+
ports:
6+
- "${LABELIMG_PORT:-8000}:8000"
7+
environment:
8+
LABELIMG_DISABLE_FILE_DIALOGS: "1"
9+
volumes:
10+
- type: bind
11+
source: ./data
12+
target: /app/data
13+
- type: bind
14+
source: ./models/plugins
15+
target: /app/models/plugins
16+
- type: bind
17+
source: ${LABELIMG_DATASETS_DIR:-./datasets}
18+
target: /datasets
19+
restart: unless-stopped

models/plugins/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)