From 8ed03338eb69d120f4df9066ad0fb9e48b45527a Mon Sep 17 00:00:00 2001 From: Casraw Date: Tue, 7 Mar 2023 01:04:37 +0100 Subject: [PATCH 1/5] Initial commit for docker docu --- docs/setup/server/docker.md | 48 +++++++++++++++++++++++++++++++++++++ docs/setup/server/index.md | 6 +++++ 2 files changed, 54 insertions(+) create mode 100644 docs/setup/server/docker.md diff --git a/docs/setup/server/docker.md b/docs/setup/server/docker.md new file mode 100644 index 00000000..3f82d894 --- /dev/null +++ b/docs/setup/server/docker.md @@ -0,0 +1,48 @@ +# Docker + +## dev environment + +This clones the master banch into a docker builder and run a build before starting it. +To run it you need docker and docker-compose +`sudo docker compose up` or `sudo docker compose up -d` + +## prod environment with local file storage + +Set the following environment variables in your environment (adapt POSTGRES_USER, POSTGRES_PASSWORD): + +`export POSTGRES_USER=postgres`
+`export POSTGRES_PASSWORD=postgres`
+`export POSTGRES_DATABASE=fosscord` + +This clones the master banch into a docker builder and run a build before starting it. +To run it you need docker and docker-compose +`sudo docker-compose -f docker-compose.prod.yaml up` or `sudo docker-compose -f docker-compose.prod.yaml up -d` + +At first start you get an + +``` +db_1 | 2023-03-04 17:28:25.790 UTC [63] ERROR: relation "config" does not exist at character 31 +db_1 | 2023-03-04 17:28:25.790 UTC [63] STATEMENT: SELECT COUNT(1) AS "cnt" FROM "config" "ConfigEntity" +``` + +## prod environment with S3 file storage + +Set the following environment variables in your environment (adapt POSTGRES_USER, POSTGRES_PASSWORD, S3_BUCKET, S3_BUCKET_NAME,S3_BUCKET_REGION): + +`export POSTGRES_USER=postgres`
+`export POSTGRES_PASSWORD=postgres`
+`export POSTGRES_DATABASE=fosscord`
+`export S3_BUCKET=S3://...`
+`export S3_BUCKET_NAME=test`
+`export S3_BUCKET_REGION=eu-central-1` + +This clones the master banch into a docker builder and run a build before starting it. +To run it you need docker and docker-compose +`docker-compose -f docker-compose.prod.s3.yaml up` or `docker-compose -f docker-compose.prod.s3.yaml up -d` + +At first start you get an + +``` +db_1 | 2023-03-04 17:28:25.790 UTC [63] ERROR: relation "config" does not exist at character 31 +db_1 | 2023-03-04 17:28:25.790 UTC [63] STATEMENT: SELECT COUNT(1) AS "cnt" FROM "config" "ConfigEntity" +``` diff --git a/docs/setup/server/index.md b/docs/setup/server/index.md index c750ed48..ddf6bc96 100644 --- a/docs/setup/server/index.md +++ b/docs/setup/server/index.md @@ -47,6 +47,12 @@ If all went according to plan, you can now access your new Fosscord instance at If you set up your server remotely, you can use `curl http://localhost:3001/api/ping` to verify the server is up and running, (you should set up a reverse proxy, next!). +## Docker + +To use docker please read the following page: + +- [Docker](docker.md) + ## Now what? Well, now you can configure Fosscord to your liking! From 6f7c9becbb537db30a3271b3ce96c03906ddc606 Mon Sep 17 00:00:00 2001 From: Casraw Date: Tue, 7 Mar 2023 01:14:29 +0100 Subject: [PATCH 2/5] Grammer mistakes --- docs/setup/server/docker.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/setup/server/docker.md b/docs/setup/server/docker.md index 3f82d894..5c4d2826 100644 --- a/docs/setup/server/docker.md +++ b/docs/setup/server/docker.md @@ -2,7 +2,7 @@ ## dev environment -This clones the master banch into a docker builder and run a build before starting it. +This clones the master branch into a docker builder and runs a build before starting it. To run it you need docker and docker-compose `sudo docker compose up` or `sudo docker compose up -d` @@ -14,11 +14,11 @@ Set the following environment variables in your environment (adapt POSTGRES_USER `export POSTGRES_PASSWORD=postgres`
`export POSTGRES_DATABASE=fosscord` -This clones the master banch into a docker builder and run a build before starting it. +This clones the master branch into a docker builder and runs a build before starting it. To run it you need docker and docker-compose `sudo docker-compose -f docker-compose.prod.yaml up` or `sudo docker-compose -f docker-compose.prod.yaml up -d` -At first start you get an +At first start, you get an ``` db_1 | 2023-03-04 17:28:25.790 UTC [63] ERROR: relation "config" does not exist at character 31 @@ -36,11 +36,11 @@ Set the following environment variables in your environment (adapt POSTGRES_USER `export S3_BUCKET_NAME=test`
`export S3_BUCKET_REGION=eu-central-1` -This clones the master banch into a docker builder and run a build before starting it. +This clones the master branch into a docker builder and runs a build before starting it. To run it you need docker and docker-compose `docker-compose -f docker-compose.prod.s3.yaml up` or `docker-compose -f docker-compose.prod.s3.yaml up -d` -At first start you get an +At first start, you get an ``` db_1 | 2023-03-04 17:28:25.790 UTC [63] ERROR: relation "config" does not exist at character 31 From 0d129b9e7c3a9d1673285e4aa008ca174c6aa029 Mon Sep 17 00:00:00 2001 From: Casraw Date: Tue, 7 Mar 2023 01:52:48 +0100 Subject: [PATCH 3/5] Corrections due to pr review --- docs/setup/server/configuration/env.md | 43 +++++++++++++++++--------- docs/setup/server/docker.md | 36 ++++++++------------- docs/setup/server/index.md | 12 +++---- 3 files changed, 47 insertions(+), 44 deletions(-) diff --git a/docs/setup/server/configuration/env.md b/docs/setup/server/configuration/env.md index 2469a1db..e7e03793 100644 --- a/docs/setup/server/configuration/env.md +++ b/docs/setup/server/configuration/env.md @@ -4,18 +4,31 @@ Below is a list of environment variables used by Fosscord. You can set environment variables easily by creating an `.env` file in the `fosscord-server` folder, with the format `NAME=VALUE` with each on new lines. -| Name | Value | Description | -| -------------------------- | -------------- | -------------------------------------------------------------------------------------------------------------------- | -| THREADS | number | Number of threads to run Fosscord on when using bundle. Make sure you've enabled RabbitMQ if using more than one | -| PORT | number | Port to listen on. Used by all components, including bundle. If using bundle, all components run under the same port | -| DATABASE | string | Database connection string. Defaults to SQlite3 at project root | -| CONFIG_PATH | string | File path for JSON config, if not using `config` db table | -| WS_LOGEVENTS | boolean | If set, log websocket events except messages from gateway | -| WS_VERBOSE | boolean | If set, log websocket messages sent/received by gateway | -| WS_DUMP | boolean | If set, dump websocket messages sent/received to disk | -| CDN | string | Lowest priority value for public CDN annoucements | -| GATEWAY | string | Lowest priority value for public gateway annoucements | -| STORAGE_LOCATION | string | CDN storage location. File path or S3 bucktet | -| STORAGE_PROVIDER | "s3" or "file" | CDN storage provider | -| STORAGE_BUCKET | string | S3 bucket name | -| STORAGE_REGION | string | S3 storage region | +| Name | Value | Description | +| ---------------- | -------------- | -------------------------------------------------------------------------------------------------------------------- | +| THREADS | number | Number of threads to run Fosscord on when using bundle. Make sure you've enabled RabbitMQ if using more than one | +| PORT | number | Port to listen on. Used by all components, including bundle. If using bundle, all components run under the same port | +| DATABASE | string | Database connection string. Defaults to SQlite3 at project root | +| CONFIG_PATH | string | File path for JSON config, if not using `config` db table | +| WS_LOGEVENTS | boolean | If set, log websocket events except messages from gateway | +| WS_VERBOSE | boolean | If set, log websocket messages sent/received by gateway | +| WS_DUMP | boolean | If set, dump websocket messages sent/received to disk | +| CDN | string | Lowest priority value for public CDN annoucements | +| GATEWAY | string | Lowest priority value for public gateway annoucements | +| STORAGE_LOCATION | string | CDN storage location. File path or S3 bucktet | +| STORAGE_PROVIDER | "s3" or "file" | CDN storage provider | +| STORAGE_BUCKET | string | S3 bucket name | +| STORAGE_REGION | string | S3 storage region | + +## Docker + +These environment variables should be set in the environment `~/.profile` or with an `export` + +| Name | Value | Description | +| ----------------- | ------ | --------------------------------------------------------------- | +| POSTGRES_USER | string | Postgressql database user name | +| POSTGRES_PASSWORD | string | Postgressql database password | +| POSTGRES_DATABASE | string | Database connection string. Defaults to SQlite3 at project root | +| S3_BUCKET | string | CDN storage location. S3 bucktet | +| S3_BUCKET_NAME | string | S3 bucket | +| S3_BUCKET_REGION | string | S3 storage region | diff --git a/docs/setup/server/docker.md b/docs/setup/server/docker.md index 5c4d2826..f13db849 100644 --- a/docs/setup/server/docker.md +++ b/docs/setup/server/docker.md @@ -1,46 +1,36 @@ # Docker -## dev environment +## Dev environment This clones the master branch into a docker builder and runs a build before starting it. To run it you need docker and docker-compose `sudo docker compose up` or `sudo docker compose up -d` -## prod environment with local file storage +## Prod environment with local file storage or with S3 Set the following environment variables in your environment (adapt POSTGRES_USER, POSTGRES_PASSWORD): -`export POSTGRES_USER=postgres`
-`export POSTGRES_PASSWORD=postgres`
-`export POSTGRES_DATABASE=fosscord` +``` +export POSTGRES_USER=postgres +export POSTGRES_PASSWORD=postgres +export POSTGRES_DATABASE=fosscord +``` This clones the master branch into a docker builder and runs a build before starting it. To run it you need docker and docker-compose `sudo docker-compose -f docker-compose.prod.yaml up` or `sudo docker-compose -f docker-compose.prod.yaml up -d` -At first start, you get an +Additional you can set S3 storage backend: ``` -db_1 | 2023-03-04 17:28:25.790 UTC [63] ERROR: relation "config" does not exist at character 31 -db_1 | 2023-03-04 17:28:25.790 UTC [63] STATEMENT: SELECT COUNT(1) AS "cnt" FROM "config" "ConfigEntity" +export S3_BUCKET=S3://... +export S3_BUCKET_NAME=test +export S3_BUCKET_REGION=eu-central-1 ``` -## prod environment with S3 file storage - -Set the following environment variables in your environment (adapt POSTGRES_USER, POSTGRES_PASSWORD, S3_BUCKET, S3_BUCKET_NAME,S3_BUCKET_REGION): - -`export POSTGRES_USER=postgres`
-`export POSTGRES_PASSWORD=postgres`
-`export POSTGRES_DATABASE=fosscord`
-`export S3_BUCKET=S3://...`
-`export S3_BUCKET_NAME=test`
-`export S3_BUCKET_REGION=eu-central-1` - -This clones the master branch into a docker builder and runs a build before starting it. -To run it you need docker and docker-compose -`docker-compose -f docker-compose.prod.s3.yaml up` or `docker-compose -f docker-compose.prod.s3.yaml up -d` +Then start it with: `docker-compose -f docker-compose.prod.s3.yaml up` or `docker-compose -f docker-compose.prod.s3.yaml up -d` -At first start, you get an +At first start, you get an. This error can be ignored due to first start. ``` db_1 | 2023-03-04 17:28:25.790 UTC [63] ERROR: relation "config" does not exist at character 31 diff --git a/docs/setup/server/index.md b/docs/setup/server/index.md index ddf6bc96..703f07bc 100644 --- a/docs/setup/server/index.md +++ b/docs/setup/server/index.md @@ -11,6 +11,12 @@ You **must** have access to a terminal for this guide. We do not recommend using Windows to run Fosscord. +## Docker + +To use docker please read the following page: + +- [Docker](docker.md) + ## Dependencies - [Git](https://git-scm.com/) @@ -47,12 +53,6 @@ If all went according to plan, you can now access your new Fosscord instance at If you set up your server remotely, you can use `curl http://localhost:3001/api/ping` to verify the server is up and running, (you should set up a reverse proxy, next!). -## Docker - -To use docker please read the following page: - -- [Docker](docker.md) - ## Now what? Well, now you can configure Fosscord to your liking! From 7ffa99e157608c021200bdf77263cda6f150b6ef Mon Sep 17 00:00:00 2001 From: Casraw Date: Tue, 7 Mar 2023 02:18:02 +0100 Subject: [PATCH 4/5] Spelling correction --- docs/setup/server/configuration/env.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/setup/server/configuration/env.md b/docs/setup/server/configuration/env.md index e7e03793..84c892cf 100644 --- a/docs/setup/server/configuration/env.md +++ b/docs/setup/server/configuration/env.md @@ -26,7 +26,7 @@ These environment variables should be set in the environment `~/.profile` or wit | Name | Value | Description | | ----------------- | ------ | --------------------------------------------------------------- | -| POSTGRES_USER | string | Postgressql database user name | +| POSTGRES_USER | string | Postgressql database username | | POSTGRES_PASSWORD | string | Postgressql database password | | POSTGRES_DATABASE | string | Database connection string. Defaults to SQlite3 at project root | | S3_BUCKET | string | CDN storage location. S3 bucktet | From f1cd66ebd734df180cf6389db48e7be8220b7f02 Mon Sep 17 00:00:00 2001 From: Casraw Date: Sat, 1 Apr 2023 23:47:26 +0200 Subject: [PATCH 5/5] rewrite of the docu --- docs/setup/server/docker.md | 138 ++++++++++++++++++++++++++++++++++-- 1 file changed, 132 insertions(+), 6 deletions(-) diff --git a/docs/setup/server/docker.md b/docs/setup/server/docker.md index f13db849..16f1809f 100644 --- a/docs/setup/server/docker.md +++ b/docs/setup/server/docker.md @@ -1,11 +1,34 @@ -# Docker +# Spacebar Server Docker + +GitHub: [Spacebar Docker GitHub](https://github.com/spacebarchat/docker) ## Dev environment -This clones the master branch into a docker builder and runs a build before starting it. To run it you need docker and docker-compose `sudo docker compose up` or `sudo docker compose up -d` +docker-compose.yaml + +``` +version: "3.9" +services: + spacebar: + image: spacebarchat/server:latest-sqlite + ports: + - "3001:3001" + volumes: + - spacebar-database:/exec/persistent/database/ + - spacebar-storage:/exec/persistent/storage + environment: + DATABASE: "/exec/persistent/database/database.db" + STORAGE_PROVIDER: "file" + STORAGE_LOCATION: "/exec/persistent/storage/" + PORT: "3001" +volumes: + spacebar-database: + spacebar-storage: +``` + ## Prod environment with local file storage or with S3 Set the following environment variables in your environment (adapt POSTGRES_USER, POSTGRES_PASSWORD): @@ -13,14 +36,54 @@ Set the following environment variables in your environment (adapt POSTGRES_USER ``` export POSTGRES_USER=postgres export POSTGRES_PASSWORD=postgres -export POSTGRES_DATABASE=fosscord +export POSTGRES_DATABASE=spacebar +``` + +docker-compose.prod.yaml + +``` +version: "3.9" +services: + spacebar: + image: spacebarchat/server:latest-postgressql + restart: unless-stopped + ports: + - "3001:3001" + volumes: + - spacebar-storage:/exec/persistent/storage + environment: + DATABASE: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DATABASE} + STORAGE_PROVIDER: "file" + STORAGE_LOCATION: "/exec/persistent/storage/" + PORT: "3001" + depends_on: + db: + condition: service_healthy + db: + image: postgres:15-alpine + restart: unless-stopped + environment: + - POSTGRES_USER=${POSTGRES_USER:?err} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?err} + - POSTGRES_DB=${POSTGRES_DATABASE:?err} + ports: + - '127.0.0.1:5432:5432' + volumes: + - db:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -d ${POSTGRES_DATABASE} -U ${POSTGRES_USER}"] + interval: 10s + timeout: 5s + retries: 5 +volumes: + spacebar-storage: + db: ``` -This clones the master branch into a docker builder and runs a build before starting it. To run it you need docker and docker-compose `sudo docker-compose -f docker-compose.prod.yaml up` or `sudo docker-compose -f docker-compose.prod.yaml up -d` -Additional you can set S3 storage backend: +### Additional you can set S3 storage backend: ``` export S3_BUCKET=S3://... @@ -28,11 +91,74 @@ export S3_BUCKET_NAME=test export S3_BUCKET_REGION=eu-central-1 ``` +docker-compose.prod.s3.yaml + +``` +version: "3.9" +services: + spacebar: + image: spacebarchat/server:latest-postgressql + restart: unless-stopped + ports: + - "3001:3001" + environment: + DATABASE: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DATABASE} + STORAGE_PROVIDER: s3 + STORAGE_LOCATION: ${S3_BUCKET:?err} + STORAGE_BUCKET: ${S3_BUCKET_NAME:?err} + STORAGE_REGION: ${S3_BUCKET_REGION:?err} + PORT: "3001" + depends_on: + db: + condition: service_healthy + db: + image: postgres:15-alpine + restart: unless-stopped + environment: + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DB=${POSTGRES_DATABASE} + ports: + - '127.0.0.1:5432:5432' + volumes: + - db:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -d ${POSTGRES_DATABASE} -U ${POSTGRES_USER}"] + interval: 10s + timeout: 5s + retries: 5 +volumes: + db: +``` + Then start it with: `docker-compose -f docker-compose.prod.s3.yaml up` or `docker-compose -f docker-compose.prod.s3.yaml up -d` -At first start, you get an. This error can be ignored due to first start. +At first start, you get the following error. This error can be ignored due to first start. ``` db_1 | 2023-03-04 17:28:25.790 UTC [63] ERROR: relation "config" does not exist at character 31 db_1 | 2023-03-04 17:28:25.790 UTC [63] STATEMENT: SELECT COUNT(1) AS "cnt" FROM "config" "ConfigEntity" ``` + +## With NGINX and client (Which is under WIP) + +Under spacebar-server-client-proxy there is a small project in experimental state. Which run the spacebar server, the spacebar client with an reverse proxy and ssl in it. +You need to clone the repo. +`git clone https://github.com/spacebarchat/docker.git` +And then go to `spacebar-server-client-proxy` +Please adapt the following env variables to your need: + +``` +export POSTGRES_USER=postgres +export POSTGRES_PASSWORD=your-password +export POSTGRES_DATABASE=spacebar +export MAIL_CERTBOT=your-email +export NGINX_HOST=your-domain +``` + +To run it you need docker and docker-compose +`sudo docker-compose -f docker-compose.prod.yaml up` or `sudo docker-compose -f docker-compose.prod.yaml up -d` + +# Spacebar client + +Due to the fact that it is under development for now, i provide no client README. It may change in the future. Take a look at the `With NGINX and client (Which is under WIP)` section