Skip to content

Instantly share code, notes, and snippets.

@beastawakens
Created March 15, 2017 10:42
Show Gist options
  • Save beastawakens/59da1b02a303362a3f7873a89c8ef46a to your computer and use it in GitHub Desktop.
Save beastawakens/59da1b02a303362a3f7873a89c8ef46a to your computer and use it in GitHub Desktop.
Getting Convox apps working with local .dev domains
version: "2"
services:
web:
build:
context: .
# Found the previous convox init using the 'convox/rails' image doesn't work due to the built-in nginx adding another layer of complexity. The new init using buildpacks is better.
command: bin/rails server -p $$PORT -e $$RAILS_ENV -b 0.0.0.0
environment:
- PORT=4001
# skip out other unimportant env vars
...
# set up the domain you want your container to respond to
- VIRTUAL_HOST=appname.dev
# tell the nginx-proxy which port you are exposing. If exposing only one port it will use that one, or default to port 80, but it's good to be explicit
- VIRTUAL_PORT=445
ports:
# define your external port. Each app running needs a different port, but if you don't define one, to leave it to Docker, then Convox thinks it's an internal only app.
- 445:4001/tcp
# Get the DNS server running for .dev domains
docker run -d --name dnsmasq -p 53535:53/tcp -p 53535:53/udp --restart always --cap-add=NET_ADMIN andyshinn/dnsmasq --address=/dev/127.0.0.1
# Get your mac resolving .dev domains to the DNS server
echo $'nameserver 127.0.0.1\nport 53535' >/etc/resolver/dev
# Get the nginx-proxy listening on port 80 and picking up on container events
docker run -d -p 80:80 -p 443:443 --name nginx-proxy --restart always -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment