many fixes...

This commit is contained in:
ALinuxNinja 2017-04-27 04:29:03 -04:00
parent 3ae659ec2c
commit 95d3525a4d
3 changed files with 30 additions and 12 deletions

View File

@ -9,17 +9,20 @@ RUN apt-get -y update \
RUN gem install bundler && gem install procodile
## Create user for postal
RUN useradd -r -m -d /opt/postal -s /bin/bash postal
RUN useradd -r -d /opt/postal -s /bin/bash postal
## Clone postal
RUN git clone https://github.com/atech/postal /opt/postal/app \
RUN git clone https://github.com/atech/postal /opt/postal \
&& chown -R postal:postal /opt/postal/
## Install gems required by postal
RUN /opt/postal/app/bin/postal bundle /opt/postal/app/vendor/bundle
RUN /opt/postal/bin/postal bundle /opt/postal/vendor/bundle
## Stick in startup script
ADD scripts/start.sh /start.sh
## Create docker folder for status keeping
RUN mkdir /opt/postal/docker
## Startup
CMD ["/start.sh"]

View File

@ -4,8 +4,16 @@ services:
build: .
image: postal
container_name: postal
links:
- mysql
- rabbitmq
environment:
- POSTAL_HOSTNAME=idontknow.nowhere.com
- MYSQL_ROOT_PASSWORD=changeme
- MYSQL_DATABASE=postal
- RABBITMQ_DEFAULT_USER=postal
- RABBITMQ_DEFAULT_PASS=changeme
- RABBITMQ_DEFAULT_VHOST=postal
mysql:
image: mariadb:10
container_name: postal_mysql
@ -18,4 +26,4 @@ services:
environment:
- RABBITMQ_DEFAULT_USER=postal
- RABBITMQ_DEFAULT_PASS=changeme
- RABBITMQ_DEFAULT_VHOST=postal
- RABBITMQ_DEFAULT_VHOST=/postal

View File

@ -2,7 +2,7 @@
## Generate keys if they do not exist
if [[ ! -f /opt/postal/config/signing.key ]]; then
/opt/postal/app/bin/postal initialize-config
/opt/postal/bin/postal initialize-config
fi
## Set Hostname
@ -12,17 +12,24 @@ sed -i "s/postal\.example\.com/$POSTAL_HOSTNAME/" /opt/postal/config/postal.yml
### MySQL Main DB
sed -i -e '/main_db:/!b' -e ':a' -e "s/host.*/host: mysql/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
sed -i -e'/main_db:/!b' -e ':a' -e "s/username.*/username: root/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
sed -i -e'/main_db:/!b' -e ':a' -e "s/password.*/password: <%= ENV['MYSQL_ROOT_PASSWORD'] %>/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
sed -i -e'/main_db:/!b' -e ':a' -e "s/database.*/database: <%= ENV['MYSQL_DATABASE'] %>/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
sed -i -e'/main_db:/!b' -e ':a' -e "s/password.*/password: $MYSQL_ROOT_PASSWORD/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
sed -i -e'/main_db:/!b' -e ':a' -e "s/database.*/database: $MYSQL_DATABASE/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
### MySQL Message DB
sed -i -e '/message_db:/!b' -e ':a' -e "s/host.*/host: mysql/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
sed -i -e'/message_db:/!b' -e ':a' -e "s/username.*/username: root/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
sed -i -e'/message_db:/!b' -e ':a' -e "s/password.*/password: <%= ENV['MYSQL_ROOT_PASSWORD'] %>/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
sed -i -e'/message_db:/!b' -e ':a' -e "s/password.*/password: $MYSQL_ROOT_PASSWORD/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
### RabbitMQ
sed -i -e '/rabbitmq:/!b' -e ':a' -e "s/host.*/host: rabbitmq/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
sed -i -e '/rabbitmq:/!b' -e ':a' -e "s/username.*/username: <%= ENV['RABBITMQ_DEFAULT_USER'] %>/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
sed -i -e '/rabbitmq:/!b' -e ':a' -e "s/password.*/password: <%= ENV['RABBITMQ_DEFAULT_PASS'] %>/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
sed -i -e '/rabbitmq:/!b' -e ':a' -e "s/vhost.*/vhost: \/<%= ENV['RABBITMQ_DEFAULT_VHOST'] %>/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
sed -i -e '/rabbitmq:/!b' -e ':a' -e "s/username.*/username: $RABBITMQ_DEFAULT_USER/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
sed -i -e '/rabbitmq:/!b' -e ':a' -e "s/password.*/password: $RABBITMQ_DEFAULT_PASS/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
sed -i -e '/rabbitmq:/!b' -e ':a' -e "s/vhost.*/vhost: \/$RABBITMQ_DEFAULT_VHOST/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml
### Initialize DB
if [[ ! -f /opt/postal/docker/postal_initialized ]]; then
/opt/postal/bin/postal initialize && touch /opt/postal/docker/postal_initialized
fi
## Clean Up
rm -r /opt/postal/tmp/pids
## Run
/opt/postal/app/bin/postal run
/opt/postal/bin/postal run