Initial commit

This commit is contained in:
2025-03-04 20:58:17 +02:00
parent ef2e780434
commit 09db1a8d08
13 changed files with 939 additions and 0 deletions

20
docker/snibox/.env Normal file
View File

@@ -0,0 +1,20 @@
# Secrets
SECRET_KEY_BASE=580b4894107e15810dd7100132ad18905d3b218bea2812a6c35662e783443c912f8454c479afcf5aaf4fdac0fa0c52308ef062a440f5360cf9161f2b1d9e0834
# SSL
FORCE_SSL=false
# Database
DB_NAME=snibox
DB_USER=snibox
DB_PASS=snibox
DB_HOST=10.0.6.178
DB_PORT=5432
# Mailgun. Required by 'Reset password feature'. Feel free to start without this setup.
MAILGUN_SMTP_PORT=587
MAILGUN_SMTP_SERVER=smtp.eu.mailgun.org
MAILGUN_SMTP_LOGIN=sender@mail.gurulandia.eu
MAILGUN_SMTP_PASSWORD=fd2481f27f76e35110ddf9b7b04ad09f-667818f5-87cb2de
MAILGUN_API_KEY=0bbddf40b4f522902c3566ac64d6843f-667818f5-f7e29b98
MAILGUN_DOMAIN=mail.gurulandia.eu
MAILGUN_PUBLIC_KEY=pubkey-1d7092746ca1272cb49c7c16615663d1

View File

@@ -0,0 +1,41 @@
services:
frontend:
image: snibox/nginx-puma:1.15.9
ports:
- "8000:80"
volumes:
- static-files:/var/www/html
depends_on:
- backend
backend:
image: snibox/snibox:latest
command: sh -c "rm -rf tmp/pids && ./bin/rails s -p 3000 -b '0.0.0.0'"
environment:
DB_NAME: "${DB_NAME}"
DB_USER: "${DB_USER}"
DB_PASS: "${DB_PASS}"
DB_HOST: "${DB_HOST}"
DB_PORT: "${DB_PORT}"
FORCE_SSL: "${FORCE_SSL}"
MAILGUN_SMTP_PORT: "${MAILGUN_SMTP_PORT}"
MAILGUN_SMTP_SERVER: "${MAILGUN_SMTP_SERVER}"
MAILGUN_SMTP_LOGIN: "${MAILGUN_SMTP_LOGIN}"
MAILGUN_SMTP_PASSWORD: "${MAILGUN_SMTP_PASSWORD}"
MAILGUN_API_KEY: "${MAILGUN_API_KEY}"
MAILGUN_DOMAIN: "${MAILGUN_DOMAIN}"
MAILGUN_PUBLIC_KEY: "${MAILGUN_PUBLIC_KEY}"
SECRET_KEY_BASE: "${SECRET_KEY_BASE}"
volumes:
- static-files:/app/public
# depends_on:
# - database
# database:
# image: postgres:10.7-alpine
# volumes:
# - pg-data:/var/lib/postgresql/data
volumes:
# pg-data:
static-files:

56
docker/snibox/setup Executable file
View File

@@ -0,0 +1,56 @@
#!/bin/bash
set -e
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m'
DEFAULT_SECRET='paste_your_key'
function report_status() {
if [ $? -eq 0 ]
then
echo -e "${GREEN}Done${NC}"
else
echo -e "${RED}Unable to complete task${NC}"
exit 1
fi
}
echo -e "Copy .env.sample to .env:"
if [ ! -f .env ]
then
cp .env.sample .env
report_status
else
echo -e "${GREEN}File .env already exists${NC}"
fi
echo -e "\nPull images:"
docker compose pull
report_status
echo -e "\nInject secret key:"
if grep -Rq "$DEFAULT_SECRET" .env
then
secret=$(docker compose run --rm --no-deps backend ./bin/rake secret)
echo "$secret"
# based on https://stackoverflow.com/a/22084103
sed -i.bak "s/$DEFAULT_SECRET/$secret/" .env
rm .env.bak
report_status
else
echo -e "${GREEN}Personal secret key exists${NC}"
fi
echo -e "\nCreate database:"
docker compose run --rm backend ./bin/rake db:create
report_status
echo -e "\nRun migrations:"
docker compose run --rm backend ./bin/rake db:migrate
report_status
echo -e "\n${GREEN}Setup completed!${NC}"