From f6cadc530f5f95427cf2fd583bea57e5de382b66 Mon Sep 17 00:00:00 2001 From: "stephane.david" Date: Sat, 29 Nov 2025 10:32:24 +0100 Subject: [PATCH] First version --- .env | 23 ++++++++ .idea/.gitignore | 5 ++ .idea/affine.iml | 9 +++ .idea/copilot.data.migration.agent.xml | 6 ++ .idea/misc.xml | 6 ++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 ++ docker-compose.yml | 76 ++++++++++++++++++++++++++ 8 files changed, 139 insertions(+) create mode 100644 .env create mode 100644 .idea/.gitignore create mode 100644 .idea/affine.iml create mode 100644 .idea/copilot.data.migration.agent.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 docker-compose.yml diff --git a/.env b/.env new file mode 100644 index 0000000..1461628 --- /dev/null +++ b/.env @@ -0,0 +1,23 @@ +# select a revision to deploy, available values: stable, beta, canary +AFFINE_REVISION=stable + +# set the port for the server container it will expose the server on +PORT=3010 + +# set the host for the server for outgoing links +# AFFINE_SERVER_HTTPS=true +# AFFINE_SERVER_HOST=affine.yourdomain.com +# or +# AFFINE_SERVER_EXTERNAL_URL=https://affine.yourdomain.com + +# position of the database data to persist +DB_DATA_LOCATION=/var/lib/docker/volumes/affine/.affine/self-host/postgres/pgdata +# position of the upload data(images, files, etc.) to persist +UPLOAD_LOCATION=/var/lib/docker/volumes/affine/.affine/self-host/storage +# position of the configuration files to persist +CONFIG_LOCATION=/var/lib/docker/volumes/affine/.affine/self-host/config + +# database credentials +DB_USERNAME=affine +DB_PASSWORD=sda101176 +DB_DATABASE=affine \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..a0ccf77 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Environment-dependent path to Maven home directory +/mavenHomeManager.xml diff --git a/.idea/affine.iml b/.idea/affine.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/affine.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/copilot.data.migration.agent.xml b/.idea/copilot.data.migration.agent.xml new file mode 100644 index 0000000..4ea72a9 --- /dev/null +++ b/.idea/copilot.data.migration.agent.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..2a824a2 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..a1c36e1 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d4c4ea2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,76 @@ +name: affine +services: + affine: + image: ghcr.io/toeverything/affine:${AFFINE_REVISION:-stable} + container_name: affine_server + ports: + - '${PORT:-3010}:3010' + depends_on: + redis: + condition: service_healthy + postgres: + condition: service_healthy + affine_migration: + condition: service_completed_successfully + volumes: + # custom configurations + - ${UPLOAD_LOCATION}:/root/.affine/storage + - ${CONFIG_LOCATION}:/root/.affine/config + env_file: + - .env + environment: + - REDIS_SERVER_HOST=redis + - DATABASE_URL=postgresql://${DB_USERNAME}:${DB_PASSWORD}@postgres:5432/${DB_DATABASE:-affine} + - AFFINE_INDEXER_ENABLED=false + restart: unless-stopped + + affine_migration: + image: ghcr.io/toeverything/affine:${AFFINE_REVISION:-stable} + container_name: affine_migration_job + volumes: + # custom configurations + - ${UPLOAD_LOCATION}:/root/.affine/storage + - ${CONFIG_LOCATION}:/root/.affine/config + command: ['sh', '-c', 'node ./scripts/self-host-predeploy.js'] + env_file: + - .env + environment: + - REDIS_SERVER_HOST=redis + - DATABASE_URL=postgresql://${DB_USERNAME}:${DB_PASSWORD}@postgres:5432/${DB_DATABASE:-affine} + - AFFINE_INDEXER_ENABLED=false + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy + + redis: + image: redis + container_name: affine_redis + healthcheck: + test: ['CMD', 'redis-cli', '--raw', 'incr', 'ping'] + interval: 10s + timeout: 5s + retries: 5 + restart: unless-stopped + + postgres: + image: pgvector/pgvector:pg16 + container_name: affine_postgres + volumes: + - ${DB_DATA_LOCATION}:/var/lib/postgresql/data + environment: + POSTGRES_USER: ${DB_USERNAME} + POSTGRES_PASSWORD: ${DB_PASSWORD} + POSTGRES_DB: ${DB_DATABASE:-affine} + POSTGRES_INITDB_ARGS: '--data-checksums' + # you better set a password for you database + # or you may add 'POSTGRES_HOST_AUTH_METHOD=trust' to ignore postgres security policy + POSTGRES_HOST_AUTH_METHOD: trust + healthcheck: + test: + ['CMD', 'pg_isready', '-U', "${DB_USERNAME}", '-d', "${DB_DATABASE:-affine}"] + interval: 10s + timeout: 5s + retries: 5 + restart: unless-stopped