update entrypoint system

This commit is contained in:
ILoveYaToo 2020-04-17 00:14:17 -04:00
parent 40b192877f
commit 6b59762ddc
3 changed files with 44 additions and 18 deletions

View File

@ -44,7 +44,7 @@ test-docker-alpine:
- cd alpine
- docker load -i postal-alpine-container.tar
- docker-compose up -d
- docker-compose run postal initialize
- for i in {1..10}; do [ $(docker inspect postal | jq '.[].State.Health.Status') == "healthy" ] && break || sleep 30; done
after_script:
- cd alpine
- docker-compose rm -sfv

View File

@ -19,6 +19,15 @@ services:
- RABBITMQ_DEFAULT_USER=postal
- RABBITMQ_DEFAULT_PASS=changeme
- RABBITMQ_DEFAULT_VHOST=postal
- POSTAL_FNAME=Sia
- POSTAL_LNAME=Cat
- POSTAL_PASSWORD=SecretCatPassword
- POSTAL_EMAIL=myemail@catsworld.com
healthcheck:
test: curl -sS http://127.0.0.1:5000 || exit 1
interval: 5s
timeout: 10s
retries: 3
mysql:
image: mariadb:10
container_name: postal_mysql

View File

@ -1,25 +1,42 @@
#!/bin/bash
## Generate config
if [ ! -f /opt/postal/config/postal.yml ] || [[ $(cat /opt/postal/config/postal.yml | wc -l) < 2 ]]; then
## Build Jinja2 Template
p2 -t /templates/postal.example.yml.j2 -o /opt/postal/config/postal.example.yml
## Add in secret key building
echo "rails:" >> /opt/postal/config/postal.example.yml
echo " secret_key: {{secretkey}}" >> /opt/postal/config/postal.example.yml
## Generate config and keys
/opt/postal/bin/postal initialize-config
fi
cat /opt/postal/config/postal.yml
## Clean Up
rm -rf /opt/postal/tmp/pids/*
rm -rf /tmp/postal
## Wait for MySQL to start up
echo "== Waiting for MySQL to start up =="
while ! mysqladmin ping -h mysql --silent; do
sleep 0.5
done
## Generate config
if [ ! -f /opt/postal/config/postal.yml ] || [[ $(cat /opt/postal/config/postal.yml | wc -l) < 2 ]]; then
## Build Jinja2 Template
p2 -t /templates/postal.example.yml.j2 -o /opt/postal/config/postal.example.yml
## Add in secret key building
echo "rails:" >> /opt/postal/config/postal.example.yml
echo " secret_key: {{secretkey}}" >> /opt/postal/config/postal.example.yml
## Generate config and keys
/opt/postal/bin/postal initialize-config
## Wait for MySQL to start up
echo "== Waiting for MySQL to start up =="
while ! mysqladmin ping -h mysql --silent; do
sleep 0.5
done
while ! mysql -hmysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "use $MYSQL_DATABASE" 2> /dev/null; do
sleep 0.5
done
/opt/postal/bin/postal initialize
/opt/postal/bin/postal make-user <<-EOF
$POSTAL_EMAIL
$POSTAL_FNAME
$POSTAL_LNAME
$POSTAL_PASSWORD
EOF
else
## Wait for MySQL to start up
echo "== Waiting for MySQL to start up =="
while ! mysqladmin ping -h mysql --silent; do
sleep 0.5
done
while ! mysql -hmysql -u root -p"$MYSQL_ROOT_PASSWORD" -e "use $MYSQL_DATABASE" 2> /dev/null; do
sleep 0.5
done
fi
## Start Postal
/opt/postal/bin/postal "$@"