No description
  • Go 62.3%
  • JavaScript 14.3%
  • Go Template 14.2%
  • SCSS 8.9%
  • Dockerfile 0.3%
Find a file
renovate_bot eb079c6f59
All checks were successful
CI / webpack (push) Successful in 43s
CI / go-test (push) Successful in 1m38s
CI / go-vet (push) Successful in 1m41s
CI / go-build (push) Successful in 1m52s
CI / bundle (push) Successful in 49s
CI / docker (push) Successful in 0s
CI / helm (push) Successful in 0s
CI / build (push) Successful in 38s
Merge pull request 'Update https://code.forgejo.org/forgejo/upload-artifact action to v5' (#2011) from renovate/https-code.forgejo.org-forgejo-upload-artifact-5.x into master
2026-11-18 13:41:41 +00:00
.forgejo/workflows Update https://code.forgejo.org/forgejo/upload-artifact action to v5 2026-11-18 13:21:24 +00:00
assets add missig security headers 2026-11-03 13:12:57 +01:00
backend Update module github.com/swaggo/files to v2 2026-11-18 13:21:53 +00:00
public replace symfony backend with go implementation 2026-02-22 14:44:10 +01:00
website implement gotify for comment notifications 2026-04-10 22:26:21 +02:00
.dockerignore replace symfony backend with go implementation 2026-02-22 14:44:10 +01:00
.env fix MINIO_SECRET_KEY typo 2023-09-07 21:47:28 +02:00
.gitignore add dev instructions 2026-03-22 21:03:00 +01:00
Dockerfile Update golang Docker tag to v1.27.4 2026-11-12 20:18:02 +00:00
package-lock.json Update dependency webpack-cli to v7 2026-11-18 13:20:43 +00:00
package.json Update dependency webpack-cli to v7 2026-11-18 13:20:43 +00:00
README.md add missig security headers 2026-11-03 13:12:57 +01:00
renovate.json automerge PRs 2026-09-25 08:14:42 +02:00
webpack.config.mjs dependency major updates 2026-08-12 13:40:38 +02:00

Website-Symfony

This repository serves a website with a Go backend and a Webpack Encore frontend asset pipeline. Despite the name, the runtime application is not a Symfony PHP app anymore.

Stack

  • Go backend in backend/
  • Gin for HTTP routing
  • GORM with MySQL
  • Redis for template and image cache support
  • S3-compatible object storage for images and skill assets
  • Webpack Encore for frontend bundles in public/build/

Prerequisites

  • Go 1.25+
  • Node.js 24+
  • npm
  • MySQL
  • Redis
  • An S3-compatible bucket such as MinIO

Install dependencies

Frontend:

npm ci

Backend:

cd backend
go mod download

Environment

The backend loads environment variables from the repo root .env file automatically.

The committed .env still contains old Symfony comments and an example PostgreSQL DATABASE_URL. The current Go application expects MySQL. Use .env.local or edit .env for local development.

Minimum local setup:

APP_ENV=dev
APP_SECRET=change-me
LISTEN_ADDR=:8080
COOKIE_SECURE=false

DATABASE_URL=mysql://user:password@127.0.0.1:3306/website?charset=utf8mb4

REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_DB=0

MINIO_URL=127.0.0.1:9000
MINIO_BUCKET=website
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin
MINIO_REGION=de-dus

IMGPROXY_KEY=
IMGPROXY_SALT=

GOTIFY_URL=http://127.0.0.1:8070
GOTIFY_TOKEN=

Notes:

  • DATABASE_URL must be MySQL-formatted. PostgreSQL URLs are not supported by the current backend.
  • If you prefer discrete database variables, use DB_NAME, DB_USER, DB_PASSWORD, DB_HOST, and DB_PORT.
  • MINIO_* values are required because the app initializes the S3 client during startup.
  • Redis is optional at runtime in the sense that the app can keep serving if Redis is unavailable, but it still tries to connect on boot.

Running in development

The production Dockerfile is not intended for development — every code change would require a full image rebuild. Instead, run the required services in Docker containers and the app natively on your machine.

1. Start backing services with Docker

docker run -d --name website-mysql \
  -e MYSQL_ROOT_PASSWORD=root \
  -e MYSQL_DATABASE=website \
  -e MYSQL_USER=website \
  -e MYSQL_PASSWORD=website \
  -p 3306:3306 \
  mysql:8

docker run -d --name website-redis \
  -p 6379:6379 \
  redis:7-alpine

docker run -d --name website-minio \
  -e MINIO_ROOT_USER=minioadmin \
  -e MINIO_ROOT_PASSWORD=minioadmin \
  -p 9000:9000 -p 9001:9001 \
  minio/minio server /data --console-address ":9001"

Create the website bucket via the MinIO Console at http://localhost:9001 (login: minioadmin / minioadmin).

To stop and remove the containers later:

docker rm -f website-mysql website-redis website-minio

2. Fix the asset path for local development

The Go backend runs from the backend/ directory and expects frontend assets at backend/public/build/, but webpack outputs to public/build/ in the repo root. A symlink bridges the two:

ln -s ../public backend/public

This only needs to be done once.

3. Configure the environment

Create a .env file in the repo root (or .env.local to avoid touching .env):

APP_ENV=dev
APP_SECRET=change-me
LISTEN_ADDR=:8080
COOKIE_SECURE=false
TEMPLATE_CACHE_ENABLED=false

DATABASE_URL=mysql://website:website@127.0.0.1:3306/website?charset=utf8mb4

REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_DB=0

MINIO_URL=127.0.0.1:9000
MINIO_BUCKET=website
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin
MINIO_REGION=de-dus

Setting TEMPLATE_CACHE_ENABLED=false disables Redis-backed template caching so you see template changes after a backend restart without stale cache entries.

4. Run the app

In one terminal, keep webpack rebuilding frontend assets on change:

npm run watch

In another terminal, start the Go backend:

cd backend
go run ./cmd/website

The app listens on http://localhost:8080 by default. Restart go run whenever you change Go source files or Go templates (backend/templates-go/). Frontend asset changes are picked up automatically via the webpack watcher without restarting the backend.

Hot reload for the Go backend (optional)

Air watches Go source files and restarts the backend automatically:

go install github.com/air-verse/air@latest
cd backend
air -c /dev/null -- ./cmd/website

Typical dev workflow

  1. Start services: docker start website-mysql website-redis website-minio (or run the docker run commands above on first use).
  2. Run npm run watch in the repo root.
  3. Run go run ./cmd/website (or air) in backend/.
  4. Open http://localhost:8080.

Production-style build

Frontend:

npm run build

Backend:

cd backend
go build ./cmd/website

Docker image

The root Dockerfile builds:

  • frontend assets with Node
  • Swagger docs and the backend binary with Go
  • a final minimal runtime image exposing port 8080

Build locally:

docker build -t website-symfony .

Security headers

Every response carries Content-Security-Policy, X-Frame-Options, X-Content-Type-Options, Referrer-Policy and Permissions-Policy. Strict-Transport-Security is added when APP_ENV=prod. They are set by backend/internal/middleware/security_headers.go.

The CSP is strict about scripts: script-src 'self', no 'unsafe-inline', no 'unsafe-eval'. That has two consequences when you change the frontend:

  • Do not add inline <script> blocks or inline event handlers (onclick=, onsubmit=, ...) to templates. Put the code in assets/ instead; for confirm prompts use data-confirm="..." on a <form>. go test ./... fails if one is reintroduced.
  • Loading something from a new external origin (an image host, an API, an embed) is blocked until you add that origin to the matching directive in buildCSP. The browser console names the blocked directive.

The S3/MinIO origin is derived from MINIO_URL automatically. HSTS is max-age=31536000 only; includeSubDomains and preload are intentionally not set.

Useful commands

Run backend tests:

cd backend
go test ./...

Rebuild frontend assets for production:

npm run build