From 44023d8ad2b3e82708539fd2f1f30a8081c2ee7f Mon Sep 17 00:00:00 2001 From: myrmidex Date: Sun, 10 May 2026 02:30:08 +0200 Subject: [PATCH] Add CI/build workflows, Dockerfile, nginx config, update README --- .forgejo/workflows/build.yml | 26 ++++++++++++++++++++++++-- .forgejo/workflows/ci.yml | 29 +++++++++++++++++++++++++++++ README.md | 14 +++++++++----- docker/Dockerfile | 16 ++++++++++++++++ docker/nginx.conf | 15 +++++++++++++++ 5 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 .forgejo/workflows/ci.yml create mode 100644 docker/Dockerfile create mode 100644 docker/nginx.conf diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index e4b6ca1..256b90f 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -1,13 +1,25 @@ name: Build and Push Docker Image + on: push: branches: [main] + paths: + - 'content/**' + - 'static/**' + - 'templates/**' + - 'themes/**' + - 'config.toml' + - 'docker/Dockerfile' + - 'docker/nginx.conf' + - '.forgejo/workflows/build.yml' + tags: ['v*'] jobs: build: runs-on: docker container: image: catthehacker/ubuntu:act-latest + steps: - uses: https://data.forgejo.org/actions/checkout@v4 with: @@ -26,11 +38,21 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.REGISTRY_TOKEN }} + - name: Determine tags + id: meta + run: | + if [[ "${{ github.ref }}" == refs/tags/v* ]]; then + TAG="${{ github.ref_name }}" + echo "tags=forge.lvl0.xyz/lvl0/lvl0-website:${TAG},forge.lvl0.xyz/lvl0/lvl0-website:latest" >> $GITHUB_OUTPUT + else + echo "tags=forge.lvl0.xyz/lvl0/lvl0-website:latest" >> $GITHUB_OUTPUT + fi + - name: Build and push uses: https://data.forgejo.org/docker/build-push-action@v5 with: context: . - file: .docker/Dockerfile + file: docker/Dockerfile platforms: linux/amd64,linux/arm64 push: true - tags: forge.lvl0.xyz/lvl0/lvl0-website:latest + tags: ${{ steps.meta.outputs.tags }} diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml new file mode 100644 index 0000000..032da96 --- /dev/null +++ b/.forgejo/workflows/ci.yml @@ -0,0 +1,29 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: docker + container: + image: catthehacker/ubuntu:act-latest + + steps: + - uses: https://data.forgejo.org/actions/checkout@v4 + with: + submodules: true + + - name: Install Zola + run: | + curl -sL https://github.com/getzola/zola/releases/download/v0.21.0/zola-v0.21.0-x86_64-unknown-linux-gnu.tar.gz \ + | tar xz -C /usr/local/bin + + - name: Build + run: zola build + + - name: Check links + run: zola check --skip-external-links diff --git a/README.md b/README.md index ce5acc0..34a9145 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ ## Production -This is the docker-compose file needed to host this webiste: +Pull and run the image with Docker Compose: -``` +```yaml services: website: image: forge.lvl0.xyz/lvl0/lvl0-website:latest @@ -12,13 +12,17 @@ services: ports: - 5002:80 restart: unless-stopped -networks: {} ``` +The image is built and pushed automatically on every push to `main`. + ## Development -Run zola: +Enter the nix-shell, then start the dev server: ```sh -zola serve +nix-shell +dev-up ``` + +Site will be available at `http://localhost:1111` with live reload. diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..c38e6eb --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,16 @@ +FROM catthehacker/ubuntu:act-latest AS builder +ARG TARGETARCH +WORKDIR /site +RUN case "$TARGETARCH" in \ + amd64) ARCH="x86_64-unknown-linux-gnu" ;; \ + arm64) ARCH="aarch64-unknown-linux-gnu" ;; \ + *) echo "Unsupported architecture: $TARGETARCH" && exit 1 ;; \ + esac && \ + curl -sL "https://github.com/getzola/zola/releases/download/v0.21.0/zola-v0.21.0-${ARCH}.tar.gz" \ + | tar xz -C /usr/local/bin +COPY . . +RUN zola build + +FROM nginx:alpine +COPY --from=builder /site/public /usr/share/nginx/html +COPY docker/nginx.conf /etc/nginx/conf.d/default.conf diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000..64e135a --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,15 @@ +server { + listen 80; + server_name lvl0.xyz; + + location / { + root /usr/share/nginx/html; + index index.html; + try_files $uri $uri/ =404; + } + + location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } +}