- Go 62.3%
- JavaScript 14.3%
- Go Template 14.2%
- SCSS 8.9%
- Dockerfile 0.3%
|
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
|
||
|---|---|---|
| .forgejo/workflows | ||
| assets | ||
| backend | ||
| public | ||
| website | ||
| .dockerignore | ||
| .env | ||
| .gitignore | ||
| Dockerfile | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| renovate.json | ||
| webpack.config.mjs | ||
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_URLmust 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, andDB_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
- Start services:
docker start website-mysql website-redis website-minio(or run thedocker runcommands above on first use). - Run
npm run watchin the repo root. - Run
go run ./cmd/website(orair) inbackend/. - 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 inassets/instead; for confirm prompts usedata-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