Skip to content

Instantly share code, notes, and snippets.

@ngerakines
Created January 26, 2025 15:57
Show Gist options
  • Save ngerakines/9ca6ff9cecaa36ea1646754c3158482a to your computer and use it in GitHub Desktop.
Save ngerakines/9ca6ff9cecaa36ea1646754c3158482a to your computer and use it in GitHub Desktop.

PLC

Prepare

  1. Build the container

    $ https://github.com/did-method-plc/did-method-plc.

Setup

  1. Start the database.

    $ docker compose up db -d

  2. Start tailscale

    $ docekr compose up tailscale -d

  3. Create the SSL certificate

    $ docker compose exec tailscale /bin/sh -c "tailscale cert --cert-file /mnt/tls/cert.pem --key-file /mnt/tls/cert.key plc.bowfin-woodpecker.ts.net"

  4. Start PLC

    $ docker compose up -d

Local Development

See also:

version: '3.8'
volumes:
plc_db:
plc_ts:
plc_tls:
services:
db:
image: postgres:14.4-alpine
restart: unless-stopped
environment:
- POSTGRES_USER=pg
- POSTGRES_PASSWORD=password
healthcheck:
test: 'pg_isready -U pg'
interval: 500ms
timeout: 10s
retries: 20
volumes:
- plc_db:/var/lib/postgresql/data
- ./postgres/init/init.sql:/docker-entrypoint-initdb.d/init.sql
app:
depends_on:
db:
condition: service_healthy
restart: true
image: docker.io/library/plcjs
restart: unless-stopped
environment:
- DATABASE_URL=postgres://pg:password@db/plc
- DEBUG_MODE=1
- LOG_ENABLED=true
- LOG_LEVEL=debug
- DB_CREDS_JSON={"username":"pg","password":"password","host":"db","port":"5432","database":"plc"}
- DB_MIGRATE_CREDS_JSON={"username":"pg","password":"password","host":"db","port":"5432","database":"plc"}
- ENABLE_MIGRATIONS=true
- LOG_DESTINATION=1
ports:
- '3000:3000'
tailscale:
image: tailscale/tailscale:latest
restart: unless-stopped
environment:
- TS_AUTHKEY=tskey-auth-your-key-goes-here
- TS_STATE_DIR=/var/run/tailscale
- TS_EXTRA_ARGS=--advertise-tags=tag:plc
- TS_HOSTNAME=plc
volumes:
- plc_tls:/mnt/tls
- plc_ts:/var/run/tailscale
nginx:
image: nginx
restart: unless-stopped
network_mode: service:tailscale
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- plc_tls:/mnt/tls:ro
-- plc
CREATE DATABASE plc;
GRANT ALL PRIVILEGES ON DATABASE plc TO pg;
-- bgs
CREATE DATABASE bgs;
CREATE DATABASE carstore;
GRANT ALL PRIVILEGES ON DATABASE bgs TO pg;
GRANT ALL PRIVILEGES ON DATABASE carstore TO pg;
-- bsky(appview)
CREATE DATABASE bsky;
GRANT ALL PRIVILEGES ON DATABASE bsky TO pg;
-- ozone(moderation)
CREATE DATABASE mod;
GRANT ALL PRIVILEGES ON DATABASE mod TO pg;
-- pds
CREATE DATABASE pds;
GRANT ALL PRIVILEGES ON DATABASE pds TO pg;
events {}
http {
server {
resolver 127.0.0.11 [::1]:5353 valid=15s;
set $backend "http://app:3000";
listen 443 ssl;
ssl_certificate /mnt/tls/cert.pem;
ssl_certificate_key /mnt/tls/cert.key;
location / {
proxy_pass $backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 64M;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment