feat: docker config for new frontend
This commit is contained in:
parent
c6eba5b51a
commit
bb2fa55cd5
9 changed files with 54 additions and 23 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -6,3 +6,7 @@ config.ini
|
||||||
*.DotSettings.user
|
*.DotSettings.user
|
||||||
proxy-config.json
|
proxy-config.json
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
docker/config.ini
|
||||||
|
docker/proxy-config.json
|
||||||
|
docker/frontend.env
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
1. Copy `docker/config.example.ini` to `docker/config.ini`, and change the settings to your liking.
|
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.
|
2. Copy `docker/proxy-config.example.json` to `docker/proxy-config.json`, and do the same.
|
||||||
3. Build with `docker compose build`
|
3. Copy `docker/frontend.example.env` to `docker/frontend.env`, and do th esame.
|
||||||
4. Run with `docker compose up`
|
4. Build with `docker compose build`
|
||||||
|
5. Run with `docker compose up`
|
||||||
|
|
||||||
The Caddy server will listen on `localhost:5004`.
|
The Caddy server will listen on `localhost:5004` for the frontend and API,
|
||||||
|
and on `localhost:5005` for the profile URL shortener.
|
||||||
|
|
4
Foxnouns.Frontend/.dockerignore
Normal file
4
Foxnouns.Frontend/.dockerignore
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
node_modules/
|
||||||
|
build/
|
||||||
|
.env
|
||||||
|
.env*
|
17
Foxnouns.Frontend/Dockerfile
Normal file
17
Foxnouns.Frontend/Dockerfile
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
FROM docker.io/node:22-slim
|
||||||
|
|
||||||
|
ENV PNPM_HOME="/pnpm"
|
||||||
|
ENV PATH="$PNPM_HOME:$PATH"
|
||||||
|
RUN corepack enable
|
||||||
|
|
||||||
|
COPY ./Foxnouns.Frontend /app
|
||||||
|
COPY ./docker/frontend.env /app/.env.local
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV PRIVATE_API_HOST=http://rate:5003/api
|
||||||
|
ENV PRIVATE_INTERNAL_API_HOST=http://backend:5000/api
|
||||||
|
|
||||||
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
|
||||||
|
RUN pnpm run build
|
||||||
|
|
||||||
|
CMD ["pnpm", "node", "build/index.js"]
|
|
@ -3,6 +3,7 @@ import { PUBLIC_API_BASE } from "$env/static/public";
|
||||||
import type { HandleFetch } from "@sveltejs/kit";
|
import type { HandleFetch } from "@sveltejs/kit";
|
||||||
|
|
||||||
export const handleFetch: HandleFetch = async ({ request, fetch }) => {
|
export const handleFetch: HandleFetch = async ({ request, fetch }) => {
|
||||||
|
console.log(PUBLIC_API_BASE, PRIVATE_INTERNAL_API_HOST, PRIVATE_API_HOST);
|
||||||
if (request.url.startsWith(`${PUBLIC_API_BASE}/internal`)) {
|
if (request.url.startsWith(`${PUBLIC_API_BASE}/internal`)) {
|
||||||
request = new Request(request.url.replace(PUBLIC_API_BASE, PRIVATE_INTERNAL_API_HOST), request);
|
request = new Request(request.url.replace(PUBLIC_API_BASE, PRIVATE_INTERNAL_API_HOST), request);
|
||||||
} else if (request.url.startsWith(PUBLIC_API_BASE)) {
|
} else if (request.url.startsWith(PUBLIC_API_BASE)) {
|
||||||
|
|
|
@ -5,8 +5,8 @@ services:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./Dockerfile.backend
|
dockerfile: ./Dockerfile.backend
|
||||||
environment:
|
environment:
|
||||||
- "Database:Url=Host=pgbouncer;Database=postgres;Username=postgres;Password=postgres"
|
- "Database:Url=Host=postgres;Database=postgres;Username=postgres;Password=postgres"
|
||||||
- "Database:EnablePooling=false"
|
- "Database:EnablePooling=true"
|
||||||
- "Host=0.0.0.0"
|
- "Host=0.0.0.0"
|
||||||
- "Port=5000"
|
- "Port=5000"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
@ -15,13 +15,14 @@ services:
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
image: frontend
|
image: frontend
|
||||||
build: ./Foxnouns.Frontend
|
build:
|
||||||
environment:
|
context: ./
|
||||||
- "API_BASE=http://rate:5003/api"
|
dockerfile: ./Foxnouns.Frontend/Dockerfile
|
||||||
- "INTERNAL_API_BASE=http://backend:5000/api"
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
env_file: ./docker/frontend.env
|
||||||
- ./docker/frontend.env:/app/.env
|
environment:
|
||||||
|
- "PRIVATE_API_HOST=http://rate:5003/api"
|
||||||
|
- "PRIVATE_INTERNAL_API_HOST=http://backend:5000/api"
|
||||||
|
|
||||||
rate:
|
rate:
|
||||||
image: rate
|
image: rate
|
||||||
|
@ -32,16 +33,6 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- ./docker/proxy-config.json:/app/proxy-config.json
|
- ./docker/proxy-config.json:/app/proxy-config.json
|
||||||
|
|
||||||
pgbouncer:
|
|
||||||
image: docker.io/edoburu/pgbouncer:latest
|
|
||||||
environment:
|
|
||||||
- "DATABASE_URL=postgres://postgres:postgres@postgres/postgres"
|
|
||||||
- "AUTH_TYPE=scram-sha-256"
|
|
||||||
- "MAX_CLIENT_CONN=100"
|
|
||||||
- "DEFAULT_POOL_SIZE=100"
|
|
||||||
- "MIN_POOL_SIZE=10"
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: docker.io/postgres:16
|
image: docker.io/postgres:16
|
||||||
command: [ "postgres",
|
command: [ "postgres",
|
||||||
|
@ -61,6 +52,7 @@ services:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "5004:80"
|
- "5004:80"
|
||||||
|
- "5005:81"
|
||||||
volumes:
|
volumes:
|
||||||
- ./docker/Caddyfile:/etc/caddy/Caddyfile
|
- ./docker/Caddyfile:/etc/caddy/Caddyfile
|
||||||
- caddy_data:/data
|
- caddy_data:/data
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
http:// {
|
# Frontend and API
|
||||||
|
http://localhost:80 {
|
||||||
reverse_proxy /api/* http://rate:5003
|
reverse_proxy /api/* http://rate:5003
|
||||||
reverse_proxy http://frontend:3000
|
reverse_proxy http://frontend:3000
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# prns.cc (profile URL shortener)
|
||||||
|
http://localhost:81 {
|
||||||
|
rewrite * /sid{uri}
|
||||||
|
reverse_proxy http://backend:5000
|
||||||
|
}
|
||||||
|
|
4
docker/frontend.example.env
Normal file
4
docker/frontend.example.env
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
PUBLIC_LANGUAGE=en
|
||||||
|
PUBLIC_BASE_URL=https://pronouns.cc
|
||||||
|
PUBLIC_SHORT_URL=https://prns.cc
|
||||||
|
PUBLIC_API_BASE=https://pronouns.cc/api
|
Loading…
Reference in a new issue