source for the Soils2Satellites webapp
- Docker = 18.09
- docker-compose 1.24
Docker was retro-fitted to this app. It's not a 12 factor app so there's not much you can control using env vars.
Instead, the config is stored in the database so to configure the app you must first start the stack, then login as the
admin user (default password in grails-app/conf/Bootstrap.groovy
) and go to
http://localhost:8080/ala-soils2sat/admin/settings (change your host and port) to see/change the system settings.
-
create a new VM
-
install
docker
anddocker-compose
-
clone this repo onto the VM
-
copy the template script to start the docker stack
pushd ./docker cp start-or-restart-stack.sh.example start-or-restart-stack.sh chmod +x start-or-restart-stack.sh popd
-
edit
./docker/start-or-restart-stack.sh
to add the required sensitive details -
spin up the compose stack
./docker/start-or-restart-stack.sh # or if you need to trigger a rebuild of the app Docker image (after a git pull) ./docker/start-or-restart-stack.sh --build # note: the docker cache means probably only the last stage of the multistage build # of our app will happen. If you need a full rebuild, do a separate no-cache build pushd ./docker docker-compose build --no-cache popd ./docker/start-or-restart-stack.sh
-
open a browser to
http://<VM IP>
(we don't run HTTPS because some of the client-side JS breaks)
We're running a number of docker containers.
- the S2S app using
grails run-app
, which uses tomcat - Postgres
- a container to do periodic backups of the postgres database to AWS S3
- a container to do continuous backups of the extracts directory to AWS S3
- an nginx instance running as a reverse proxy
docker exec -it s2s-pgbackups3 /bin/sh /backup.sh
./docker/start-or-restart-stack.sh
This will leave the DB data volume alone but stop the containers:
docker-compose stop
# from here you can run the `./docker/start-or-restart-stack.sh` command to start the stack again, and it'll pick up the existing DB data volume
You can also use docker-compose down
, which will remove the containers but the data volumes still exist.
To completely remove all traces, including the DB data and other data volumes, use:
docker-compose down --volumes # the --volumes flag nukes the volumes too
docker logs --follow --tail 10 s2s_app
You can connect to the DB as the superuser if you SSH to the docker host, then run:
docker exec -it s2s_db sh -c 'psql -U $POSTGRES_USER -d $POSTGRES_DB'
It depends on the format of your dump but the easiest way is probably to cat the dump into a shell inside the DB container:
cat data.backup | docker exec -i s2s_db sh -c 'pg_restore -v -U $POSTGRES_USER -d $POSTGRES_DB --clean --if-exists'
You could also docker cp
the dump into the container, then docker exec
to do the restore.