adhocteam / soapbox

Apache License 2.0
11 stars 3 forks source link

Use docker-compose to containerize dev environment #142

Closed nickclyde closed 7 years ago

nickclyde commented 7 years ago

Fixes #130

This uses docker-compose.yml to build three docker images (one for soapboxd, one for the rails app, and one for postgres). Run docker-compose up to run the app.

We could take this a bit further at some point by building some kind of dev server that watches for changes and rebuilds soapboxd automatically, but I think this is a good start for now.

BTW if you want to use this you may need to dump your local db and load it into the Dockerized db.

nickclyde commented 7 years ago

Decided to get creative and use modd to run a kind of dev server that watches for changes and restarts the docker services. Working out the kinks on that, will push shortly.

nickclyde commented 7 years ago

Getting a weird error when copying a newly compiled soapboxd to its Docker container and restarting:

standard_init_linux.go:187: exec user process caused "no such file or directory"

When I sh into the container and look, /root/soapboxd exists, and I can run it manually, but the container won't start externally. Still looking into this.

nickclyde commented 7 years ago

Solved the above by just rebuilding the container image for soapboxd instead of copying the compiled binary over.

nickclyde commented 7 years ago

Process for migrating local soapbox_dev db into the Docker container: First comment out these lines in docker-compose.yml:

5    volumes:
6      - ./db/schema.sql:/docker-entrypoint-initdb.d/init.sql

Then run these commands:

pg_dump soapbox_dev -f ./soapbox_dev.dump -F c
docker-compose up --build postgres
export DOCKER_DB_NAME="$(docker-compose ps -q postgres)"
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U soapbox -d soapbox_dev < ./soapbox_dev.dump

Then uncomment the same lines as above.