Drop the container pipeline: the servers serve the flake
All checks were successful
CI / check (push) Successful in 7s

asxpio-services serves the site from this flake (services.blog), and
Traefik no longer routes to the container. The Dockerfile, nginx.conf,
docker-compose.yml and the Kaniko and deploy jobs go; CI builds the
package on every push, main included.

Assisted-by: Claude:opus-5-5
This commit is contained in:
Sergei Poljanski 2026-11-17 13:12:54 +04:00
commit 5ff625feaa
Signed by: asxpi
GPG key ID: 4F8851660FA4121B
6 changed files with 5 additions and 176 deletions

View file

@ -1,9 +1,11 @@
name: Test
name: CI
# Every push builds the site as the servers will (the flake's package).
# Deploying is not this repository's job: Renovate in asxpi/iac picks up
# each push to main and the servers pull it (comin).
on:
push:
branches-ignore:
- main
jobs:
check:

View file

@ -1,111 +0,0 @@
name: Build and Deploy to Production
on:
push:
branches:
- main
jobs:
# Same job as in test.yaml (non-main branches); duplicated so a broken
# build blocks deploy — Forgejo has no cross-workflow needs.
check:
runs-on: nix-latest
# Settings via env, not /etc/nix/nix.conf: in the image that is a
# symlink into /nix/store, which the runner's nix-store volume
# shadows, so it dangles once the image moves on.
env:
NIX_CONFIG: |
experimental-features = nix-command flakes
build-users-group =
sandbox = false
steps:
- name: Prepare container for actions
run: |
nix-env -iA nixpkgs.nodejs_22
- name: Checkout
uses: actions/checkout@v7.0.1
- name: Build site (the package nginx serves)
run: nix build .#default
build:
runs-on: arch-latest
needs: check
container:
image: gcr.io/kaniko-project/executor:v1.24.0-debug
outputs:
image_tag: ${{ steps.build_image.outputs.image_tag }}
steps:
- name: Build and push Docker Image using Kaniko
id: build_image
run: |
# Tags
SHORT_SHA=${GITHUB_SHA::8}
IMAGE_BASE=git.czsk.it/asxpi/blog
IMAGE_TAG=${IMAGE_BASE}:${SHORT_SHA}
IMAGE_LATEST=${IMAGE_BASE}:latest
# Auth Conf
mkdir -p /kaniko/.docker
echo "{\"auths\":{\"git.czsk.it\":{\"auth\":\"$(echo -n asxpi:${{ secrets.FJ_TOKEN }} | base64)\"}}}" > /kaniko/.docker/config.json
# Build & push
/kaniko/executor \
--context=git://git.czsk.it/${{ github.repository }}.git \
--git=branch=${{ github.ref_name }} \
--destination=$IMAGE_TAG \
--destination=$IMAGE_LATEST
# Output the specific tag for deployment
echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT
deploy:
runs-on: arch-latest
needs: build
steps:
- name: Install dependencies
run: |
pacman -Syu --noconfirm nodejs openssh rsync
- name: Checkout code
uses: actions/checkout@v7.0.1
- name: Deploy docker-compose.yml
uses: easingthemes/ssh-deploy@v6.0.3
with:
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
REMOTE_HOST: ${{ secrets.DEPLOY_IP }}
REMOTE_USER: ${{ secrets.DEPLOY_USER }}
SOURCE: "docker-compose.yml"
TARGET: "/opt/blog/"
- name: Deploy and update container
uses: appleboy/ssh-action@v1.2.5
env:
NEW_IMAGE: ${{ needs.build.outputs.image_tag }}
with:
host: ${{ secrets.DEPLOY_IP }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
envs: NEW_IMAGE
script: |
cd /opt/blog
sed -i "s|image:.*|image: $NEW_IMAGE|" docker-compose.yml
docker pull $NEW_IMAGE
docker compose up -d
# Wait for the image HEALTHCHECK to report healthy.
for i in $(seq 1 18); do
status=$(docker inspect --format '{{.State.Health.Status}}' blog 2>/dev/null || echo missing)
if [ "$status" = "healthy" ]; then
echo "Deployment successful!"
exit 0
fi
sleep 5
done
echo "blog never became healthy (last status: $status)" >&2
docker logs --tail 50 blog
exit 1

View file

@ -7,8 +7,6 @@ servers take the site from this flake: a push to `main` is picked up by
Renovate in asxpi/iac (flake input `blog`) within about 15 minutes and
deployed by comin, no deploy job here.
The old container pipeline (Kaniko image, compose deploy to `/opt/blog`)
still runs until it is removed; nothing serves from it.
## Writing a post

View file

@ -1,16 +0,0 @@
# Keep in step with the zola in flake.nix (tests, local serve): bump this
# pin together with nixpkgs in flake.lock.
FROM ghcr.io/getzola/zola:v0.23.6 AS build
COPY . /project
WORKDIR /project
# zola is /zola in the image since 0.23, not on PATH
RUN ["/zola", "build"]
FROM nginx:1.31.8-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /project/public /usr/share/nginx/html
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD wget -qO /dev/null http://127.0.0.1/ || exit 1

View file

@ -1,29 +0,0 @@
services:
blog:
# Image will be dynamically updated during deployment
# Format: registry.example.com/user/blog:sha_tag
build: .
image: blog:latest
container_name: blog
# Same as the image HEALTHCHECK. Podman ignores HEALTHCHECK in OCI-format
# images (what kaniko pushes), and the deploy waits for "healthy".
healthcheck:
test: ["CMD-SHELL","wget -qO /dev/null http://127.0.0.1/ || exit 1"]
interval: 30s
timeout: 5s
start_period: 5s
retries: 3
restart: unless-stopped
networks:
- traefik
labels:
- "traefik.enable=true"
- "traefik.http.routers.blog.rule=Host(`blog.asxp.io`)"
- "traefik.http.routers.blog.entrypoints=websecure"
- "traefik.http.routers.blog.tls=true"
- "traefik.http.routers.blog.tls.certresolver=letsencrypt"
- "traefik.http.services.blog.loadbalancer.server.port=80"
networks:
traefik:
external: true

View file

@ -1,15 +0,0 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
error_page 404 /404.html;
location / {
try_files $uri $uri/ =404;
}
location ~* \.(css|png|svg|xml|ico)$ {
expires 1h;
}
}