diff --git a/.dockerignore b/.dockerignore index ad2d9206a4b..404667b1fa1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -16,6 +16,7 @@ !.yarnrc !babel.config.js !docker-entrypoint.sh +!dump-data.sh !Dockerfile !frontend.sh !initial-data.sh diff --git a/Dockerfile b/Dockerfile index 5ffcce2fca1..66e9806aaa0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -135,7 +135,7 @@ RUN mkdir -p /var/www/.local && chown -R apache:apache ${APP_HOME} /var/www/.loc # Copy the cfgov directory form the build image COPY --from=cfgov-frontend-builder --chown=apache:apache ${CFGOV_PATH}/cfgov ${CFGOV_PATH}/cfgov -COPY --from=cfgov-frontend-builder --chown=apache:apache ${CFGOV_PATH}/docker-entrypoint.sh ${CFGOV_PATH}/refresh-data.sh ${CFGOV_PATH}/initial-data.sh ${CFGOV_PATH}/ +COPY --from=cfgov-frontend-builder --chown=apache:apache ${CFGOV_PATH}/docker-entrypoint.sh ${CFGOV_PATH}/refresh-data.sh ${CFGOV_PATH}/initial-data.sh ${CFGOV_PATH}/dump-data.sh ${CFGOV_PATH}/ COPY --from=cfgov-frontend-builder --chown=apache:apache ${CFGOV_PATH}/static.in ${CFGOV_PATH}/static.in RUN ln -s /usr/lib/apache2 cfgov/apache/modules diff --git a/dump-data.sh b/dump-data.sh index d361b73e725..fb4fe08ba10 100755 --- a/dump-data.sh +++ b/dump-data.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # ========================================================================== # Dump the contents of the Database into a gzipped SQL file. @@ -15,8 +15,16 @@ fi dump_data() { # This preamble will drop the existing 'cfpb' schema if it exists. DROP_PREAMBLE=$(cat << EOF +-- +-- We add this DROP to ensure that a database dump can be loaded to generate +-- a state that exactly matches the one that was dumped. Without this, objects +-- in the schema before the dump happens may exist and conflict with the +-- dumped data being loaded. +-- SET client_min_messages = WARNING; -DROP SCHEMA IF EXISTS cfpb CASCADE; +DROP SCHEMA IF EXISTS ${PGUSER:-cfpb} CASCADE; + + EOF ) diff --git a/helm/cfgov/Chart.yaml b/helm/cfgov/Chart.yaml index 01e3a149980..52bd443182d 100644 --- a/helm/cfgov/Chart.yaml +++ b/helm/cfgov/Chart.yaml @@ -20,7 +20,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.2 +version: 0.1.3 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/helm/cfgov/templates/cronjob.yaml b/helm/cfgov/templates/cronjob.yaml index 770f2fddb9a..e0f26299072 100644 --- a/helm/cfgov/templates/cronjob.yaml +++ b/helm/cfgov/templates/cronjob.yaml @@ -28,13 +28,9 @@ spec: imagePullPolicy: {{ $.Values.image.pullPolicy }} {{- end }} command: - {{- range $values.command }} - - {{ . | quote }} - {{- end }} + {{- toYaml $values.command | nindent 16 }} args: - {{- range $values.args }} - - {{ . | quote }} - {{- end }} + {{- toYaml $values.args | nindent 16 }} volumeMounts: {{- if or $values.includeEnv (not (hasKey $values "includeEnv")) }} # Add in main container volumes diff --git a/helm/cfgov/values.yaml b/helm/cfgov/values.yaml index 53c0cfc45d6..bc35dc714b6 100644 --- a/helm/cfgov/values.yaml +++ b/helm/cfgov/values.yaml @@ -226,10 +226,11 @@ cronJobs: - "bash" args: - "-c" - - >- - pg_dump --no-owner --no-privileges | \ - gzip > test.sql.gz | \ - aws s3 cp test.sql.gz s3://$S3_BUCKET/ + - | + ./dump-data.sh "${DB_DUMP_FILE:-test.sql.gz}" && \ + if [ ! -z $S3_BUCKET ]; then \ + aws s3 cp "${DB_DUMP_FILE:-test.sql.gz}" \ + s3://$S3_BUCKET/; fi suspend: true publish-scheduled-pages: diff --git a/test.sql.gz b/test.sql.gz index 78eb641d255..b6c1371fa24 100644 Binary files a/test.sql.gz and b/test.sql.gz differ