Compare commits

...

12 Commits

Author SHA1 Message Date
decentral1se 2ca92dd55f
fix: drop golang templatin'
continuous-integration/drone/push Build is passing Details
2024-03-28 22:40:46 +01:00
3wc 080fcd7a2d chore: publish 1.1.9+v4.0.15-hometown-1.1.1 release
continuous-integration/drone/push Build is passing Details
2024-03-27 01:30:10 -03:00
3wc 556d73cce8 Further startup fix
continuous-integration/drone/push Build is passing Details
2024-03-27 01:26:42 -03:00
3wc f6c2527182 Run migrations during app startup
continuous-integration/drone/push Build is passing Details
2024-03-27 00:55:00 -03:00
3wc 953faaca83 chore: publish 1.1.8+v4.0.15-hometown-1.1.1 release
continuous-integration/drone/push Build is passing Details
2024-02-16 18:57:41 -03:00
knoflook 547cefbd19 chore: publish 1.1.7+v4.0.14-hometown-1.1.1 release
continuous-integration/drone/push Build is passing Details
2024-02-15 16:14:49 +01:00
Nick Sellen 91ed3cf439
chore: publish 1.1.6+v4.0.13-hometown-1.1.1 release
continuous-integration/drone/push Build is passing Details
2024-02-12 22:18:27 +00:00
Nick Sellen 6f31be3458
Bump ENTRYPOINT_CONF_VERSION 2024-02-12 22:16:14 +00:00
3wc 4e8ae43423 chore: publish 1.1.5+v4.0.13-hometown-1.1.1 release
continuous-integration/drone/push Build is passing Details
2024-02-01 20:31:28 -03:00
3wc 2e46a01082 chore: publish 1.1.4+v4.0.10-hometown-1.1.1 release
continuous-integration/drone/push Build is passing Details
2024-01-11 21:33:16 -03:00
3wc 1155b3cc50 Improve abra.sh and use DB_PASS_FILE 2024-01-11 21:32:36 -03:00
3wordchant 66adadea97 Merge pull request 'Add missing S3_ vars' (#19) from add/missing-s3-vars into main
continuous-integration/drone/push Build is passing Details
Reviewed-on: #19
2023-10-31 22:11:54 +00:00
4 changed files with 90 additions and 68 deletions

View File

@ -1,6 +1,6 @@
TYPE=hometown
DOMAIN={{ .Domain }}
DOMAIN=hometown.example.com
# Enables WEB_DOMAIN if set (FOR FUTURE USE)
# USER_DOMAIN=

138
abra.sh
View File

@ -1,70 +1,92 @@
#!/bin/bash
export ENTRYPOINT_CONF_VERSION=v7
export ENTRYPOINT_CONF_VERSION=v8
assets() {
export OTP_SECRET=$(cat /run/secrets/otp_secret)
export SECRET_KEY_BASE=$(cat /run/secrets/secret_key_base)
export DB_PASS=$(cat /run/secrets/db_password)
file_env() {
local var="$1"
local fileVar="${var}_FILE"
local def="${2:-}"
RAILS_ENV=production bundle exec rails assets:precompile
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
exit 1
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
declare -x -g "$var"="$val"
unset "$fileVar"
}
setup() {
export OTP_SECRET=$(cat /run/secrets/otp_secret)
export SECRET_KEY_BASE=$(cat /run/secrets/secret_key_base)
export DB_PASS=$(cat /run/secrets/db_password)
environment() {
# for sidekiq service bundle exec env var threading
file_env "OTP_SECRET"
file_env "SECRET_KEY_BASE"
file_env "DB_PASS"
file_env "SMTP_PASSWORD"
file_env "VAPID_PRIVATE_KEY"
RAILS_ENV=production bundle exec rake db:setup
declare -x RAILS_ENV=production
}
admin() {
export OTP_SECRET=$(cat /run/secrets/otp_secret)
export SECRET_KEY_BASE=$(cat /run/secrets/secret_key_base)
export DB_PASS=$(cat /run/secrets/db_password)
RAILS_ENV=production bin/tootctl accounts create "$1" --email "$2" --confirmed --role admin
setup_admin() {
## Create an admin user
environment
accounts create "$1" --email "$2" --confirmed --role admin
}
secrets() {
docker context use default > /dev/null 2>&1
echo "Generating secrets for new Hometown deployment..."
echo ""
SECRET_KEY_BASE=$(docker run --rm tootsuite/mastodon:v3.4.0 bundle exec rake secret)
abra app secret insert "$APP_NAME" secret_key_base v1 "$SECRET_KEY_BASE"
echo "SECRET_KEY_BASE = $SECRET_KEY_BASE"
echo ""
OTP_SECRET=$(docker run --rm tootsuite/mastodon:v3.4.0 bundle exec rake secret)
abra app secret insert "$APP_NAME" otp_secret v1 "$OTP_SECRET"
echo "OTP_SECRET = $OTP_SECRET"
echo ""
docker run \
-e SECRET_KEY_BASE="$SECRET_KEY_BASE" \
-e OTP_SECRET="$OTP_SECRET" \
--rm tootsuite/mastodon:v3.4.0 \
bundle exec rake mastodon:webpush:generate_vapid_key \
> /tmp/key.txt
VAPID_PRIVATE_KEY=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "/tmp/key.txt")
VAPID_PUBLIC_KEY=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "/tmp/key.txt")
rm -rf /tmp/key.txt
echo "VAPID_PUBLIC_KEY = $VAPID_PUBLIC_KEY"
echo "!IMPORTANT! you MUST insert this VAPID_PUBLIC_KEY into your app .env config !IMPORTANT!"
echo ""
abra app secret insert "$APP_NAME" vapid_private_key v1 "$VAPID_PRIVATE_KEY"
echo "VAPID_PRIVATE_KEY = $VAPID_PRIVATE_KEY"
echo ""
abra app secret generate "$APP_NAME" db_password v1
echo ""
echo "don't forget to insert your smtp_password! your deployment won't work without it"
echo "run \"abra app secret insert $APP_NAME smtp_password v1 YOURSMTPPASSWORD\""
echo ""
shell() {
## Run a shell with proper environment
environment
bash $@
}
generate_secrets() {
## Run `abra app cmd -l <yourdomain> generate_secrets` to use Docker to generate secrets you'll need to deploy
## your new instance (and create the secrets on target app).
docker context use default > /dev/null 2>&1
echo "Generating secrets for new Hometown deployment..."
echo ""
SECRET_KEY_BASE=$(docker run --rm tootsuite/mastodon:v4.2.0 bundle exec rake secret)
abra app secret insert "$APP_NAME" secret_key_base v1 "$SECRET_KEY_BASE"
echo "SECRET_KEY_BASE = $SECRET_KEY_BASE"
echo ""
OTP_SECRET=$(docker run --rm tootsuite/mastodon:v4.2.0 bundle exec rake secret)
abra app secret insert "$APP_NAME" otp_secret v1 "$OTP_SECRET"
echo "OTP_SECRET = $OTP_SECRET"
echo ""
docker run \
-e SECRET_KEY_BASE="$SECRET_KEY_BASE" \
-e OTP_SECRET="$OTP_SECRET" \
--rm tootsuite/mastodon:v3.4.0 \
bundle exec rake mastodon:webpush:generate_vapid_key \
> /tmp/key.txt
VAPID_PRIVATE_KEY=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "/tmp/key.txt")
VAPID_PUBLIC_KEY=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "/tmp/key.txt")
rm -rf /tmp/key.txt
echo "VAPID_PUBLIC_KEY = $VAPID_PUBLIC_KEY"
echo "!IMPORTANT! you MUST insert this VAPID_PUBLIC_KEY into your app .env config !IMPORTANT!"
echo ""
abra app secret insert "$APP_NAME" vapid_private_key v1 "$VAPID_PRIVATE_KEY"
echo "VAPID_PRIVATE_KEY = $VAPID_PRIVATE_KEY"
echo ""
abra app secret generate "$APP_NAME" db_password v1
echo ""
echo "don't forget to insert your smtp_password! your deployment won't work without it"
echo "run \"abra app secret insert $APP_NAME smtp_password v1 YOURSMTPPASSWORD\""
echo ""
}

View File

@ -3,8 +3,8 @@ version: "3.8"
services:
app:
image: git.coopcloud.tech/coop-cloud-chaos-patchs/hometown:v4.0.10-hometown-1.1.1
command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000"
image: git.coopcloud.tech/coop-cloud-chaos-patchs/hometown:v4.0.15-hometown-1.1.1
command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rake db:migrate; bundle exec rails s -p 3000"
networks: &bothNetworks
- proxy
- internal_network
@ -19,7 +19,7 @@ services:
- "traefik.http.routers.${STACK_NAME}_web.rule=Host(`${DOMAIN}`)"
- "traefik.http.routers.${STACK_NAME}_web.entrypoints=web-secure"
- "traefik.http.routers.${STACK_NAME}_web.tls.certresolver=${LETS_ENCRYPT_ENV}"
- "coop-cloud.${STACK_NAME}.version=1.1.3+v4.0.10-hometown-1.1.1"
- "coop-cloud.${STACK_NAME}.version=1.1.9+v4.0.15-hometown-1.1.1"
configs: &configs
- source: entrypoint_sh
target: /usr/local/bin/entrypoint.sh
@ -45,6 +45,7 @@ services:
- DB_NAME
- DB_PORT
- DB_USER
- DB_PASS_FILE=/run/secrets/db_password
- DEFAULT_LOCALE
- DISALLOW_UNAUTHENTICATED_API_ACCESS
- EMAIL_DOMAIN_ALLOWLIST
@ -142,7 +143,7 @@ services:
- WEB_DOMAIN
streaming:
image: git.coopcloud.tech/coop-cloud-chaos-patchs/hometown:v4.0.10-hometown-1.1.1
image: git.coopcloud.tech/coop-cloud-chaos-patchs/hometown:v4.0.15-hometown-1.1.1
command: node ./streaming
configs: *configs
entrypoint: *entrypoint
@ -163,7 +164,7 @@ services:
volumes: *appVolume # used to make sure this volume is created
sidekiq:
image: git.coopcloud.tech/coop-cloud-chaos-patchs/hometown:v4.0.10-hometown-1.1.1
image: git.coopcloud.tech/coop-cloud-chaos-patchs/hometown:v4.0.15-hometown-1.1.1
secrets: *secrets
command: bundle exec sidekiq
configs: *configs
@ -177,7 +178,7 @@ services:
environment: *env
db:
image: postgres:14.5-alpine
image: postgres:14.10-alpine
networks: &internalNetwork
- internal_network
volumes:
@ -190,7 +191,7 @@ services:
- POSTGRES_USER=${DB_USER}
redis:
image: redis:7.0-alpine
image: redis:7.2-alpine
networks: *internalNetwork
healthcheck:
test: ["CMD", "redis-cli", "ping"]

View File

@ -23,9 +23,8 @@ file_env() {
unset "$fileVar"
}
export DB_PASS=$(cat /run/secrets/db_password)
# for sidekiq service bundle exec env var threading
file_env "DB_PASS"
file_env "OTP_SECRET"
file_env "SECRET_KEY_BASE"
file_env "SMTP_PASSWORD"