From 86ee0b5d2c1ee2c8d15880c00e3a965585196075 Mon Sep 17 00:00:00 2001 From: Oleg Valter Date: Mon, 31 Aug 2026 14:43:16 +0300 Subject: [PATCH 1/2] Make Docker-specific sensitive env vars required --- docker/README.md | 15 +++++++++++++- docker/create_admin_and_community.rb | 30 ++++++++++++++++++++-------- docker/dummy.env | 3 --- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/docker/README.md b/docker/README.md index fa4dc34e8..99052f74e 100644 --- a/docker/README.md +++ b/docker/README.md @@ -42,6 +42,18 @@ Our Docker setup supports custom build configurations for the uwsgi container vi To use a custom build config, change the `CLIENT_DOCKERFILE` variable in the .env file that is automatically created by [local-setup.sh](/docker/local-setup.sh) in the project root. +### Environment + +The following lists environment variables specific to deploying QPixel via Docker: + +| Name | Value | Required? | Default | Description | +| -------------------------- | -------- | --------- | ------- | ----------------------------------------------------------------------------------- | +| `COMMUNITY_ADMIN_USERNAME` | | yes* | - | Username of the admin user on the default community. Only required on database init | +| `COMMUNITY_ADMIN_PASSWORD` | | yes* | - | Password of the admin user on the default community. Only required on database init | +| `COMMUNITY_ADMIN_EMAIL` | | yes* | - | Email of the admin user on the default community. Only required on database init | +| `COMMUNITY_NAME` | | yes* | - | Name of the default community to create. Only required on database init | +| `LOCAL_DEV_PORT` | | no | `3000` | Port or port range on the host to map the server's port `3000` in the container to | + ## 2. Database File Ensure `config/database.yml` has the username and password as defined in [docker/env](docker/env) file. The `config/database.yml` should already be gitignored. @@ -96,7 +108,8 @@ and see the interface. ![img/interface.png](../img/interface.png) -You can then click "Sign in" to login with what you defined for `$COMMUNITY_ADMIN_EMAIL` and `$COMMUNITY_ADMIN_PASSWORD`. Importantly, your password must be 6 characters or longer, otherwise the user won't be created. +You can then click "Sign in" to login with what you defined for `COMMUNITY_ADMIN_EMAIL` and `COMMUNITY_ADMIN_PASSWORD`. +Importantly, your password must be 6 characters or longer, otherwise the user won't be created. ### Custom build configs diff --git a/docker/create_admin_and_community.rb b/docker/create_admin_and_community.rb index 7c152b8e2..12abf4749 100644 --- a/docker/create_admin_and_community.rb +++ b/docker/create_admin_and_community.rb @@ -1,12 +1,26 @@ +community_name = ENV.fetch('COMMUNITY_NAME', nil) +username = ENV.fetch('COMMUNITY_ADMIN_USERNAME', nil) +password = ENV.fetch('COMMUNITY_ADMIN_PASSWORD', nil) +email = ENV.fetch('COMMUNITY_ADMIN_EMAIL', nil) +port = ENV.fetch('LOCAL_DEV_PORT', '3000') + +unless [community_name, username, password, email].all?(&:present?) + puts 'COMMUNITY_NAME is required' unless community_name.present? + puts 'COMMUNITY_ADMIN_USERNAME is required' unless username.present? + puts 'COMMUNITY_ADMIN_PASSWORD is required' unless password.present? + puts 'COMMUNITY_ADMIN_EMAIL is required' unless email.present? + exit 1 +end + # 1. Create the community -community_name = ENV['COMMUNITY_NAME'] || 'Dinosaur Community' -Community.create(name: community_name, host: "localhost:#{ENV.fetch('LOCAL_DEV_PORT', nil)}") +Community.create!(name: community_name, host: "localhost:#{port}") Rails.cache.clear # 2. Create the admin user, ensure doesn't require confirmation -username = ENV['COMMUNITY_ADMIN_USERNAME'] || 'admin' -password = ENV['COMMUNITY_ADMIN_PASSWORD'] || 'password' -email = ENV['COMMUNITY_ADMIN_EMAIL'] || 'codadict@noreply.com' - -User.create(username: username, password: password, email: email, is_global_admin: true, is_global_moderator: true, - staff: true, confirmed_at: DateTime.now) +User.create!(username: username, + password: password, + email: email, + is_global_admin: true, + is_global_moderator: true, + staff: true, + confirmed_at: DateTime.now) diff --git a/docker/dummy.env b/docker/dummy.env index 65c42be15..8a524e99a 100644 --- a/docker/dummy.env +++ b/docker/dummy.env @@ -2,6 +2,3 @@ MYSQL_ROOT_PASSWORD=qpixel MYSQL_DATABASE=qpixel MYSQL_USER=qpixel MYSQL_PASSWORD=qpixel -COMMUNITY_ADMIN_USERNAME=admin -COMMUNITY_ADMIN_PASSWORD=password -COMMUNITY_ADMIN_EMAIL=admin@noreply.com From cace201d5de06b02e89f73f87270c0dfa036408b Mon Sep 17 00:00:00 2001 From: Oleg Valter Date: Mon, 31 Aug 2026 14:48:33 +0300 Subject: [PATCH 2/2] Minor fix to Docker-specific README escaping --- docker/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docker/README.md b/docker/README.md index 99052f74e..66cf4bad7 100644 --- a/docker/README.md +++ b/docker/README.md @@ -46,13 +46,13 @@ To use a custom build config, change the `CLIENT_DOCKERFILE` variable in the .en The following lists environment variables specific to deploying QPixel via Docker: -| Name | Value | Required? | Default | Description | -| -------------------------- | -------- | --------- | ------- | ----------------------------------------------------------------------------------- | -| `COMMUNITY_ADMIN_USERNAME` | | yes* | - | Username of the admin user on the default community. Only required on database init | -| `COMMUNITY_ADMIN_PASSWORD` | | yes* | - | Password of the admin user on the default community. Only required on database init | -| `COMMUNITY_ADMIN_EMAIL` | | yes* | - | Email of the admin user on the default community. Only required on database init | -| `COMMUNITY_NAME` | | yes* | - | Name of the default community to create. Only required on database init | -| `LOCAL_DEV_PORT` | | no | `3000` | Port or port range on the host to map the server's port `3000` in the container to | +| Name | Value | Required? | Default | Description | +| -------------------------- | ---------- | --------- | ------- | ----------------------------------------------------------------------------------- | +| `COMMUNITY_ADMIN_USERNAME` | `` | yes* | - | Username of the admin user on the default community. Only required on database init | +| `COMMUNITY_ADMIN_PASSWORD` | `` | yes* | - | Password of the admin user on the default community. Only required on database init | +| `COMMUNITY_ADMIN_EMAIL` | `` | yes* | - | Email of the admin user on the default community. Only required on database init | +| `COMMUNITY_NAME` | `` | yes* | - | Name of the default community to create. Only required on database init | +| `LOCAL_DEV_PORT` | `` | no | `3000` | Port or port range on the host to map the server's port `3000` in the container to | ## 2. Database File Ensure `config/database.yml` has the username and password as defined in [docker/env](docker/env) file. The `config/database.yml` should already be gitignored.