Skip to content

Commit 5494190

Browse files
authored
Merge pull request #6 from karuboniru/master
Provide image with or without api_dump.sql
2 parents 56c1987 + 26b4a94 commit 5494190

5 files changed

Lines changed: 97 additions & 47 deletions

File tree

.github/workflows/docker-publish.yml

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ env:
1818
REGISTRY: ghcr.io
1919
# github.repository as <account>/<repo>
2020
IMAGE_NAME: ${{ github.repository }}
21+
# docker.io/<account>/<repo>
22+
AUTHOR: urenko
2123

2224

23-
jobs:
25+
jobs:
2426
build:
2527

2628
runs-on: ubuntu-latest
@@ -53,20 +55,49 @@ jobs:
5355
# https://github.com/docker/login-action
5456
- name: Log into registry ${{ env.REGISTRY }}
5557
if: github.event_name != 'pull_request'
56-
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
58+
uses: docker/login-action@v3 # v3.0.0
5759
with:
5860
registry: ${{ env.REGISTRY }}
5961
username: ${{ github.actor }}
6062
password: ${{ secrets.GITHUB_TOKEN }}
63+
-
64+
name: Login to Docker Hub
65+
if: github.event_name != 'pull_request'
66+
uses: docker/login-action@v3
67+
with:
68+
username: ${{ secrets.DOCKERHUB_USERNAME }}
69+
password: ${{ secrets.DOCKERHUB_TOKEN }}
6170

6271
# Extract metadata (tags, labels) for Docker
6372
# https://github.com/docker/metadata-action
64-
- name: Extract Docker metadata
73+
- name: Extract Docker metadata from ${{ env.REGISTRY }}
6574
id: meta
6675
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
6776
with:
6877
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
6978

79+
- name: Extract Docker metadata from Docker Hub
80+
id: meta_dockerhub
81+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
82+
with:
83+
images: docker.io/${{ secrets.DOCKERHUB_USERNAME || env.AUTHOR }}/${{ github.event.repository.name }}
84+
85+
- name: Extract Docker metadata from ${{ env.REGISTRY }}
86+
id: meta-full
87+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
88+
with:
89+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
90+
flavor: |
91+
suffix=-full,onlatest=true
92+
93+
- name: Extract Docker metadata from Docker Hub
94+
id: meta_dockerhub-full
95+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
96+
with:
97+
images: docker.io/${{ secrets.DOCKERHUB_USERNAME || env.AUTHOR }}/${{ github.event.repository.name }}
98+
flavor: |
99+
suffix=-full,onlatest=true
100+
70101
# Build and push Docker image with Buildx (don't push on PR)
71102
# https://github.com/docker/build-push-action
72103
- name: Build and push Docker image
@@ -75,8 +106,27 @@ jobs:
75106
with:
76107
context: .
77108
push: ${{ github.event_name != 'pull_request' }}
78-
tags: ${{ steps.meta.outputs.tags }}
109+
tags: |
110+
${{ steps.meta.outputs.tags }}
111+
${{ steps.meta_dockerhub.outputs.tags }}
79112
labels: ${{ steps.meta.outputs.labels }}
113+
build-args: |
114+
BUILDTYPE=minimal
115+
cache-from: type=gha
116+
cache-to: type=gha,mode=max
117+
118+
- name: Build and push Docker image with api_dump.sql
119+
id: build-and-push-full
120+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
121+
with:
122+
context: .
123+
push: ${{ github.event_name != 'pull_request' }}
124+
tags: |
125+
${{ steps.meta-full.outputs.tags }}
126+
${{ steps.meta_dockerhub-full.outputs.tags }}
127+
labels: ${{ steps.meta.outputs.labels }}
128+
build-args: |
129+
BUILDTYPE=full
80130
cache-from: type=gha
81131
cache-to: type=gha,mode=max
82132

@@ -89,8 +139,22 @@ jobs:
89139
if: ${{ github.event_name != 'pull_request' }}
90140
env:
91141
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
92-
TAGS: ${{ steps.meta.outputs.tags }}
93-
DIGEST: ${{ steps.build-and-push.outputs.digest }}
142+
TAGS: |
143+
${{ steps.meta.outputs.tags }}
144+
DIGEST: |
145+
${{ steps.build-and-push.outputs.digest }}
146+
# This step uses the identity token to provision an ephemeral certificate
147+
# against the sigstore community Fulcio instance.
148+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
149+
150+
- name: Sign the published Docker image for full image
151+
if: ${{ github.event_name != 'pull_request' }}
152+
env:
153+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
154+
TAGS: |
155+
${{ steps.meta-full.outputs.tags }}
156+
DIGEST: |
157+
${{ steps.build-and-push-full.outputs.digest }}
94158
# This step uses the identity token to provision an ephemeral certificate
95159
# against the sigstore community Fulcio instance.
96160
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

