I’m trying to deploy a Phoenix project to Digital Ocean using Docker for the 1st time. In the past, I’ve used either Heroku or Gigalixir. This is my first experience with both Docker and Digital Ocean. I’ve used the following resources:
Distillery: Deploying to Digital Ocean
My hello_docker project is on Github here. My image is on docker hub here.
The docker-compose.yml is:
# File my_app/docker-compose.yml
version: "3.5"
networks:
webnet:
driver: overlay
attachable: true # Needed in order to run custom commands in the container
services:
app:
image: axelclark/hello_docker:0.2.0
ports:
- "80:4000" # In our .env file above, we chose port 4000
env_file:
- config/docker.env
depends_on:
- db
deploy:
replicas: 1
restart_policy:
condition: on-failure
networks:
- webnet
db:
image: postgres:10-alpine
deploy:
replicas: 1
placement:
constraints: [node.role == manager]
restart_policy:
condition: on-failure
volumes:
- "./volumes/postgres:/var/lib/postgresql/data"
ports:
- "5432:5432"
env_file:
- config/docker.env
networks:
- webnet
I’ve followed the deploy steps in Distillery: Deploying to Digital Ocean.
I saved the config/docker.env
and docker-compose.yml
files to the droplet. Then I ran the docker swarm
and docker stack deploy
commands:
root@docker-axelclark:~$ docker swarm init --advertise-addr 64.227.3.73
Swarm initialized: current node (kdqwzzipuli9rbncr282mm633) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-5w2kptuxwtwbnu3nvr4abx4vh6qo3b3k82nnu91qnkojqosx1s-6b4a9ifclb3hprmkn227cjwo6 64.227.3.73:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
root@docker-axelclark:~$ docker stack deploy -c ~/etc/myapp/docker-compose.yml myapp
Creating network myapp_webnet
Creating service myapp_db
Creating service myapp_app
root@docker-axelclark:~$ docker stack ls
NAME SERVICES ORCHESTRATOR
myapp 2 Swarm
When I deploy locally with docker swarm init
and docker stack deploy
, everything works as expected.
However, when I deploy to Digital Ocean, I can’t figure out how to visit my site. What url can I visit to see if my app is working?
I tried the ip: 64.227.3.73, but it says the site can’t be reached. There is probably a simple answer, but I haven’t been able to figure it out.
Thanks!
Axel