mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-08-23 00:57:21 -05:00
feat: add docker compose setup
This commit is contained in:
32
.docker/assets/garage-init.sh
Normal file
32
.docker/assets/garage-init.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
# Taken from: https://spwoodcock.dev/blog/2026-03-03-automate-garage-standalone/
|
||||
# Modified to add environment variable support
|
||||
|
||||
# chroot into the s3 container's filesystem so the garage binary runs
|
||||
# with its own libs/linker, while the shared network namespace keeps
|
||||
# 127.0.0.1:3901 pointing at the live Garage server
|
||||
G="chroot /proc/1/root /garage -c /etc/garage.toml"
|
||||
|
||||
# Wait for server
|
||||
for i in $(seq 1 20); do
|
||||
if $G node id -q 2>/dev/null; then break; fi
|
||||
echo "Waiting for Garage RPC... ($i/20)"
|
||||
sleep 3
|
||||
done
|
||||
$G node id -q || { echo "Garage RPC not ready"; exit 1; }
|
||||
|
||||
# Init garage nodes
|
||||
if $G status 2>&1 | grep -q 'NO ROLE ASSIGNED'; then
|
||||
NODE_ID=$($G node id -q | cut -c1-16)
|
||||
$G layout assign "$NODE_ID" -z local -c 1G
|
||||
$G layout apply --version 1
|
||||
fi
|
||||
|
||||
# Create S3 bucket
|
||||
$G key import --yes -n "$S3_ACCESS_KEY_NAME" \
|
||||
"$S3_ACCESS_KEY_ID" \
|
||||
"$S3_ACCESS_KEY_SECRET" || true
|
||||
$G bucket create "$S3_BUCKET" || true
|
||||
$G bucket allow "$S3_BUCKET" --key "$S3_ACCESS_KEY_NAME" --read --write --owner || true
|
||||
$G bucket website --allow "$S3_BUCKET"
|
||||
|
||||
echo "Garage initialized."
|
||||
17
.docker/assets/garage.toml
Normal file
17
.docker/assets/garage.toml
Normal file
@@ -0,0 +1,17 @@
|
||||
metadata_dir = "/var/lib/garage/meta"
|
||||
data_dir = "/var/lib/garage/data"
|
||||
|
||||
replication_factor = 1
|
||||
db_engine = "sqlite"
|
||||
|
||||
rpc_bind_addr = "[::]:3901"
|
||||
rpc_public_addr = "127.0.0.1:3901"
|
||||
rpc_secret = "fbb4c8c25cdb7766ef9c2913cee0a6b52a927c03fafea2aa21e8658c68cc14c7"
|
||||
|
||||
[s3_api]
|
||||
s3_region = "garage"
|
||||
api_bind_addr = "[::]:3900"
|
||||
|
||||
[s3_web]
|
||||
bind_addr = "[::]:3902"
|
||||
root_domain = ".localhost"
|
||||
86
.docker/docker-compose.yml
Normal file
86
.docker/docker-compose.yml
Normal file
@@ -0,0 +1,86 @@
|
||||
name: "pn-website-dev"
|
||||
|
||||
services:
|
||||
mailpit:
|
||||
image: axllent/mailpit
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 8025:8025 # Web port
|
||||
- 1025:1025 # SMTP port
|
||||
mongo:
|
||||
image: mongo:8.0
|
||||
restart: unless-stopped
|
||||
command: ["--replSet", "rs0", "--bind_ip_all", "--port", "27017"]
|
||||
ports:
|
||||
- 27017:27017 # MongoDB port
|
||||
# This funky stuff is needed for making a replicaset
|
||||
healthcheck:
|
||||
test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'rs0',members:[{_id:0,host:'host.docker.internal:27017'}]}) }" | mongosh --port 27017 --quiet
|
||||
interval: 5s
|
||||
timeout: 30s
|
||||
start_period: 0s
|
||||
start_interval: 1s
|
||||
retries: 30
|
||||
volumes:
|
||||
- "mongo_data:/data/db"
|
||||
- "mongo_config:/data/configdb"
|
||||
garage:
|
||||
image: dxflrs/garage:v2.3.0
|
||||
restart: unless-stopped
|
||||
networks: [net]
|
||||
ports:
|
||||
- "3900:3900" # S3 API port
|
||||
- "3902:3902" # Web port
|
||||
healthcheck:
|
||||
test: ["CMD", "/garage", "status"]
|
||||
start_period: 5s
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
volumes:
|
||||
- ./assets/garage.toml:/etc/garage.toml:ro
|
||||
- garage_data:/var/lib/garage
|
||||
garage-init:
|
||||
image: alpine:3.23
|
||||
depends_on:
|
||||
garage:
|
||||
condition: service_healthy
|
||||
network_mode: service:garage
|
||||
pid: service:garage
|
||||
environment:
|
||||
GARAGE_ADMIN_TOKEN: garage-admin-token
|
||||
S3_ACCESS_KEY_NAME: pretendo-key
|
||||
S3_ACCESS_KEY_ID: GK3515373e4c851ebaad366558
|
||||
S3_ACCESS_KEY_SECRET: 7d37d093435a41f2aab8f13c19ba067d9776c90215f56614adad6ece597dbb34
|
||||
S3_BUCKET: pretendo
|
||||
restart: "on-failure:2"
|
||||
entrypoint: "/bin/sh -eu /etc/init.sh"
|
||||
volumes:
|
||||
- "./assets/garage-init.sh:/etc/init.sh"
|
||||
account:
|
||||
image: ghcr.io/pretendonetwork/account:sha-edb4b02
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8123:8123" # grpc
|
||||
- "8056:8056" # http
|
||||
environment:
|
||||
PN_ACT_CONFIG_HTTP_PORT: 8056
|
||||
PN_ACT_CONFIG_GRPC_PORT: 8123
|
||||
PN_ACT_CONFIG_MONGO_CONNECTION_STRING: "mongodb://mongo:27017/account?directConnection=true"
|
||||
PN_ACT_CONFIG_S3_ENDPOINT: "http://localhost:3900"
|
||||
PN_ACT_CONFIG_S3_REGION: "garage"
|
||||
PN_ACT_CONFIG_S3_BUCKET: "pretendo"
|
||||
PN_ACT_CONFIG_S3_ACCESS_KEY: "GK3515373e4c851ebaad366558"
|
||||
PN_ACT_CONFIG_S3_ACCESS_SECRET: "7d37d093435a41f2aab8f13c19ba067d9776c90215f56614adad6ece597dbb34"
|
||||
PN_ACT_CONFIG_CDN_BASE_URL: "http://localhost:3902/pretendo"
|
||||
PN_ACT_CONFIG_AES_KEY: "1234567812345678123456781234567812345678123456781234567812345678"
|
||||
PN_ACT_CONFIG_GRPC_MASTER_API_KEY_ACCOUNT: "12345678123456781234567812345678"
|
||||
PN_ACT_CONFIG_GRPC_MASTER_API_KEY_API: "12345678123456781234567812345678"
|
||||
|
||||
networks:
|
||||
net:
|
||||
|
||||
volumes:
|
||||
mongo_data:
|
||||
mongo_config:
|
||||
garage_data:
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -6,3 +6,6 @@
|
||||
dist
|
||||
node_modules
|
||||
.env
|
||||
|
||||
# Old configuration ignored for safety
|
||||
config.json
|
||||
|
||||
Reference in New Issue
Block a user