From 91368f5c8e049f90008c9b231f2beba28f1a100d Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 28 Jan 2026 14:24:52 -0800 Subject: [PATCH] build and push container with forgejo actions --- .../workflows/build-and-push-containers.yaml | 39 +++++++++++++++++++ .forgejo/workflows/ci.yml | 26 ------------- README.md | 24 +++++++++++- docker-compose.dev.yaml | 2 - docker-compose.yaml | 4 +- example.env | 4 +- 6 files changed, 65 insertions(+), 34 deletions(-) create mode 100644 .forgejo/workflows/build-and-push-containers.yaml delete mode 100644 .forgejo/workflows/ci.yml diff --git a/.forgejo/workflows/build-and-push-containers.yaml b/.forgejo/workflows/build-and-push-containers.yaml new file mode 100644 index 0000000..8f9f52b --- /dev/null +++ b/.forgejo/workflows/build-and-push-containers.yaml @@ -0,0 +1,39 @@ +on: + push: + branches: + - main +jobs: + build: + runs-on: ubuntu-latest + container: + image: node:22-bullseye + + steps: + - name: Install Docker + run: | + curl -fsSL https://get.docker.com -o get-docker.sh + sh get-docker.sh + + - name: checkout + uses: actions/checkout@v4 + + - name: Login to forgejo + uses: docker/login-action@v3 + with: + registry: forgejo.fredzernia.com + username: ${{ github.actor }} + password: ${{ secrets.PACKAGE_TOKEN }} + + - name: build and push backend + uses: docker/build-push-action@v6 + with: + context: backend/. + push: true + tags: forgejo.fredzernia.com/${{ env.FORGEJO_REPOSITORY }}_backend:latest + + - name: build and push frontend + uses: docker/build-push-action@v6 + with: + context: frontend/. + push: true + tags: forgejo.fredzernia.com/${{ env.FORGEJO_REPOSITORY }}_frontend:latest diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml deleted file mode 100644 index d39bc96..0000000 --- a/.forgejo/workflows/ci.yml +++ /dev/null @@ -1,26 +0,0 @@ -on: - push: - branches: - - main -jobs: - build: - runs-on: ubuntu-latest - env: - NODE_ENV: dev - container: - image: node:22-bullseye - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Build Frontend - working-directory: frontend - run: | - npm ci - npm run ci - - - name: Build Backend - working-directory: backend - run: | - npm ci - npm run ci diff --git a/README.md b/README.md index 8d59f82..2f68d90 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,26 @@ - Tailwind CSS -I have a production build of the app hosted in docker served with caddy on a vps running nixos that you can access here: https://recipe-app.fredzernia.com +#### Infra/CI: + +This Forgejo instance is hosted on a VPS running NixOS. +The Forgejo Runner is hosted in a LXC container running on a local nix server +The runner builds the containers and pushes them to this Forgejo registry +In the frontend container I bundle the compiled src with Caddy to run as a standalone app. The exposed frontend port can then be served via reverse proxy. + +#### Try it out: + +https://recipe-app.fredzernia.com + +#### Run it yourself: + +``` +mkdir recipe_app && cd recipe_app +wget https://forgejo.fredzernia.com/fred/recipe_app/raw/branch/main/docker-compose.yaml +wget https://forgejo.fredzernia.com/fred/recipe_app/raw/branch/main/example.env +mv example.env .env # Change these values if you want +docker compose pull +docker compose up db -d +docker compose run backend npx prisma migrate deploy +docker compose up -d +``` diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index 2fc6742..3660fd3 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -15,7 +15,6 @@ services: - ./db:/var/lib/postgresql/data backend: container_name: recipes_backend_dev - image: recipes_backend restart: unless-stopped build: context: ./backend @@ -32,7 +31,6 @@ services: - DATABASE_URL=${DATABASE_URL} frontend: container_name: recipes_frontend_dev - image: recipes_frontend restart: unless-stopped environment: - NODE_ENV=dev diff --git a/docker-compose.yaml b/docker-compose.yaml index 96d0564..7b6aff5 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -13,7 +13,7 @@ services: - ./db:/var/lib/postgresql/data backend: container_name: recipes_backend - image: forgejo.fredzernia.com/fred/recipes_backend:latest + image: forgejo.fredzernia.com/fred/recipe_app_backend:latest restart: unless-stopped build: context: ./backend @@ -26,7 +26,7 @@ services: - DATABASE_URL=${DATABASE_URL} frontend: container_name: recipes_frontend - image: forgejo.fredzernia.com/fred/recipes_frontend:latest + image: forgejo.fredzernia.com/fred/recipe_app_frontend:latest restart: unless-stopped build: context: ./frontend diff --git a/example.env b/example.env index 092cc7e..0df3045 100644 --- a/example.env +++ b/example.env @@ -1,7 +1,5 @@ -DB_PORT=5432 DB_USER=recipe_app DB_PASSWORD=password DB_NAME=recipe_app -BACKEND_PORT=3000 FRONTEND_PORT=8080 -DATABASE_URL='postgres://recipe_app:password@db:5432/' +DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@db:5432/