.github/workflows/docker.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

Dockerfile

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
ARG BUILDTYPE=minimal
2+
13
FROM debian:12-slim AS build-venv
24

35
RUN apt-get update && \
@@ -6,26 +8,35 @@ RUN apt-get update && \
68
python3 -m venv /venv && \
79
/venv/bin/pip install --upgrade pip
810

9-
ADD https://files.niconi.org/api_dump.sqlite.7z /tmp
1011
ADD https://github.com/eugeneware/ffmpeg-static/releases/download/b6.0/ffmpeg-linux-x64 /usr/bin/ffmpeg
1112
ADD https://www.7-zip.org/a/7z2301-linux-x64.tar.xz /tmp/
1213
RUN tar -C /usr/bin -xvf /tmp/7z*.tar.xz 7zz
13-
RUN mkdir /exract
14-
WORKDIR /extract
15-
RUN 7zz x /tmp/api_dump.sqlite.7z
1614
COPY . /tmp/comiclib
1715
RUN /venv/bin/pip install --no-cache-dir -U "/tmp/comiclib[full]"
1816
RUN /venv/bin/pip install --no-cache-dir -U gunicorn
1917
RUN mkdir /userdata
20-
# RUN rm -r /tmp/*
2118

22-
FROM gcr.io/distroless/python3-debian12
19+
FROM debian:12-slim AS data
20+
ADD https://files.niconi.org/api_dump.sqlite.7z /tmp
21+
COPY --from=build-venv /usr/bin/7zz /usr/bin
22+
RUN mkdir /exract
23+
WORKDIR /extract
24+
RUN 7zz x /tmp/api_dump.sqlite.7z
25+
26+
FROM gcr.io/distroless/python3-debian12 AS product-env-full
27+
ENV importEHdb_database_URI=file:/data/api_dump.sqlite?mode=rw
28+
COPY --from=data /extract/api_dump.sqlite /data/api_dump.sqlite
29+
30+
FROM gcr.io/distroless/python3-debian12 AS product-env-minimal
31+
ENV importEHdb_database_URI=file:api_dump.sqlite?mode=rw
32+
33+
34+
FROM product-env-${BUILDTYPE}
2335
COPY --from=build-venv /venv /venv
2436
COPY --from=build-venv /usr/bin/7zz /usr/bin
2537
COPY --from=build-venv /usr/bin/ffmpeg /usr/bin
26-
COPY --from=build-venv /extract/api_dump.sqlite /data/api_dump.sqlite
2738
COPY --from=build-venv /userdata /userdata
28-
ENV importEHdb_API_DUMP_PATH=/data/api_dump.sqlite content=/root/comiclib watch=False
39+
ENV content=/root/comiclib watch=False
2940
EXPOSE 8000
3041
WORKDIR /userdata
3142
VOLUME /userdata

docs/en/docs/getting-started.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ pip install -U "comiclib[full] @ git+https://github.com/comiclib/comiclib.git"
4040
docker run -p 8000:8000 \
4141
--mount type=bind,source=<YOUR_COMIC_DIRECTORY_HERE>,target=/root/comiclib \
4242
--mount type=bind,source=<USER_DATA_PATH>,target=/userdata \
43-
urenko/comiclib
43+
ghcr.io/comiclib/comiclib:master
4444
```
45-
ComicLib now runs at http://localhost:8000 .
45+
ComicLib now runs at http://localhost:8000 . If you want to use `api_dump.sqlite`, please put it under `/userdata`.
46+
47+
Or you can use images with `-full` suffix to include `api_dump.sqlite` in the image, however the image size is much larger.
4648

4749
P.S.: Monitoring comic folders is disabled by default for Docker currently.
4850

docs/zh/docs/getting-started.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ pip install -U "comiclib[full] @ git+https://github.com/comiclib/comiclib.git"
4040
docker run -p 8000:8000 \
4141
--mount type=bind,source=你的漫画库路径,target=/root/comiclib \
4242
--mount type=bind,source=你的数据路径,target=/userdata \
43-
urenko/comiclib
43+
ghcr.io/comiclib/comiclib:master
4444
```
45-
现在 ComicLib 运行在了 http://localhost:8000
45+
现在 ComicLib 运行在了 http://localhost:8000 。如果你想要使用 `api_dump.sqlite`, 请手动下载并将其放在 `/userdata` 下。
46+
47+
或者你可以使用带有 `-full` 后缀的镜像,其中包含了 `api_dump.sqlite`,但镜像大小会大很多。
4648

4749
注:目前监视漫画文件夹默认对 Docker 禁用。
4850

0 commit comments

Comments
 (0)