Includes docker-compose
settings and nginx dockerfile to run Advocate and Advocate Bridge.
Set your $DOCKER_REGISTRY
to the same registry you used for advocate
, advocate-bridge
, and advocate-nginx
.
Note: we advise installing autoenv
(on macOS brew install autoenv
) which loads .env
when you cd
into the project
cp .env.sample .env
- Edit
.env
with your settings for postgres, rails/mix envs, and the servers you want to use - Edit
/etc/hosts
to point the server names you used in Step 2 (e.g.advocate.dev
/bridge.advocate.dev
) to your local machine
These environment variables will all be passed to the appropriate containers by compose.
To run everything together you can us make run
. This will:
- start a postgres DB
- run advocate
- run advocate bridge
- run the nginx proxy
Locally, this will be available on port 8080.
- Deploy this compose file to a docker swarm in production
Only if you want to run each service individually will you need to do the next phase.
- cd advocate-nginx
cp .env.sample .env
- Edit each to set the server names you want to use in nginx
make release
make run
- use
--build-arg
with environment variables to create the nginx site config
-
env_file loaded from ENV variable for DEPLOY_ENV=
-
multiple compose files stacked together
-
...
-
Each dockerfile takes a build arg for build_env 2a. compose can build, passing that build arg 2b. compose only pulls from iamges with a env tag
Small script to switch .env between .env.prod/production and .env.development Prepends the BUILD_ENV=$1 Write out as .env in current directory Sources .env
- create 2 or 3 nodes (I used digitalocean.com), one manager, one application, and one database
ssh
to managerdocker swarm init --advertise-addr {VPS_PRIVATE_IP}
- Copy the command to join the swarm
ssh
to application and database, and paste thedocker swarm join --token ...
command- Back on the manager node, assign roles to each hostname e.g.:
docker node update --label-add role=database {DATABASE_SERVER_HOSTNAME}
docker node update --label-add role=application {APPLICATION_SERVER_HOSTNAME
curl -O https://raw.githubusercontent.com/tpitale/advocate_provision/master/docker-compose.yml
curl https://raw.githubusercontent.com/tpitale/advocate_provision/master/.env.sample > .env
vi .env
to set your variablesset -a; source .env; set +a
docker login $DOCKER_REGISTRY
docker stack deploy --with-registry-auth --compose-file=docker-compose.yml advocate
# each time you update
docker exec advocate_advocate.1.{CONTAINER_ID} bin/rake db:setup --trace
docker exec advocate_advocate.1.{CONTAINER_ID} bin/rake db:migrate
docker stack services advocate
docker stack ps advocate
docker exec advocate_advocate.1.{CONTAINER_ID} tail -f /app/log/puma.stderr.log
docker exec advocate_advocate.1.{CONTAINER_ID} tail -f /app/log/prod.log