From f1845aa9261ba72cc7cf30e345401df07f7a1223 Mon Sep 17 00:00:00 2001 From: Nathan Hertz <nhertz@nrao.edu> Date: Wed, 28 Jul 2021 17:07:35 +0000 Subject: [PATCH] WS-541: Production HTCondor submit host configuration file and updated production `Dockerfile`s --- .gitlab-ci.yml | 2 +- Makefile | 4 ++-- apps/web/{Dockerfile.dev => Dockerfile} | 7 ++++++- apps/web/Dockerfile.ci | 5 ++--- apps/web/angular.json | 5 ++++- apps/web/src/environments/environment.prod.ts | 4 ++-- ci/build.template.yml | 9 ++++---- .../submit/99-workspaces-submit.prod.conf | 21 +++++++++++++++++++ .../capability/{Dockerfile.dev => Dockerfile} | 6 +++--- .../{Dockerfile.dev => Dockerfile} | 6 +++--- .../workflow/{Dockerfile.dev => Dockerfile} | 13 +++++++----- 11 files changed, 57 insertions(+), 25 deletions(-) rename apps/web/{Dockerfile.dev => Dockerfile} (87%) create mode 100644 config/htcondor/submit/99-workspaces-submit.prod.conf rename services/capability/{Dockerfile.dev => Dockerfile} (83%) rename services/notification/{Dockerfile.dev => Dockerfile} (83%) rename services/workflow/{Dockerfile.dev => Dockerfile} (77%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e237b7060..50618075b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -180,7 +180,7 @@ e2e: variables: ENV_HOST: workflow before_script: - - docker build -t base-build:ci --target base-build -f apps/web/Dockerfile.dev . + - docker build -t base-build:ci --target base-build -f apps/web/Dockerfile --build-arg env=dev . - docker build -t e2e:${CI_COMMIT_SHORT_SHA} -f apps/web/Dockerfile.ci . script: # setting env variables with .env https://docs.docker.com/compose/environment-variables/ diff --git a/Makefile b/Makefile index 3a15a0f68..dd8aba670 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ all: dev check-build # Check if local code will pass CI build check-build: docker-base docker-dev-images-locally test-dev -# Run tests on Dockerfile.dev images +# Run tests on Dockerfile images test-dev: docker run nrao:workflow ./bin/run-tests.sh docker run nrao:capability ./bin/run-tests.sh @@ -32,7 +32,7 @@ alembic-update: cd schema; \ env CAPO_PROFILE=local alembic upgrade head -# Build images from Dockerfile.dev +# Build images from Dockerfile docker-dev-images-locally: docker build -t nrao:workflow -f services/workflow/Dockerfile.local . --build-arg capo_env=docker docker build -t nrao:capability -f services/capability/Dockerfile.local . --build-arg capo_env=docker diff --git a/apps/web/Dockerfile.dev b/apps/web/Dockerfile similarity index 87% rename from apps/web/Dockerfile.dev rename to apps/web/Dockerfile index c5421ed3b..44387361c 100644 --- a/apps/web/Dockerfile.dev +++ b/apps/web/Dockerfile @@ -1,5 +1,10 @@ FROM ssa-containers.aoc.nrao.edu/ops/base:nodejs-14 as base-build +# Requies build-arg $env +# Build arg that sets environment; sets to "dev" if no build arg is given +ARG env=dev +ENV ENV=${env} + # Switch to vlapipe USER vlapipe @@ -37,7 +42,7 @@ USER vlapipe COPY --chown=vlapipe:vlapipe ./apps/web ./ # Build the angular app -RUN ./node_modules/.bin/ng build --configuration=dev --output-path=dist +RUN ./node_modules/.bin/ng build --configuration=${ENV} --output-path=dist # ## NGINX section of multi-stage image diff --git a/apps/web/Dockerfile.ci b/apps/web/Dockerfile.ci index b9586b7e8..89395a15f 100644 --- a/apps/web/Dockerfile.ci +++ b/apps/web/Dockerfile.ci @@ -1,9 +1,9 @@ -# base-build:ci references the first stage in app/web/Dockerfile.dev +# base-build:ci references the first stage in app/web/Dockerfile # in which npm install has already been ran and app/web/ has been # copied to /app in the image # For e2e testing, we want to use this first stage as the base for our -# e2e container when we run e2e tests in the CI. We'll copy /app/ from +# e2e container when we run e2e tests in the CI. We'll copy /app/ from # base-build:ci and copy it to /app of the trion/ng-cli-karma:11.2.7 image. # Then we are able to run `ng e2e` with our Angular environment already setup. # https://hub.docker.com/r/trion/ng-cli-karma/ @@ -17,4 +17,3 @@ WORKDIR /app COPY --from=web-base /home/vlapipe/app/ ./ CMD ./node_modules/protractor/bin/webdriver-manager update --versions.chrome 89.0.4389.114 && ng e2e --configuration=ci --webdriver-update=false - diff --git a/apps/web/angular.json b/apps/web/angular.json index 4d3f27bb2..81dcdd0e2 100644 --- a/apps/web/angular.json +++ b/apps/web/angular.json @@ -36,7 +36,7 @@ "scripts": [] }, "configurations": { - "production": { + "prod": { "fileReplacements": [ { "replace": "src/environments/environment.ts", @@ -183,6 +183,9 @@ }, "test": { "baseUrl": "https://ws-test.nrao.edu" + }, + "prod": { + "baseUrl": "https://ws.nrao.edu" } } }, diff --git a/apps/web/src/environments/environment.prod.ts b/apps/web/src/environments/environment.prod.ts index 15fdc275f..913b12f97 100644 --- a/apps/web/src/environments/environment.prod.ts +++ b/apps/web/src/environments/environment.prod.ts @@ -1,7 +1,7 @@ export const environment = { production: true, // archive search services - apiUrl: 'https://webtest.aoc.nrao.edu/archive-service/', + apiUrl: "https://data.nrao.edu/archive-service/", // workspace services - workspacesUrl: 'http://localhost:3457/' + workspacesUrl: "http://ws.nrao.edu/", }; diff --git a/ci/build.template.yml b/ci/build.template.yml index d3c8ce507..4f12887b3 100644 --- a/ci/build.template.yml +++ b/ci/build.template.yml @@ -1,11 +1,9 @@ # CI Build Template .build: - variables: - CAPO_BUILD_ARG: "docker" script: - echo "Building branch or tag -- ${IMAGE_TAG}" - NAME="${REGISTRY_URL}/${PROJECT_NAME}/${SERVICE_NAME}" - - docker build -t ${NAME}:${CI_COMMIT_SHORT_SHA} -f ${PATH_PREFIX}${SERVICE_NAME}/Dockerfile.dev . --build-arg capo_env=${CAPO_BUILD_ARG} --build-arg TAGNAME=${CI_COMMIT_SHORT_SHA} + - docker build -t ${NAME}:${CI_COMMIT_SHORT_SHA} -f ${PATH_PREFIX}${SERVICE_NAME}/Dockerfile . --build-arg env=${DEPLOY_ENV} --build-arg TAGNAME=${CI_COMMIT_SHORT_SHA} - docker tag ${NAME}:${CI_COMMIT_SHORT_SHA} ${NAME}:${IMAGE_TAG} - echo "TAG=${IMAGE_TAG}" >> build.env artifacts: @@ -15,9 +13,12 @@ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH variables: IMAGE_TAG: $CI_COMMIT_BRANCH + DEPLOY_ENV: "dev" - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' variables: IMAGE_TAG: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME + DEPLOY_ENV: "dev" + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - if: '$CI_COMMIT_TAG =~ /^end-of-sprint-[0-9]+/' variables: IMAGE_TAG: $CI_COMMIT_TAG @@ -27,4 +28,4 @@ variables: IMAGE_TAG: $CI_COMMIT_TAG # override DEPLOY_ENV - DEPLOY_ENV: "prod" \ No newline at end of file + DEPLOY_ENV: "prod" diff --git a/config/htcondor/submit/99-workspaces-submit.prod.conf b/config/htcondor/submit/99-workspaces-submit.prod.conf new file mode 100644 index 000000000..7ba55acf9 --- /dev/null +++ b/config/htcondor/submit/99-workspaces-submit.prod.conf @@ -0,0 +1,21 @@ +CONDOR_HOST = nmpost-cm.aoc.nrao.edu + +use ROLE : Submit + +ALLOW_WRITE = *.aoc.nrao.edu +ALLOW_DAEMON = $(ALLOW_WRITE) + +# one or more submit hosts has an external IP +PRIVATE_NETWORK_NAME = nrao.edu + +# while not in production yet +CONDOR_ADMIN = krowe@nrao.edu + +# send email if job errors +JOB_DEFAULT_NOTIFICATION = ERROR + +# Differentiate from other pools if needed +PoolName = "nmpost" + +# Set UID domain +UID_DOMAIN = aoc.nrao.edu diff --git a/services/capability/Dockerfile.dev b/services/capability/Dockerfile similarity index 83% rename from services/capability/Dockerfile.dev rename to services/capability/Dockerfile index ae5e77d8d..740587c73 100644 --- a/services/capability/Dockerfile.dev +++ b/services/capability/Dockerfile @@ -20,8 +20,8 @@ ENV PATH "${PATH}:/home/vlapipe/.local/bin" RUN python setup.py develop --user -# Set Capo -ARG capo_env=dsoc-dev -ENV CAPO_PROFILE $capo_env +# Set Capo for build stage +# Gets reset to proper environment's profile in the deploy stage +ENV CAPO_PROFILE docker CMD ["pserve", "--reload", "development.ini"] diff --git a/services/notification/Dockerfile.dev b/services/notification/Dockerfile similarity index 83% rename from services/notification/Dockerfile.dev rename to services/notification/Dockerfile index 12e7470b2..851796570 100644 --- a/services/notification/Dockerfile.dev +++ b/services/notification/Dockerfile @@ -20,8 +20,8 @@ ENV PATH "${PATH}:/home/vlapipe/.local/bin" RUN python setup.py develop --user -# Set Capo -ARG capo_env=dsoc-dev -ENV CAPO_PROFILE $capo_env +# Set Capo for build stage +# Gets reset to proper environment's profile in the deploy stage +ENV CAPO_PROFILE docker CMD ["pserve", "--reload", "development.ini"] diff --git a/services/workflow/Dockerfile.dev b/services/workflow/Dockerfile similarity index 77% rename from services/workflow/Dockerfile.dev rename to services/workflow/Dockerfile index 2ac9111f2..f0910f86c 100644 --- a/services/workflow/Dockerfile.dev +++ b/services/workflow/Dockerfile @@ -2,6 +2,10 @@ ARG TAGNAME="tmp" FROM cache:${TAGNAME} +# Build arg that sets environment; sets to "dev" if no build arg is given +ARG env=dev +ENV ENV=${env} + USER root # HTCondor install @@ -14,7 +18,7 @@ RUN sudo apt install -y htcondor # HTCondor setup # Copy over HTCondor submit node config -COPY ./config/htcondor/submit/99-workspaces-submit.dev.conf /etc/condor/config.d/99-workspaces-submit.dev.conf +COPY ./config/htcondor/submit/99-workspaces-submit.${ENV}.conf /etc/condor/config.d/99-workspaces-submit.${ENV}.conf # Change working directory to /code WORKDIR /code @@ -34,10 +38,9 @@ ENV PATH "${PATH}:/home/vlapipe/.local/bin" RUN python setup.py develop --user -# Set Capo -ARG capo_env=dsoc-dev -ENV CAPO_PROFILE $capo_env -ENV PATH $PATH:/lustre/aoc/pipeline/$CAPO_PROFILE/workflow +# Set Capo for build stage +# Gets reset to proper environment's profile in the deploy stage +ENV CAPO_PROFILE docker USER root -- GitLab