diff --git a/api/package.json b/api/package.json index 7e09aa0ac8..03cfa158dc 100644 --- a/api/package.json +++ b/api/package.json @@ -26,6 +26,7 @@ "db:seed:staging": "npx prisma db seed -- --environment staging", "db:seed:development": "npx prisma db seed -- --environment development --jurisdictionName 'Bay Area'", "db:reseed:with-external:dev": "yarn db:setup:staging && IMPORT_ENV=dev yarn db:import-listings", + "db:reseed:ci": "SUPPRESS_NOTICE=true PGDATABASE=template1 yarn db:setup:staging", "generate:client": "ts-node scripts/generate-axios-client.ts && prettier -w ../shared-helpers/src/types/backend-swagger.ts", "test:e2e": "yarn db:resetup && yarn db:migration:run && jest --config ./test/jest-e2e.config.js", "db:setup": "yarn db:resetup && yarn db:migration:run && yarn db:seed:development", diff --git a/build/docker/Dockerfile.backend b/build/docker/Dockerfile.backend index d32f5c4e45..68621765fa 100644 --- a/build/docker/Dockerfile.backend +++ b/build/docker/Dockerfile.backend @@ -126,6 +126,8 @@ CMD yarn start:prod # The run stage contains an optimized image for running the application FROM run AS migrate +ENV SKIP_MIGRATIONS=TRUE + WORKDIR /app # These parts have to be run as root @@ -144,6 +146,6 @@ COPY --from=source --chown=node:node /app/api/scripts ./scripts USER node # We need to skip all migrations that are just for local development (changes already exist in deployed environment) -CMD yarn db:migration:skip 00_init || true && yarn db:migration:skip 02_hba_to_prisma || true && yarn db:migration:skip 03_0_external_listing || true && yarn db:migration:run -## uncomment the below if starting on a new environment -# CMD yarn db:migration:run +CMD if [ "$SKIP_MIGRATIONS" = TRUE ]; then yarn db:migration:skip 00_init || true && yarn db:migration:skip 02_hba_to_prisma || true && yarn db:migration:skip 03_0_external_listing || true && yarn db:migration:run; \ + else yarn db:migration:run; \ + fi diff --git a/ci/buildspec/build_backend.yml b/ci/buildspec/build_backend.yml index 3fa0bca067..3b6a124cdc 100644 --- a/ci/buildspec/build_backend.yml +++ b/ci/buildspec/build_backend.yml @@ -18,8 +18,9 @@ phases: - export ECR_HOST="${ECR_ACCOUNT_ID}.dkr.ecr.${ECR_REGION}.amazonaws.com" - export ECR_REPO="${ECR_HOST}/${ECR_NAMESPACE}" - - docker build . -f build/docker/Dockerfile.backend --target test -t backend/core:test - - docker run backend/core:test yarn test + # Skip the test step as it is handle before merge. But re-add if you want more verification + # - docker build . -f build/docker/Dockerfile.backend --target test -t backend/core:test + # - docker run backend/core:test yarn test - docker build . -f build/docker/Dockerfile.backend --target run -t backend/core:run-candidate - docker build . -f build/docker/Dockerfile.backend --target migrate -t backend/core:migrate-candidate diff --git a/ci/buildspec/migrate_stop_backend.yml b/ci/buildspec/migrate_stop_backend.yml index 6d6dd2ad07..dbcd93e408 100644 --- a/ci/buildspec/migrate_stop_backend.yml +++ b/ci/buildspec/migrate_stop_backend.yml @@ -68,6 +68,7 @@ phases: --env CLOUDINARY_KEY="${CLOUDINARY_KEY:-dummy_key}" --env PARTNERS_BASE_URL="${PARTNERS_BASE_URL:-http://localhost:3001/not-used}" --env PARTNERS_PORTAL_URL="${PARTNERS_PORTAL_URL:-http://localhost:3001/not-used}" + --env SKIP_MIGRATIONS=FALSE "${MIGRATION_IMAGE}" sh -c "yarn ${MIGRATION_CMD}" # Start the backend back up with the previous number of desired containers