Permalink
Browse files

various streamlining

  • Loading branch information...
BretFisher committed Sep 29, 2018
1 parent 5cfc777 commit 10b94b1b71d83d8d7eb6dc0f9bc44f0d491fd709
Showing with 100 additions and 22 deletions.
  1. +7 −1 create-servers.sh
  2. +17 −4 create-swarm.sh
  3. +3 −3 stack-ghost.yml
  4. +16 −13 stack-proxy.yml
  5. +11 −1 stack-rexray.yml
  6. +46 −0 stack-sqlite-ghost.yml
@@ -3,17 +3,23 @@

# create managers servers in digital ocean with pre-set environment vars
# https://docs.docker.com/machine/drivers/digital-ocean/

# DO_TOKEN get the token from digitalocean.com (read/write)
# DO_SIZE pick your droplet size from "doctl compute size list"
# SSH_FINGERPRINT in the format of "8d:30:8a..." with a comand like "ssh-keygen -E md5 -lf ~/.ssh/id_rsa.pub"

for server in {1..3}; do
docker-machine create \
--driver=digitalocean \
--digitalocean-access-token="${DO_TOKEN}" \
--digitalocean-size="${DO_SIZE}" \
--digitalocean-private-networking=true \
--digitalocean-ssh-key-fingerprint="${SSH_FINGERPRINT}" \
--digitalocean-tags=dogvscat \
--digitalocean-private-networking=true \
dvc${server} &
done


# if you wanted to create these locally in virtualbox, you might do this
# remember to check if you have enough RAM
# https://docs.docker.com/machine/drivers/virtualbox/
@@ -1,10 +1,23 @@
#!/bin/bash
set -x

# since we created droplets with a private NIC on eth1, lets use that for swarm comms
LEADER_IP=$(docker-machine ssh dvc1 ifconfig eth1 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')

# create a swarm as all managers
docker-machine ssh dvc1 docker swarm init --listen-addr=eth1 --data-path-addr=eth1 --advertise-addr=eth1
docker-machine ssh dvc1 docker swarm init --advertise-addr "$LEADER_IP"

# note that if you use eth1 above (private network in digitalocean) it makes the below
# a bit tricky, because docker-machine lists the public IP's but we need the
# private IP of manager for join commands, so we can't simply envvar the token
# like lots of scripts do... we'd need to fist get private IP of first node

# TODO: provide flexable numbers at cli for x managers and x workers
JOIN_TOKEN=$(docker-machine ssh dvc1 docker swarm join-token -q manager)

for i in 2 3; do
docker-machine ssh dvc$i docker swarm join --token "$JOIN_TOKEN" "$LEADER_IP":2377
done

docker-machine ssh dvc1 docker swarm join-token manager
docker-machine env dvc1

# copy this command and add run it on other nodes
# docker-machine ssh dvc2 <paste command>
@@ -3,7 +3,7 @@ version: '3.5'
services:

ghost:
image: ghost:1-alpine
image: ghost:alpine
networks:
- proxy
- ghost
@@ -12,7 +12,7 @@ services:
database__client: mysql
database__connection__host: db
database__connection__user: root
database__connection__password: YOURDBPASSWORDhere
database__connection__password: YOURDBPASSWORDhereee
database__connection__database: ghost
url: http://ghost.dogvs.cat
deploy:
@@ -31,7 +31,7 @@ services:
volumes:
- db:/var/lib/mysql
secrets:
- db-password
- db-password2
networks:
- ghost
deploy:
@@ -20,20 +20,23 @@ services:
- --docker.domain=traefik
- --docker.watch
- --api
- --defaultentrypoints=http,https
- --acme
- --acme.email=bret@bretfisher.com
# TODO: envvar for email and default domain
- --acme.httpchallenge
- --acme.httpchallenge.entrypoint=http
- --acme.onhostrule=true
- --acme.entrypoint=https
- --entryPoints=Name:https Address::443 TLS
- --entryPoints=Name:http Address::80
- --acme.storage=/etc/traefik/acme/acme.json
- --acme.acmelogging
- --acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
# - --defaultentrypoints=http,https
# - --acme
# - --acme.email=bret@bretfisher.com
# # TODO: envvar for email and default domain
# - --acme.httpchallenge
# - --acme.httpchallenge.entrypoint=http
# - --acme.onhostrule=true
# - --acme.entrypoint=https
# - --entryPoints=Name:https Address::443 TLS
# - --entryPoints=Name:http Address::80
# - --acme.storage=/etc/traefik/acme/acme.json
# - --acme.acmelogging
# - --acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
# - --acme.caserver=https://acme-v02.api.letsencrypt.org/directory
deploy:
placement:
constraints: [node.role == manager]
logging:
options:
max-size: "500k"
@@ -1,8 +1,15 @@
version: "3.4"

# 1. WORKAROUND: would prefer this use null network driver, will use bride for now to avoid overlay
# 2. TODO: would prefer on-failure restart_policy, but need to run this in script to look
# for if plugin exists first before reinstalling
# 3. TODO: would prefer this picks a driver version, and support driver updates

services:
plugin-rexray:
image: mavenugo/swarm-exec:17.03.0-ce
networks:
- bridge
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: docker plugin install --grant-all-permissions rexray/dobs DOBS_REGION=nyc3 DOBS_TOKEN="${REXRAY_DO_TOKEN}" DOBS_CONVERTUNDERSCORES=true
@@ -15,4 +22,7 @@ services:
options:
max-size: "500k"


networks:
bridge:
external: true
name: bridge
@@ -0,0 +1,46 @@
version: '3.5'

services:

ghost:
image: ghost:2-alpine
networks:
- proxy
- ghost
volumes:
- content:/var/lib/ghost/content
environment:
# see https://docs.ghost.org/docs/config#section-running-ghost-with-config-env-variables
NODE_ENV: production
# database__client: mysql
# database__connection__host: db
# database__connection__user: root
# database__connection__password: YOURDBPASSWORDhereee
# database__connection__database: ghost
url: http://ghost.dogvs.cat
deploy:
replicas: 1
labels:
- traefik.port=2368
- traefik.docker.network=proxy
- traefik.frontend.rule=Host:ghost.dogvs.cat
# logging:
# driver: "gelf"
# options:
# gelf-address: "udp://127.0.0.1:5000"

# TODO: backup for static content


networks:
ghost: {}
proxy:
external: true

volumes:
content:
driver: rexray/dobs
driver_opts:
size: 1


0 comments on commit 10b94b1

Please sign in to comment.