From 2891856b486ad9397bca1c9839255d73be66361f Mon Sep 17 00:00:00 2001 From: Nutomic Date: Mon, 6 Feb 2023 02:30:10 +0900 Subject: [PATCH] Fix docker federation setup (#2706) --- api_tests/src/shared.ts | 1 - crates/apub/src/lib.rs | 6 +--- crates/db_schema/src/utils.rs | 4 +-- docker/federation/docker-compose.yml | 35 +++++++++++--------- docker/federation/lemmy_alpha.hjson | 8 +---- docker/federation/lemmy_beta.hjson | 7 +--- docker/federation/lemmy_delta.hjson | 7 +--- docker/federation/lemmy_epsilon.hjson | 7 +--- docker/federation/lemmy_gamma.hjson | 7 +--- docker/federation/start-local-instances.bash | 2 +- 10 files changed, 29 insertions(+), 55 deletions(-) diff --git a/api_tests/src/shared.ts b/api_tests/src/shared.ts index 08054818..835f119c 100644 --- a/api_tests/src/shared.ts +++ b/api_tests/src/shared.ts @@ -147,7 +147,6 @@ export async function setupLogins() { // Registration applications are now enabled by default, need to disable them let editSiteForm: EditSite = { registration_mode: RegistrationMode.Open, - federation_debug: true, rate_limit_message: 999, rate_limit_post: 999, rate_limit_register: 999, diff --git a/crates/apub/src/lib.rs b/crates/apub/src/lib.rs index 0908a1f4..53fe7cd3 100644 --- a/crates/apub/src/lib.rs +++ b/crates/apub/src/lib.rs @@ -45,15 +45,11 @@ async fn local_instance(context: &LemmyContext) -> &'static LocalInstance { .as_ref() .map(|l| l.federation_worker_count) .unwrap_or(64) as u64; - let federation_debug = local_site - .as_ref() - .map(|l| l.federation_debug) - .unwrap_or(true); let settings = InstanceSettings::builder() .http_fetch_retry_limit(FEDERATION_HTTP_FETCH_LIMIT) .worker_count(worker_count) - .debug(federation_debug) + .debug(cfg!(debug_assertions)) .http_signature_compat(true) .url_verifier(Box::new(VerifyUrlData(context.clone()))) .build() diff --git a/crates/db_schema/src/utils.rs b/crates/db_schema/src/utils.rs index 8441b687..76d1f795 100644 --- a/crates/db_schema/src/utils.rs +++ b/crates/db_schema/src/utils.rs @@ -154,11 +154,11 @@ pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!(); pub fn run_migrations(db_url: &str) { // Needs to be a sync connection let mut conn = - PgConnection::establish(db_url).unwrap_or_else(|_| panic!("Error connecting to {db_url}")); + PgConnection::establish(db_url).unwrap_or_else(|e| panic!("Error connecting to {db_url}: {e}")); info!("Running Database migrations (This may take a long time)..."); let _ = &mut conn .run_pending_migrations(MIGRATIONS) - .unwrap_or_else(|_| panic!("Couldn't run DB Migrations")); + .unwrap_or_else(|e| panic!("Couldn't run DB Migrations: {e}")); info!("Database migrations complete."); } diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml index 5434603b..f581aa4f 100644 --- a/docker/federation/docker-compose.yml +++ b/docker/federation/docker-compose.yml @@ -30,9 +30,9 @@ services: lemmy-alpha-ui: image: dessalines/lemmy-ui:0.17.1 environment: - - LEMMY_INTERNAL_HOST=lemmy-alpha:8541 - - LEMMY_EXTERNAL_HOST=localhost:8541 - - LEMMY_HTTPS=false + - LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy-alpha:8541 + - LEMMY_UI_LEMMY_EXTERNAL_HOST=localhost:8541 + - LEMMY_UI_HTTPS=false depends_on: - lemmy-alpha lemmy-alpha: @@ -52,15 +52,16 @@ services: - POSTGRES_USER=lemmy - POSTGRES_PASSWORD=password - POSTGRES_DB=lemmy + restart: always volumes: - ./volumes/postgres_alpha:/var/lib/postgresql/data lemmy-beta-ui: image: dessalines/lemmy-ui:0.17.1 environment: - - LEMMY_INTERNAL_HOST=lemmy-beta:8551 - - LEMMY_EXTERNAL_HOST=localhost:8551 - - LEMMY_HTTPS=false + - LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy-beta:8551 + - LEMMY_UI_LEMMY_EXTERNAL_HOST=localhost:8551 + - LEMMY_UI_HTTPS=false depends_on: - lemmy-beta lemmy-beta: @@ -80,15 +81,16 @@ services: - POSTGRES_USER=lemmy - POSTGRES_PASSWORD=password - POSTGRES_DB=lemmy + restart: always volumes: - ./volumes/postgres_beta:/var/lib/postgresql/data lemmy-gamma-ui: image: dessalines/lemmy-ui:0.17.1 environment: - - LEMMY_INTERNAL_HOST=lemmy-gamma:8561 - - LEMMY_EXTERNAL_HOST=localhost:8561 - - LEMMY_HTTPS=false + - LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy-gamma:8561 + - LEMMY_UI_LEMMY_EXTERNAL_HOST=localhost:8561 + - LEMMY_UI_HTTPS=false depends_on: - lemmy-gamma lemmy-gamma: @@ -108,6 +110,7 @@ services: - POSTGRES_USER=lemmy - POSTGRES_PASSWORD=password - POSTGRES_DB=lemmy + restart: always volumes: - ./volumes/postgres_gamma:/var/lib/postgresql/data @@ -115,9 +118,9 @@ services: lemmy-delta-ui: image: dessalines/lemmy-ui:0.17.1 environment: - - LEMMY_INTERNAL_HOST=lemmy-delta:8571 - - LEMMY_EXTERNAL_HOST=localhost:8571 - - LEMMY_HTTPS=false + - LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy-delta:8571 + - LEMMY_UI_LEMMY_EXTERNAL_HOST=localhost:8571 + - LEMMY_UI_HTTPS=false depends_on: - lemmy-delta lemmy-delta: @@ -137,6 +140,7 @@ services: - POSTGRES_USER=lemmy - POSTGRES_PASSWORD=password - POSTGRES_DB=lemmy + restart: always volumes: - ./volumes/postgres_delta:/var/lib/postgresql/data @@ -144,9 +148,9 @@ services: lemmy-epsilon-ui: image: dessalines/lemmy-ui:0.17.1 environment: - - LEMMY_INTERNAL_HOST=lemmy-epsilon:8581 - - LEMMY_EXTERNAL_HOST=localhost:8581 - - LEMMY_HTTPS=false + - LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy-epsilon:8581 + - LEMMY_UI_LEMMY_EXTERNAL_HOST=localhost:8581 + - LEMMY_UI_HTTPS=false depends_on: - lemmy-epsilon lemmy-epsilon: @@ -166,5 +170,6 @@ services: - POSTGRES_USER=lemmy - POSTGRES_PASSWORD=password - POSTGRES_DB=lemmy + restart: always volumes: - ./volumes/postgres_epsilon:/var/lib/postgresql/data diff --git a/docker/federation/lemmy_alpha.hjson b/docker/federation/lemmy_alpha.hjson index 5620c447..a0329b30 100644 --- a/docker/federation/lemmy_alpha.hjson +++ b/docker/federation/lemmy_alpha.hjson @@ -7,13 +7,7 @@ admin_password: lemmylemmy site_name: lemmy-alpha } - # These are ignored, use LEMMY_DATABASE_URL database: { - database: lemmy_alpha - user: lemmy - password: password - host: localhost - port: 5432 - pool_size: 5 + host: postgres_alpha } } diff --git a/docker/federation/lemmy_beta.hjson b/docker/federation/lemmy_beta.hjson index 4aed8552..228fe502 100644 --- a/docker/federation/lemmy_beta.hjson +++ b/docker/federation/lemmy_beta.hjson @@ -8,11 +8,6 @@ site_name: lemmy-beta } database: { - database: lemmy_beta - user: lemmy - password: password - host: localhost - port: 5432 - pool_size: 5 + host: postgres_beta } } diff --git a/docker/federation/lemmy_delta.hjson b/docker/federation/lemmy_delta.hjson index e2ed2547..d05e4121 100644 --- a/docker/federation/lemmy_delta.hjson +++ b/docker/federation/lemmy_delta.hjson @@ -8,11 +8,6 @@ site_name: lemmy-delta } database: { - database: lemmy_delta - user: lemmy - password: password - host: localhost - port: 5432 - pool_size: 5 + host: postgres_delta } } diff --git a/docker/federation/lemmy_epsilon.hjson b/docker/federation/lemmy_epsilon.hjson index cdba0577..17fe2f63 100644 --- a/docker/federation/lemmy_epsilon.hjson +++ b/docker/federation/lemmy_epsilon.hjson @@ -8,11 +8,6 @@ site_name: lemmy-epsilon } database: { - database: lemmy_epsilon - user: lemmy - password: password - host: localhost - port: 5432 - pool_size: 5 + host: postgres_epsilon } } diff --git a/docker/federation/lemmy_gamma.hjson b/docker/federation/lemmy_gamma.hjson index 80c75b25..2041c984 100644 --- a/docker/federation/lemmy_gamma.hjson +++ b/docker/federation/lemmy_gamma.hjson @@ -8,11 +8,6 @@ site_name: lemmy-gamma } database: { - database: lemmy_gamma - user: lemmy - password: password - host: localhost - port: 5432 - pool_size: 5 + host: postgres_gamma } } diff --git a/docker/federation/start-local-instances.bash b/docker/federation/start-local-instances.bash index 1c38c2da..7527108d 100755 --- a/docker/federation/start-local-instances.bash +++ b/docker/federation/start-local-instances.bash @@ -3,7 +3,7 @@ set -e sudo docker-compose down -sudo docker build ../../ --file ../dev/volume_mount.dockerfile -t lemmy-federation:latest +sudo docker build ../../ --file ../dev/Dockerfile -t lemmy-federation:latest for Item in alpha beta gamma delta epsilon ; do sudo mkdir -p volumes/pictrs_$Item -- 2.44.1