chore(prod): support .env.docker in crons, fix WAL mapping and add canvas copy in Dockerfile
This commit is contained in:
@@ -12,6 +12,7 @@ services:
|
|||||||
POSTGRES_DB: ${POSTGRES_DB:-memento}
|
POSTGRES_DB: ${POSTGRES_DB:-memento}
|
||||||
volumes:
|
volumes:
|
||||||
- postgres-data:/var/lib/postgresql/data
|
- postgres-data:/var/lib/postgresql/data
|
||||||
|
- ./backups:/var/lib/postgresql/backups
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:${POSTGRES_PORT:-5433}:5432"
|
- "127.0.0.1:${POSTGRES_PORT:-5433}:5432"
|
||||||
healthcheck:
|
healthcheck:
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
|
|||||||
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/.prisma ./node_modules/.prisma
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/.prisma ./node_modules/.prisma
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/@prisma ./node_modules/@prisma
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/@prisma ./node_modules/@prisma
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/prisma ./node_modules/prisma
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/prisma ./node_modules/prisma
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/@napi-rs ./node_modules/@napi-rs
|
||||||
|
|
||||||
# Entrypoint
|
# Entrypoint
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/docker-entrypoint.sh ./docker-entrypoint.sh
|
COPY --from=builder --chown=nextjs:nodejs /app/docker-entrypoint.sh ./docker-entrypoint.sh
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Load environment variables from .env.docker if it exists
|
||||||
|
if [ -f "/opt/memento/.env.docker" ]; then
|
||||||
|
set -a
|
||||||
|
source "/opt/memento/.env.docker"
|
||||||
|
set +a
|
||||||
|
fi
|
||||||
|
|
||||||
BACKUP_DIR="/opt/memento/backups"
|
BACKUP_DIR="/opt/memento/backups"
|
||||||
WAL_DIR="$BACKUP_DIR/wal"
|
WAL_DIR="$BACKUP_DIR/wal"
|
||||||
SNAPSHOT_DIR="$BACKUP_DIR/snapshots"
|
SNAPSHOT_DIR="$BACKUP_DIR/snapshots"
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Load environment variables from .env.docker if it exists
|
||||||
|
if [ -f "/opt/memento/.env.docker" ]; then
|
||||||
|
set -a
|
||||||
|
source "/opt/memento/.env.docker"
|
||||||
|
set +a
|
||||||
|
fi
|
||||||
|
|
||||||
SNAPSHOT_DIR="/opt/memento/backups/snapshots"
|
SNAPSHOT_DIR="/opt/memento/backups/snapshots"
|
||||||
SSH_KEY="/root/.ssh/memento-nas"
|
SSH_KEY="/root/.ssh/memento-nas"
|
||||||
NAS1="sepehr@192.168.1.132"
|
NAS1="sepehr@192.168.1.132"
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Load environment variables from .env.docker if it exists
|
||||||
|
if [ -f "/opt/memento/.env.docker" ]; then
|
||||||
|
set -a
|
||||||
|
source "/opt/memento/.env.docker"
|
||||||
|
set +a
|
||||||
|
fi
|
||||||
|
|
||||||
BACKUP_DIR="/opt/memento/backups"
|
BACKUP_DIR="/opt/memento/backups"
|
||||||
SNAPSHOT_DIR="$BACKUP_DIR/snapshots"
|
SNAPSHOT_DIR="$BACKUP_DIR/snapshots"
|
||||||
PG_CONTAINER="memento-postgres"
|
PG_CONTAINER="memento-postgres"
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Load environment variables from .env.docker if it exists
|
||||||
|
if [ -f "/opt/memento/.env.docker" ]; then
|
||||||
|
set -a
|
||||||
|
source "/opt/memento/.env.docker"
|
||||||
|
set +a
|
||||||
|
fi
|
||||||
|
|
||||||
BACKUP_DIR="/opt/memento/backups"
|
BACKUP_DIR="/opt/memento/backups"
|
||||||
WAL_DIR="$BACKUP_DIR/wal"
|
WAL_DIR="$BACKUP_DIR/wal"
|
||||||
PG_CONTAINER="memento-postgres"
|
PG_CONTAINER="memento-postgres"
|
||||||
@@ -19,13 +26,23 @@ log "=== Setting up WAL archiving ==="
|
|||||||
|
|
||||||
docker exec "$PG_CONTAINER" bash -c "mkdir -p /var/lib/postgresql/backups/wal"
|
docker exec "$PG_CONTAINER" bash -c "mkdir -p /var/lib/postgresql/backups/wal"
|
||||||
|
|
||||||
|
log "Configuring PostgreSQL WAL parameters..."
|
||||||
docker exec "$PG_CONTAINER" psql -U "$PG_USER" -d "$PG_DB" -c "ALTER SYSTEM SET wal_level = replica;"
|
docker exec "$PG_CONTAINER" psql -U "$PG_USER" -d "$PG_DB" -c "ALTER SYSTEM SET wal_level = replica;"
|
||||||
docker exec "$PG_CONTAINER" psql -U "$PG_USER" -d "$PG_DB" -c "ALTER SYSTEM SET archive_mode = on;"
|
docker exec "$PG_CONTAINER" psql -U "$PG_USER" -d "$PG_DB" -c "ALTER SYSTEM SET archive_mode = on;"
|
||||||
docker exec "$PG_CONTAINER" psql -U "$PG_USER" -d "$PG_DB" -c "ALTER SYSTEM SET archive_command = 'cp %p /var/lib/postgresql/backups/wal/%f';"
|
docker exec "$PG_CONTAINER" psql -U "$PG_USER" -d "$PG_DB" -c "ALTER SYSTEM SET archive_command = 'cp %p /var/lib/postgresql/backups/wal/%f';"
|
||||||
docker exec "$PG_CONTAINER" psql -U "$PG_USER" -d "$PG_DB" -c "ALTER SYSTEM SET max_wal_senders = 3;"
|
docker exec "$PG_CONTAINER" psql -U "$PG_USER" -d "$PG_DB" -c "ALTER SYSTEM SET max_wal_senders = 3;"
|
||||||
docker exec "$PG_CONTAINER" psql -U "$PG_USER" -d "$PG_DB" -c "ALTER SYSTEM SET wal_keep_size = '1GB';"
|
docker exec "$PG_CONTAINER" psql -U "$PG_USER" -d "$PG_DB" -c "ALTER SYSTEM SET wal_keep_size = '1GB';"
|
||||||
|
|
||||||
log "Reloading PostgreSQL configuration..."
|
log "Restarting PostgreSQL container to apply WAL parameters (required for wal_level)..."
|
||||||
|
docker restart "$PG_CONTAINER"
|
||||||
|
|
||||||
|
# Wait for PostgreSQL to be ready
|
||||||
|
log "Waiting for PostgreSQL to be ready..."
|
||||||
|
until docker exec "$PG_CONTAINER" pg_isready -U "$PG_USER" -d "$PG_DB" >/dev/null 2>&1; do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
log "PostgreSQL is ready. Reloading config..."
|
||||||
docker exec "$PG_CONTAINER" psql -U "$PG_USER" -d "$PG_DB" -c "SELECT pg_reload_conf();"
|
docker exec "$PG_CONTAINER" psql -U "$PG_USER" -d "$PG_DB" -c "SELECT pg_reload_conf();"
|
||||||
|
|
||||||
log "WAL archiving enabled. Archives stored in /var/lib/postgresql/backups/wal/"
|
log "WAL archiving enabled. Archives stored in /var/lib/postgresql/backups/wal/"
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Load environment variables from .env.docker if it exists
|
||||||
|
if [ -f "/opt/memento/.env.docker" ]; then
|
||||||
|
set -a
|
||||||
|
source "/opt/memento/.env.docker"
|
||||||
|
set +a
|
||||||
|
fi
|
||||||
|
|
||||||
BACKUP_DIR="/opt/memento/backups"
|
BACKUP_DIR="/opt/memento/backups"
|
||||||
SNAPSHOT_DIR="$BACKUP_DIR/snapshots"
|
SNAPSHOT_DIR="$BACKUP_DIR/snapshots"
|
||||||
PG_CONTAINER="memento-postgres"
|
PG_CONTAINER="memento-postgres"
|
||||||
|
|||||||
Reference in New Issue
Block a user