All checks were successful
Publish Container / publish (push) Successful in 3m18s
88 lines
2.8 KiB
Markdown
88 lines
2.8 KiB
Markdown
# maddoscientisto.net
|
|
|
|
Blazor WebAssembly (.NET 10) static site packaged as an Nginx container and publishable to a Forgejo container registry.
|
|
|
|
## Project layout
|
|
|
|
- `src/MaddoScientisto.Web` - Blazor WebAssembly app
|
|
- `Dockerfile` - multi-stage build and Nginx runtime image
|
|
- `nginx.conf` - static hosting and SPA fallback
|
|
- `.forgejo/workflows/publish-container.yml` - Forgejo Actions workflow for build and push
|
|
|
|
## Local development
|
|
|
|
```powershell
|
|
dotnet restore
|
|
dotnet build src/MaddoScientisto.Web/MaddoScientisto.Web.csproj -c Release
|
|
dotnet run --project src/MaddoScientisto.Web/MaddoScientisto.Web.csproj
|
|
```
|
|
|
|
## Local publish check
|
|
|
|
```powershell
|
|
dotnet publish src/MaddoScientisto.Web/MaddoScientisto.Web.csproj -c Release -o .\artifacts\publish
|
|
```
|
|
|
|
Published static files are under `.\artifacts\publish\wwwroot`.
|
|
|
|
## Docker build and run
|
|
|
|
```powershell
|
|
docker build -t maddoscientisto-web:local .
|
|
docker run --rm -p 8080:80 maddoscientisto-web:local
|
|
```
|
|
|
|
Open `http://localhost:8080`.
|
|
|
|
## Docker Compose deployment
|
|
|
|
A ready-to-use `docker-compose.yml` is included to build and run the site container. By default it maps container port `80` to host port `8002`.
|
|
|
|
Start the service (builds the image if needed) with:
|
|
|
|
```bash
|
|
docker compose up --build -d
|
|
```
|
|
|
|
Verify the site at:
|
|
|
|
```bash
|
|
curl http://localhost:8002/
|
|
```
|
|
|
|
To stop and remove the service:
|
|
|
|
```bash
|
|
docker compose down
|
|
```
|
|
|
|
You can customize the built image name and tag via environment variables read by Compose (`IMAGE_REGISTRY` and `IMAGE_TAG`), or edit `docker-compose.yml` to change the published host port.
|
|
|
|
## Forgejo registry configuration
|
|
|
|
Set these Forgejo Actions variables:
|
|
|
|
- `FORGEJO_REGISTRY` (example: `forgejo.example.com`)
|
|
- `IMAGE_NAMESPACE` (example: `maddo`)
|
|
- `IMAGE_NAME` (example: `maddoscientisto-web`)
|
|
- Optional: `DOCKER_HOST` (example: `tcp://forgejo-docker-in-docker:2375`)
|
|
|
|
Set these Forgejo Actions secrets:
|
|
|
|
- `FORGEJO_REGISTRY_USERNAME`
|
|
- `FORGEJO_REGISTRY_TOKEN`
|
|
|
|
## Workflow behavior
|
|
|
|
The workflow in `.forgejo/workflows/publish-container.yml` runs on pushes to `master` (and manual dispatch), bootstraps Docker Buildx if needed, then builds and pushes the container image with BuildKit:
|
|
|
|
- `${FORGEJO_REGISTRY}/${IMAGE_NAMESPACE}/${IMAGE_NAME}:latest`
|
|
- `${FORGEJO_REGISTRY}/${IMAGE_NAMESPACE}/${IMAGE_NAME}:sha-<12-char-commit>`
|
|
|
|
## Forgejo runner notes (Docker-in-Docker)
|
|
|
|
If the runner image does not contain the `docker` binary, the workflow bootstraps a Docker CLI in user space before login/build/push.
|
|
|
|
If the runner image does not contain the Buildx plugin, the workflow also installs `docker-buildx` in the Docker CLI plugin directory before creating a builder.
|
|
|
|
For your current dind-based runner, the workflow defaults `DOCKER_HOST` to `tcp://172.17.0.1:2375` unless you set `vars.DOCKER_HOST` explicitly.
|