feat: add pre-built docker images
This commit is contained in:
parent
978b8e100e
commit
3527acb8ba
3 changed files with 76 additions and 4 deletions
27
DOCKER.md
27
DOCKER.md
|
@ -1,10 +1,29 @@
|
|||
# Running with Docker
|
||||
# Running with Docker (pre-built backend and rate limiter) *(linux/arm64 only)*
|
||||
|
||||
Because SvelteKit is a pain in the ass to build in a container, and processes secrets at build time,
|
||||
there is no pre-built frontend image available.
|
||||
If you don't want to build images on your server, I recommend running the frontend outside of Docker.
|
||||
This is preconfigured in `docker-compose.prebuilt.yml`: the backend, database, and rate limiter will run in Docker,
|
||||
while the frontend is run as a normal, non-containerized service.
|
||||
|
||||
1. Copy `docker/config.example.ini` to `docker/config.ini`, and change the settings to your liking.
|
||||
2. Copy `docker/proxy-config.example.json` to `docker/proxy-config.json`, and do the same.
|
||||
3. Copy `docker/frontend.example.env` to `docker/frontend.env`, and do the same.
|
||||
4. Build with `docker compose build`
|
||||
5. Run with `docker compose up`
|
||||
3. Run with `docker compose up -f docker-compose.prebuilt.yml`
|
||||
|
||||
The backend will listen on port 5001 and metrics will be available on port 5002.
|
||||
The rate limiter (which is what should be exposed to the outside) will listen on port 5003.
|
||||
You can use `docker/Caddyfile` as an example for your reverse proxy. If you use nginx, good luck.
|
||||
|
||||
# Running with Docker (local builds)
|
||||
|
||||
In order to run *everything* in Docker, you'll have to build every container yourself.
|
||||
The advantage of this is that it's an all-in-one solution, where you only have to point your reverse proxy at a single container.
|
||||
The disadvantage is that you'll likely have to build the images on the server you'll be running them on.
|
||||
|
||||
1. Configure the backend and rate limiter as in the section above.
|
||||
2. Copy `docker/frontend.example.env` to `docker/frontend.env`, and configure it.
|
||||
3. Build with `docker compose build -f docker-compose.local.yml`
|
||||
4. Run with `docker compose up -f docker-compose.local.yml`
|
||||
|
||||
The Caddy server will listen on `localhost:5004` for the frontend and API,
|
||||
and on `localhost:5005` for the profile URL shortener.
|
||||
|
|
53
docker-compose.prebuilt.yml
Normal file
53
docker-compose.prebuilt.yml
Normal file
|
@ -0,0 +1,53 @@
|
|||
services:
|
||||
backend:
|
||||
image: code.vulpine.solutions/sam/foxnouns-be:latest
|
||||
environment:
|
||||
- "Database:Url=Host=postgres;Database=postgres;Username=postgres;Password=postgres"
|
||||
- "Database:EnablePooling=true"
|
||||
- "Database:Redis=redis:6379"
|
||||
- "Host=0.0.0.0"
|
||||
- "Port=5000"
|
||||
- "Logging:MetricsPort=5001"
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "5001:5000"
|
||||
- "5002:5001"
|
||||
volumes:
|
||||
- ./docker/config.ini:/app/config.ini
|
||||
- ./docker/static-pages:/app/static-pages
|
||||
|
||||
rate:
|
||||
image: code.vulpine.solutions/sam/foxnouns-rate:latest
|
||||
environment:
|
||||
- "PORT=5003"
|
||||
ports:
|
||||
- "5003:5003"
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./docker/proxy-config.json:/app/proxy-config.json
|
||||
|
||||
postgres:
|
||||
image: docker.io/postgres:16
|
||||
command: [ "postgres",
|
||||
"-c", "max-connections=1000",
|
||||
"-c", "timezone=Etc/UTC",
|
||||
"-c", "max_wal_size=1GB",
|
||||
"-c", "min_wal_size=80MB",
|
||||
"-c", "shared_buffers=128MB" ]
|
||||
environment:
|
||||
- "POSTGRES_PASSWORD=postgres"
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
|
||||
redis:
|
||||
image: registry.redict.io/redict:7
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- redict_data:/data
|
||||
|
||||
volumes:
|
||||
caddy_data:
|
||||
caddy_config:
|
||||
postgres_data:
|
||||
redict_data:
|
Loading…
Add table
Reference in a new issue