build and push container with forgejo actions
This commit is contained in:
parent
8c7fb8c6bf
commit
91368f5c8e
6 changed files with 65 additions and 34 deletions
39
.forgejo/workflows/build-and-push-containers.yaml
Normal file
39
.forgejo/workflows/build-and-push-containers.yaml
Normal file
|
|
@ -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
|
||||||
|
|
@ -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
|
|
||||||
24
README.md
24
README.md
|
|
@ -19,4 +19,26 @@
|
||||||
|
|
||||||
- Tailwind CSS
|
- 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
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ services:
|
||||||
- ./db:/var/lib/postgresql/data
|
- ./db:/var/lib/postgresql/data
|
||||||
backend:
|
backend:
|
||||||
container_name: recipes_backend_dev
|
container_name: recipes_backend_dev
|
||||||
image: recipes_backend
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
build:
|
build:
|
||||||
context: ./backend
|
context: ./backend
|
||||||
|
|
@ -32,7 +31,6 @@ services:
|
||||||
- DATABASE_URL=${DATABASE_URL}
|
- DATABASE_URL=${DATABASE_URL}
|
||||||
frontend:
|
frontend:
|
||||||
container_name: recipes_frontend_dev
|
container_name: recipes_frontend_dev
|
||||||
image: recipes_frontend
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=dev
|
- NODE_ENV=dev
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ services:
|
||||||
- ./db:/var/lib/postgresql/data
|
- ./db:/var/lib/postgresql/data
|
||||||
backend:
|
backend:
|
||||||
container_name: recipes_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
|
restart: unless-stopped
|
||||||
build:
|
build:
|
||||||
context: ./backend
|
context: ./backend
|
||||||
|
|
@ -26,7 +26,7 @@ services:
|
||||||
- DATABASE_URL=${DATABASE_URL}
|
- DATABASE_URL=${DATABASE_URL}
|
||||||
frontend:
|
frontend:
|
||||||
container_name: recipes_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
|
restart: unless-stopped
|
||||||
build:
|
build:
|
||||||
context: ./frontend
|
context: ./frontend
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
DB_PORT=5432
|
|
||||||
DB_USER=recipe_app
|
DB_USER=recipe_app
|
||||||
DB_PASSWORD=password
|
DB_PASSWORD=password
|
||||||
DB_NAME=recipe_app
|
DB_NAME=recipe_app
|
||||||
BACKEND_PORT=3000
|
|
||||||
FRONTEND_PORT=8080
|
FRONTEND_PORT=8080
|
||||||
DATABASE_URL='postgres://recipe_app:password@db:5432/'
|
DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@db:5432/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue