Skip to content

Instantly share code, notes, and snippets.

@andyshinn
Last active August 8, 2023 08:39
Show Gist options
  • Star 45 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save andyshinn/439790630a6a8040fda4100f954d829f to your computer and use it in GitHub Desktop.
Save andyshinn/439790630a6a8040fda4100f954d829f to your computer and use it in GitHub Desktop.
Postal on Docker
version: '2'
services:
web:
build: .
volumes:
- config:/opt/postal/config
- assets:/usr/src/app/public/assets
command: bundle exec puma -C config/puma.rb
links:
- mysql
ports:
- "5000:5000"
environment:
RAILS_SERVE_STATIC_FILES: "true"
fast:
build: .
volumes:
- config:/opt/postal/config
command: bundle exec rake postal:fast_server
worker:
build: .
volumes:
- config:/opt/postal/config
command: bundle exec rake postal:worker
links:
- rabbitmq
cron:
build: .
volumes:
- config:/opt/postal/config
command: bundle exec rake postal:cron
smtp:
build: .
volumes:
- config:/opt/postal/config
command: bundle exec rake postal:smtp_server
requeuer:
build: .
volumes:
- config:/opt/postal/config
command: bundle exec rake postal:requeuer
links:
- mysql
mysql:
build:
context: .
dockerfile: Dockerfile-mysql
environment:
MYSQL_DATABASE: postal
MYSQL_USER: postal
MYSQL_PASSWORD: p0st4l
MYSQL_ROOT_PASSWORD: p0st4lr00t
volumes:
- mysql:/var/lib/mysql
rabbitmq:
image: "rabbitmq:3-management"
environment:
RABBITMQ_ERLANG_COOKIE: "PHIOCHASOUQUIAXUFIETH"
RABBITMQ_DEFAULT_USER: "postal"
RABBITMQ_DEFAULT_PASS: "p0st4l"
RABBITMQ_DEFAULT_VHOST: "postal"
ports:
- "15672:15672"
- "5672:5672"
volumes:
config:
mysql:
assets:
FROM ruby:2.3-onbuild
VOLUME /opt/postal/config
ENV LOG_TO_STDOUT 1
ENV AM_CONFIG_ROOT /opt/postal/config
RUN gem install procodile
RUN apt-get update -qq && apt-get install -yqq nodejs
FROM mysql:5.6
COPY grants.sql /docker-entrypoint-initdb.d/grants.sql
GRANT ALL PRIVILEGES ON `postal-%` . * to `postal`@`%` IDENTIFIED BY "p0st4l";
  1. Clone the Postal git repository and place the files from this gist in the root folder.
  2. docker-compose build
  3. docker-compose up -d mysql
  4. docker-compose run web bin/postal initialize-config
  5. docker run -it -v postal_config:/opt/postal/config alpine vi /opt/postal/config/postal.yml
  6. See the attached postal.yml for the correct message_db, main_db, and rabbitmq settings and make the necessary edits.
  7. docker-compose run web bin/postal initialize
  8. docker-compose up

App should be running at http://<your_docker_host_ip>:5000/.

web:
host: postal.example.com
protocol: https
web_server:
bind_address: 0.0.0.0
port: 5000
max_threads: 5
fast_server:
bind_address: 0.0.0.0
port: 5010
ssl_port: 5011
proxy_protocol: false
general:
use_ip_pools: false
exception_url: null
logging:
stdout: false
max_log_file_size: 20
max_log_files: 10
main_db:
host: mysql
port: 3306
username: postal
password: p0st4l
database: postal
message_db:
host: mysql
port: 3306
username: postal
password: p0st4l
prefix: postal
rabbitmq:
host: rabbitmq
port: 5672
username: postal
password: p0st4l
vhost: postal
smtp_server:
proxy_protocol: false
log_connect: true
evented: true
ports:
- 2525
dns:
mx_records:
- mx1.example.com
- mx2.example.com
smtp_server_hostname: smtp.example.com
spf_include: spf.example.com
return_path: rp.example.com
route_domain: routes.example.com
track_domain: track.example.com
dkim_identifier: postal
domain_verify_prefix: postal-verification
custom_return_path_prefix: psrp
smtp:
host: smtp.blah
port: 2525
username:
password:
from_name: Postal
from_address: postal@yourdomain.com
espect:
hosts:
- http://espect01.infra.atech.io
rails:
environment: production
secret_key: 38a0c8c838859b5f94cad8036060235665e3b0aa8365ba0ebfa14e9a07b27feba07c183afdb1aafea4ff755a1649ab4d73799d5ae7bb78241cf0786537f4563a4d953e5918a3f0fd896ddd6b2460943ceeb39884206587ba2f1d4cf1214a5ac8475b77efb5b178951bb8bdecbe2bf8b7d45200e837cedea9b2ddf951d46175f9
Copy link

ghost commented Aug 25, 2018

Impressive, what would be the next steps to run it on Kubernetes?

@ericlaflamme
Copy link

Hi there, thanks for that. Very cool to get up and running fast like this. FYI, I had to do this in Dockerfile:
FROM ruby:2.3-onbuild VOLUME /opt/postal/config ENV LOG_TO_STDOUT 1 ENV AM_CONFIG_ROOT /opt/postal/config ENV POSTAL_CONFIG_ROOT /opt/postal/config RUN gem install procodile RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \ && apt-get install -y nodejs

  1. Config_root was defaulting to /usr/src.... look in code and was looking for POSTAL_CONFIG_ROOT
  2. And the apt-get install nodejs, erroring at assets creation:
    I, [2018-11-26T15:48:46.007117 #17] INFO -- : Writing /usr/src/app/public/assets/application/application-602ea59ead8408bdd66cbed4dc0d71c02bb8df0fe63aa700ac397a69ff29c17a.js I, [2018-11-26T15:48:46.008862 #17] INFO -- : Writing /usr/src/app/public/assets/application/application-602ea59ead8408bdd66cbed4dc0d71c02bb8df0fe63aa700ac397a69ff29c17a.js.gz rake aborted! Autoprefixer doesn’t support Node v4.8.2. Update it.

I don't really understand why this changes work technically, so not sure it's the best way to solve those problems. Hope it help you. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment