From cc57dee33458f88e4da5e4e3d2b5dc5c9f56b88c Mon Sep 17 00:00:00 2001 From: Yadunand Prem Date: Tue, 5 Aug 2025 11:51:37 +0800 Subject: [PATCH] Add Dockerfile and gitea workflow --- .gitea/workflows/build-image.yaml | 42 +++++++++++++++++++++++++++++++ .gitignore | 18 +++++++++++++ Dockerfile | 25 ++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 .gitea/workflows/build-image.yaml create mode 100644 .gitignore create mode 100644 Dockerfile diff --git a/.gitea/workflows/build-image.yaml b/.gitea/workflows/build-image.yaml new file mode 100644 index 0000000..f414771 --- /dev/null +++ b/.gitea/workflows/build-image.yaml @@ -0,0 +1,42 @@ +name: Build OCI Image + +on: + workflow_dispatch: + push: + branches: + - main + tags: + - 'v*' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + harbor.yadunut.dev/yadunut/yadunut.dev + # generate Docker tags based on the following events/attributes + tags: | + type=sha,suffix=-{{ commit_date 'X' }} + type=ref,event=branch + type=semver,pattern={{version}} + + - name: Login to Harbor + uses: docker/login-action@v3 + with: + registry: harbor.yadunut.dev + username: ${{ secrets.HARBOR_USERNAME }} + password: ${{ secrets.HARBOR_PASSWORD }} + - name: Setup Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e11ee65 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +* +!.gitignore +!flake.lock +!flake.nix +!zine.ziggy +!Dockerfile +!layouts/ +!layouts/** + +!content/ +!content/** + +!assets/ +!assets/** + +!.gitea/ +!.gitea/workflows/ +!.gitea/workflows/** diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ba5ba30 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM alpine:3.22.1 as zine +ARG ZINE_VERSION=v0.11.1 + +ARG TARGETARCH +RUN apk add --no-cache curl tar xz \ + && case "$TARGETARCH" in \ + amd64) Z_ARCH="x86_64-linux-musl";; \ + arm64) Z_ARCH="aarch64-linux-musl";; \ + *) echo "Unsupported TARGETARCH: $TARGETARCH" && exit 1;; \ + esac \ + && curl -L "https://github.com/kristoff-it/zine/releases/download/${ZINE_VERSION}/${Z_ARCH}.tar.xz" -o /tmp/zine.tar.xz \ + && tar -C /usr/local/bin -xJf /tmp/zine.tar.xz zine \ + && chmod +x /usr/local/bin/zine \ + && zine --version + +FROM alpine:3.22.1 as builder +COPY --from=zine /usr/local/bin/zine /usr/local/bin/zine +WORKDIR /site +COPY . . +RUN zine release + +FROM nginx:alpine3.22 AS runner +COPY --from=builder /site/public/ /usr/share/nginx/html/ +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"]