diff --git a/CHANGELOG.md b/CHANGELOG.md index 40f73b8..83006e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ uptime. - Fix issue with EDD metrics being nested under each other in the `/api/metrics` generated-page. +- Add `./deploy/deploy` script for use with + [garrison](https://bitbucket.org/nsidc/garrison) deployment system at NSIDC. # v1.0.1 diff --git a/deploy/deploy b/deploy/deploy new file mode 100755 index 0000000..469ef45 --- /dev/null +++ b/deploy/deploy @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +ENVIRONMENT=$1 + +THISDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +COMPOSE_FILE=$THISDIR/../docker-compose.yml + +if [ "${ENVIRONMENT}" = "dev" ]; then + echo "Dev does not support stack deploy with garrison." + exit 1 +elif [ "${ENVIRONMENT}" = "integration" ]; then + OVERRIDE_FILE=$THISDIR/../docker-compose.integration.yml +else + OVERRIDE_FILE=$THISDIR/../docker-compose.production.yml +fi + +source /etc/profile.d/envvars.sh + +cd $THISDIR/../ +docker compose -f $COMPOSE_FILE -f $OVERRIDE_FILE up --detach +docker system prune -af diff --git a/doc/envvars.md b/doc/envvars.md index fb83461..64dabe3 100644 --- a/doc/envvars.md +++ b/doc/envvars.md @@ -21,3 +21,5 @@ Environment variables are exposed to the DAT's components through . - `LOGS_SHARE_PATH`: Local path to directory where logs are stored. See [Logs](logs.md) for more information. +- `LOGS_SHARE_BACKUP_PATH`: Path to directory where logs are backed-up for + long-term storage. See [Logs](logs.md) for more information. diff --git a/doc/logs.md b/doc/logs.md index 2195bf9..21f81fd 100644 --- a/doc/logs.md +++ b/doc/logs.md @@ -12,10 +12,10 @@ The Data Access Tool backend produces logs from two primary sources: ## NGINX Server logs -Logs are written to local disk, in `./logs/server/`. +Logs are written to local disk, in a directory defined by `LOGS_SHARE_PATH`. It is expected that these logs be backed-up to a networked share drive (defined -through the `LOGS_SHARE_PATH` [environment variable](envvars.md)) through +through the `LOGS_SHARE_BACKUP_PATH` [environment variable](envvars.md)) through `logrotation`. The `dat.access.log` is intended to be used for application metrics, and these data should be retained for recordkeeping. The [data-access-tool-vm](https://github.com/nsidc/data-access-tool-vm) project sets diff --git a/doc/releasing.md b/doc/releasing.md index 99a5617..35fcf69 100644 --- a/doc/releasing.md +++ b/doc/releasing.md @@ -9,5 +9,24 @@ To release a new version: - Tag latest commit on `main` with the version, and push. This will trigger a build of the `data-access-tool-api` and `data-access-tool-server` images with the given version tag. -- Deploy the latest change with the - [data-access-tool-vm](https://github.com/nsidc/data-access-tool-vm). +- Deploy the latest change with + [garrison](https://bitbucket.org/nsidc/garrison). See the + [section on garrison](#garrison) below for more info. + +## garrison + +[garrison](https://bitbucket.org/nsidc/garrison) is a deployment system for +NSIDC applications deployed to a VM on NSIDC infrastructure. + +The [jenkins-cd](http://ci.jenkins-cd.apps.int.nsidc.org:8080) Jenkins VM +provides a mechanism for doing garrison deployments of the +`data-access-tool-backend` to integration and QA. + +The +[Deploy Project with Garrison](https://ci.jenkins-ops-2022.apps.int.nsidc.org/job/Deploy_Project_with_Garrison/) +job defined in the Ops Jenkins is used by Ops to deploy to staging and +production. + +See the [data-access-tool-vm](https://github.com/nsidc/data-access-tool-vm) +project for additional details and VM configuration for the +`data-access-tool-backend`. diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 69064d0..b592a2f 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,13 +1,7 @@ services: api: build: . - volumes: - - "./src:/tmp/" - # live logs written directly by the nginx server - - "./logs/server:/tmp/server_logs/live/:ro" command: '/bin/bash -c "PYTHONPATH=./ python dat_backend/dev_server.py"' server: build: ./nginx - volumes: - - ./logs/server:/var/log/nginx/ diff --git a/docker-compose.local.yml b/docker-compose.local.yml index 23ff84d..4ea7ded 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -9,15 +9,9 @@ services: api: build: . volumes: - - "./src:/tmp/" - # live logs written directly by the nginx server - - "./logs/server:/tmp/server_logs/live/:ro" command: '/bin/bash -c "PYTHONPATH=./ python dat_backend/dev_server.py"' server: build: ./nginx volumes: - - ./logs/server:/var/log/nginx/ - # Run server as root locally. This works for systems that do not have the - # `vagrant` user defined user: ":" diff --git a/docker-compose.yml b/docker-compose.yml index 509a03e..e95edb6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,9 +17,10 @@ services: restart: always volumes: # live logs written directly by the nginx server - - "./logs/server:/tmp/server_logs/live/:ro" - # backup logs rotated onto NFS - "${LOGS_SHARE_PATH:?LOGS_SHARE_PATH must be + set}/server:/tmp/server_logs/live/:ro" + # backup logs rotated onto NFS + - "${LOGS_SHARE_BACKUP_PATH:?LOGS_SHARE_PATH must be set}/server:/tmp/server_logs/backup/:ro" logging: options: @@ -37,7 +38,8 @@ services: # Setting the user explicitly ensures that the logs are written out as vagrant. user: "vagrant:vagrant" volumes: - - ./logs/server:/var/log/nginx/ + - "${LOGS_SHARE_PATH:?LOGS_SHARE_PATH must be + set}/server:/var/log/nginx/:rw" logging: options: max-size: "20m"