Move to circleci + more reliable formating
This commit is contained in:
parent
b42749fbb7
commit
a7ef0fe512
22
.circleci/config.yml
Normal file
22
.circleci/config.yml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
version: 2
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
machine: true
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run: docker build -t postal:latest .
|
||||||
|
workflows:
|
||||||
|
version: 2
|
||||||
|
nightly:
|
||||||
|
triggers:
|
||||||
|
- schedule:
|
||||||
|
cron: "0 * * * *"
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
jobs:
|
||||||
|
- build
|
||||||
|
commit:
|
||||||
|
jobs:
|
||||||
|
- build
|
18
Dockerfile
18
Dockerfile
|
@ -1,23 +1,25 @@
|
||||||
FROM ruby:2.4
|
FROM ruby:2.4
|
||||||
|
|
||||||
## Clone postal
|
|
||||||
COPY src /opt/postal
|
|
||||||
|
|
||||||
RUN apt-get -y update \
|
RUN apt-get -y update \
|
||||||
&& apt-get -y install nodejs mysql-client \
|
&& apt-get -y install nodejs mysql-client git-core python-minimal python-pip python-dev libcap2-bin \
|
||||||
|
&& pip install j2cli \
|
||||||
|
&& git clone https://github.com/atech/postal.git /opt/postal \
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
&& gem install bundler \
|
&& gem install bundler \
|
||||||
&& gem install procodile \
|
&& gem install procodile \
|
||||||
&& useradd -r -d /opt/postal -s /bin/bash postal \
|
&& useradd -r -d /opt/postal -s /bin/bash postal \
|
||||||
&& chown -R postal:postal /opt/postal/ \
|
&& chown -R postal:postal /opt/postal/ \
|
||||||
&& /opt/postal/bin/postal bundle /opt/postal/vendor/bundle \
|
&& /opt/postal/bin/postal bundle /opt/postal/vendor/bundle
|
||||||
&& mv /opt/postal/config /opt/postal/config-original
|
|
||||||
|
## Adjust permissions
|
||||||
|
RUN setcap 'cap_net_bind_service=+ep' /usr/local/bin/ruby
|
||||||
|
|
||||||
## Stick in required files
|
## Stick in required files
|
||||||
ADD wrapper.sh /wrapper.sh
|
ADD src/docker-entrypoint.sh /docker-entrypoint.sh
|
||||||
|
ADD src/templates /templates
|
||||||
|
|
||||||
## Expose
|
## Expose
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
## Startup
|
## Startup
|
||||||
ENTRYPOINT ["/bin/bash", "-c", "/wrapper.sh ${*}", "--"]
|
ENTRYPOINT ["/bin/bash", "-c", "/docker-entrypoint.sh ${*}", "--"]
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Tue Sep 12 12:00:06 EDT 2017
|
|
|
@ -1,4 +0,0 @@
|
||||||
app:
|
|
||||||
build:
|
|
||||||
image: alinuxninja/postal
|
|
||||||
dockerfile: Dockerfile
|
|
|
@ -1,7 +0,0 @@
|
||||||
- service: app
|
|
||||||
type: push
|
|
||||||
image_name: alinuxninja/postal
|
|
||||||
registry: https://index.docker.io/v1/
|
|
||||||
encrypted_dockercfg_path: dockercfg.encrypted
|
|
||||||
tag: master
|
|
||||||
image_tag: latest
|
|
|
@ -1 +0,0 @@
|
||||||
do3fXlgx/znajtHioPJFLQ4biXCFLSZDnt3jzf02HdAEUJIAJIwSojMOl0wCiKDYlnWN75KxixTLPN8Acvb0VjeRsxYKHp5zR1We2eNFbyxPxFRvCra1FFrJ+B6fSK3HfwkRdPyxIMWnxKMsX//OzbwEQDbDHhh8hwzfHBsgaYaYeHFGzoSMD8F4PU8jnlLUY/2nyIvoj/k2aTLqUJkarJg8umKzJ/nNehLAeOoGXf7Mln7pVmJFfUeafesemgY=
|
|
23
nginx.conf
23
nginx.conf
|
@ -1,23 +0,0 @@
|
||||||
server {
|
|
||||||
listen 80;
|
|
||||||
|
|
||||||
root /opt/postal/public;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
client_max_body_size 50M;
|
|
||||||
try_files $uri $uri/index.html $uri.html @puma;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /assets {
|
|
||||||
add_header Cache-Control max-age=3600;
|
|
||||||
}
|
|
||||||
|
|
||||||
location @puma {
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
|
||||||
proxy_pass http://postal:5000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
24
src/docker-entrypoint.sh
Executable file
24
src/docker-entrypoint.sh
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
## Generate config
|
||||||
|
if [ ! -f /opt/postal/config/postal.yml ] || [[ $(cat /opt/postal/config/postal.yml | wc -l) < 2 ]]; then
|
||||||
|
## Build Jinja2 Template
|
||||||
|
j2 /templates/postal.example.yml.j2 > /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
|
||||||
|
|
||||||
|
## Clean Up
|
||||||
|
rm -rf /opt/postal/tmp/pids/*
|
||||||
|
|
||||||
|
## Wait for MySQL to start up
|
||||||
|
echo "== Waiting for MySQL to start up =="
|
||||||
|
while ! mysqladmin ping -h mysql --silent; do
|
||||||
|
sleep 0.5
|
||||||
|
done
|
||||||
|
|
||||||
|
## Start Postal
|
||||||
|
/opt/postal/bin/postal "$@"
|
66
src/templates/postal.example.yml.j2
Normal file
66
src/templates/postal.example.yml.j2
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
web_server:
|
||||||
|
bind_address: 0.0.0.0
|
||||||
|
port: 5000
|
||||||
|
max_threads: 5
|
||||||
|
|
||||||
|
web:
|
||||||
|
# The host that the management interface will be available on
|
||||||
|
host: postal.example.com
|
||||||
|
# The protocol that requests to the management interface should happen on
|
||||||
|
protocol: https
|
||||||
|
|
||||||
|
fast_server:
|
||||||
|
# This can be enabled to enable click & open tracking on emails. It is disabled by
|
||||||
|
# default as it requires a separate static IP address on your server.
|
||||||
|
enabled: false
|
||||||
|
bind_address:
|
||||||
|
|
||||||
|
general:
|
||||||
|
# This can be changed to allow messages to be sent from multiple IP addresses
|
||||||
|
use_ip_pools: false
|
||||||
|
|
||||||
|
main_db:
|
||||||
|
# Specify the connection details for your MySQL database
|
||||||
|
host: mysql
|
||||||
|
username: root
|
||||||
|
password: {{ MYSQL_ROOT_PASSWORD }}
|
||||||
|
database: {{ MYSQL_DATABASE }}
|
||||||
|
|
||||||
|
message_db:
|
||||||
|
# Specify the connection details for your MySQL server that will be house the
|
||||||
|
# message databases for mail servers.
|
||||||
|
host: mysql
|
||||||
|
username: root
|
||||||
|
password: {{ MYSQL_ROOT_PASSWORD }}
|
||||||
|
prefix: postal
|
||||||
|
|
||||||
|
rabbitmq:
|
||||||
|
# Specify the connection details for your RabbitMQ server.
|
||||||
|
host: rabbitmq
|
||||||
|
username: {{ RABBITMQ_DEFAULT_USER }}
|
||||||
|
password: {{ RABBITMQ_DEFAULT_PASS }}
|
||||||
|
vhost: /{{ RABBITMQ_DEFAULT_VHOST }}
|
||||||
|
|
||||||
|
dns:
|
||||||
|
# Specifies the DNS record that you have configured. Refer to the documentation at
|
||||||
|
# https://github.com/atech/postal/wiki/Domains-&-DNS-Configuration for further
|
||||||
|
# information about these.
|
||||||
|
mx_records:
|
||||||
|
- mx.postal.example.com
|
||||||
|
smtp_server_hostname: postal.example.com
|
||||||
|
spf_include: spf.postal.example.com
|
||||||
|
return_path: rp.postal.example.com
|
||||||
|
route_domain: routes.postal.example.com
|
||||||
|
track_domain: track.postal.example.com
|
||||||
|
|
||||||
|
smtp:
|
||||||
|
# Specify an SMTP server that can be used to send messages from the Postal management
|
||||||
|
# system to users. You can configure this to use a Postal mail server once the
|
||||||
|
# your installation has been set up.
|
||||||
|
host: 127.0.0.1
|
||||||
|
port: 2525
|
||||||
|
username: # Complete when Postal is running and you can
|
||||||
|
password: # generate the credentials within the interface.
|
||||||
|
from_name: Postal
|
||||||
|
from_address: postal@yourdomain.com
|
||||||
|
|
42
wrapper.sh
42
wrapper.sh
|
@ -1,42 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
## Refresh config
|
|
||||||
cp -R /opt/postal/config-original/* /opt/postal/config
|
|
||||||
|
|
||||||
## Generate keys
|
|
||||||
/opt/postal/bin/postal initialize-config
|
|
||||||
|
|
||||||
if [[ $(cat /opt/postal/config/postal.yml| grep -i web_server |wc -l) == 0 ]]; then
|
|
||||||
cat >> /opt/postal/config/postal.yml << EOF
|
|
||||||
web_server:
|
|
||||||
bind_address: 0.0.0.0
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
|
|
||||||
## Set MySQL/RabbitMQ usernames/passwords
|
|
||||||
### 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: $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: $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: $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
|
|
||||||
|
|
||||||
## Clean Up
|
|
||||||
rm -rf /opt/postal/tmp/pids/*
|
|
||||||
|
|
||||||
## Wait for MySQL to start up
|
|
||||||
echo "== Waiting for MySQL to start up =="
|
|
||||||
while ! mysqladmin ping -h mysql --silent; do
|
|
||||||
sleep 0.5
|
|
||||||
done
|
|
||||||
|
|
||||||
## Start Postal
|
|
||||||
/opt/postal/bin/postal "$@"
|
|
Loading…
Reference in New Issue
Block a user