Override-based compose, profiles in .env, README

This commit is contained in:
hh
2026-09-09 00:18:15 +02:00
parent ecd38ee28b
commit e0d55e12e9
6 changed files with 39 additions and 27 deletions
+3 -1
View File
@@ -1,2 +1,4 @@
{% if layout == 'root' %}COMPOSE_FILE=docker-compose.yml:docker-compose.local.yml
{% if layout == 'root' %}COMPOSE_PROFILES=services
{% endif %}PUBLIC_API_BASE_URL=/api
ALLOWED_HOSTS=
+10 -13
View File
@@ -1,8 +1,6 @@
COMPOSE := docker compose{% if layout == 'part' %} --project-directory ..{% endif %}
{% if layout == 'root' %}SERVICES := $(COMPOSE) --profile services
EXTERNAL := $(COMPOSE) --profile external
{% endif %}
.PHONY: {% if layout == 'root' %}env external recreate rebuild restart logs down {% endif %}fmt check build dev
.PHONY: {% if layout == 'root' %}env recreate rebuild restart logs down {% endif %}fmt check build dev
fmt:
bun run fix
@@ -20,21 +18,20 @@ dev:
{% if layout == 'root' %}
env:
@test -f .env || cp .env.example .env
@test -f docker-compose.override.yml || cp docker-compose.override.yml.example docker-compose.override.yml
external:
$(EXTERNAL) up -d
recreate:
$(COMPOSE) up -d --force-recreate
recreate: external
$(SERVICES) up -d --force-recreate
rebuild: build recreate
rebuild: build
$(COMPOSE) up -d
restart:
$(SERVICES) restart
$(COMPOSE) restart
logs:
$(SERVICES) logs -f --tail=100
$(COMPOSE) logs -f --tail=100
down:
$(EXTERNAL) --profile services down
$(COMPOSE) down
{% endif %}
@@ -1,8 +0,0 @@
services:
{% if serve != 'api' %} frontend:
ports:
- "127.0.0.1:3000:3000"
{% endif %} frontend-dev:
ports:
- "127.0.0.1:3000:3000"
@@ -1,8 +1,15 @@
{%- set dash = project_slug | replace('_', '-') -%}
{% if serve != 'api' -%}
services:
frontend:
{% if serve != 'api' %} frontend:
networks:
default: {}
caddy:
aliases:
- {{ dash }}-frontend
{% endif %} frontend-dev:
networks:
default: {}
caddy:
aliases:
- {{ dash }}-frontend
@@ -10,6 +17,3 @@ services:
networks:
caddy:
external: true
{%- else -%}
services: {}
{%- endif %}
+5
View File
@@ -2,9 +2,14 @@ import { sveltekit } from "@sveltejs/kit/vite";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
const allowedHosts = process.env.ALLOWED_HOSTS
? process.env.ALLOWED_HOSTS.split(",")
: undefined;
export default defineConfig({
plugins: [tailwindcss(), sveltekit()],
server: {
allowedHosts,
proxy: {
"/api": {
changeOrigin: true,
@@ -0,0 +1,12 @@
# {{ project_name }}
Runs in Docker, locally the same way as in production. `COMPOSE_PROFILES` in `.env` selects the services that run on this machine. `docker-compose.override.yml` holds what differs between machines: published ports and the aliases on the external `caddy` network.
```sh
make env
make recreate
```
`make env` creates `.env` and `docker-compose.override.yml` from their examples. `make recreate` starts the selected profiles, `make rebuild` builds the image first, `make logs`, `make restart` and `make down` do what they say.
`make dev` runs the Vite dev server on the host, `make fmt` formats, `make check` runs svelte-check and the linter.