Skip to content

Instantly share code, notes, and snippets.

@chrisdone
Created October 22, 2019 14:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdone/bba2f8562ef58f1eed99081835ddf77e to your computer and use it in GitHub Desktop.
Save chrisdone/bba2f8562ef58f1eed99081835ddf77e to your computer and use it in GitHub Desktop.
Spinning up Duta mail server on DigitalOcean with docker-machine and docker-compose

Change the mx.chrisdone.com mentions to your own domain.

Spin up a Droplet on DigitalOcean with docker-machine.

$ time docker-machine create \
  --driver digitalocean \
  --digitalocean-access-token $(cat ~/.do-token) \
  --digitalocean-monitoring \
  --digitalocean-region "lon1" \
  --digitalocean-size "s-1vcpu-1gb" \
  chrisdonemx
Running pre-create checks...
Creating machine...
(chrisdonemx) Creating SSH key...
(chrisdonemx) Creating Digital Ocean droplet...
(chrisdonemx) Waiting for IP address to be assigned to the Droplet...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with ubuntu(systemd)...
Installing Docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env chrisdonemx

real	2m3.009s
user	0m0.845s
sys	0m0.183s

Switch docker commands to refer to the remote machine:

$ eval $(docker-machine env chrisdonemx)

Start up the email server:

$ docker-compose up -d
Creating network "duta_default" with the default driver
Creating volume "duta_certs" with default driver
Pulling duta-web (chrisdone/duta-deploy@sha256:0b39ec0bc01c476a90792dccf683f593d9e25c2c493da4899b67e0caa73eada4)...
sha256:0b39ec0bc01c476a90792dccf683f593d9e25c2c493da4899b67e0caa73eada4: Pulling from chrisdone/duta-deploy
Pulling certbot-loop (chrisdone/certbot-loop@sha256:e67770ad671900d4b1f447b7771743b7c531b05046e7d7760cd538e1cf6fdb8e)...
sha256:e67770ad671900d4b1f447b7771743b7c531b05046e7d7760cd538e1cf6fdb8e: Pulling from chrisdone/certbot-loop
Creating duta_duta-web_1 ... 
Creating duta_duta-smtp-receiver_1 ... 
Creating duta_certbot-loop_1       ... 
$

Done!

version: "3"
services:
certbot-loop:
image: chrisdone/certbot-loop@sha256:e67770ad671900d4b1f447b7771743b7c531b05046e7d7760cd538e1cf6fdb8e
ports: ["80:80"]
restart: "no"
command: "--email letsencrypt@chrisdone.com --domains mx.chrisdone.com --duration 1d"
volumes:
- certs:/etc/letsencrypt/
duta-web:
command: /opt/duta/duta-web
image: chrisdone/duta-deploy@sha256:0b39ec0bc01c476a90792dccf683f593d9e25c2c493da4899b67e0caa73eada4
ports: ["443:443"]
volumes:
- certs:/etc/letsencrypt/
env_file:
- ./duta-web-env
duta-smtp-receiver:
command: /opt/duta/duta-smtp-receiver
image: chrisdone/duta-deploy@sha256:0b39ec0bc01c476a90792dccf683f593d9e25c2c493da4899b67e0caa73eada4
ports: ["25:25"]
env_file:
- ./duta-smtp-receiver-env
volumes:
certs:
DUTA_SMTP_RECEIVER_port=25
DUTA_SMTP_RECEIVER_max_db_connections=10
DUTA_SMTP_RECEIVER_hostname= mx.chrisdone.com
DUTA_SMTP_RECEIVER_connstr=dbname=duta user=duta password=YOURPW host=YOURHOST port=YOURPORT
DUTA_WEB_connstr=dbname=duta user=duta password=YOURPW host=YOURHOST port=YOURPORT
DUTA_WEB_port=443
DUTA_WEB_approot=https://mx.chrisdone.com
DUTA_WEB_max_db_connections=10
DUTA_WEB_username=chris
DUTA_WEB_password=YOURPW
DUTA_WEB_cert_file=/etc/letsencrypt/live/mx.chrisdone.com/cert.pem
DUTA_WEB_chain_file=/etc/letsencrypt/live/mx.chrisdone.com/chain.pem
DUTA_WEB_key_file=/etc/letsencrypt/live/mx.chrisdone.com/privkey.pem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment