From c4250f2bff92f47b83de336f6fadbacddb6ef8f9 Mon Sep 17 00:00:00 2001
From: Brandon Clayton <bclayton@usgs.gov>
Date: Tue, 29 Oct 2024 10:58:41 -0600
Subject: [PATCH] checnge docker

---
 .gitlab-ci.yml | 21 ++++++++++++++++-----
 docs/docker.md | 38 +++++++++++++++++++++++---------------
 2 files changed, 39 insertions(+), 20 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 61c90ef54..429cde49f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -100,17 +100,25 @@ default:
       for arg in ${DOCKER_BUILD_ARGS}; do
         BUILD_ARGS="${BUILD_ARGS} --build-arg ${arg}";
       done
+    - env_image_name="${REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${ENVIRONMENT}-latest";
+    - latest_image_name="${REGISTRY_IMAGE}/${CI_PROJECT_NAME}:latest";
+    - sha_image_name="${REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${IMAGE_TAG}";
     - |
       docker build \
         ${BUILD_ARGS} \
         --pull \
-        --tag "${REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${IMAGE_TAG}" \
+        --tag "${env_image_name}" \
         --file "${CI_PROJECT_DIR}/${DOCKERFILE}" \
         "${CI_PROJECT_DIR}/.";
-    - docker push "${REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${IMAGE_TAG}";
-    - latest_image_name="${REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${ENVIRONMENT}-latest";
-    - docker tag "${REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${IMAGE_TAG}" "${latest_image_name}";
-    - docker push "${latest_image_name}";
+    - docker push "${env_image_name}";
+    - |
+      docker tag "${env_image_name}" "${sha_image_name}";
+      docker push "${sha_image_name}";
+    - |
+      if [[ "${ENVIRONMENT}" != "development" ]]; then
+        docker tag "${env_image_name}" "${latest_image_name}";
+        docker push "${latest_image_name}";
+      fi
     - |
       printf "
         --------
@@ -119,6 +127,9 @@ default:
       " "${CI_PROJECT_NAME}" "${IMAGE_TAG}";
   variables:
     DOCKERFILE: Dockerfile
+    DOCKER_BUILD_ARGS: |
+      BUILD_IMAGE=${CI_REGISTRY}/devops/images/usgs/node:20
+      FROM_IMAGE=${CI_REGISTRY}/devops/images/usgs/nginx:latest
     IMAGE_TAG: ${ENVIRONMENT}-${CI_COMMIT_SHORT_SHA}
     REGISTRY_IMAGE: ${CI_REGISTRY_IMAGE}
 
diff --git a/docs/docker.md b/docs/docker.md
index 89b8bad8a..038f79a60 100644
--- a/docs/docker.md
+++ b/docs/docker.md
@@ -2,8 +2,9 @@
 
 ## Local Build
 
-This projects contains a [Dockerfile](https://code.usgs.gov/ghsc/nshmp/nshmp-apps/-/blob/main/Dockerfile) that can be built and
-ran.
+This projects contains a
+[Dockerfile](https://code.usgs.gov/ghsc/nshmp/nshmp-apps/-/blob/main/Dockerfile)
+that can be built and ran.
 
 ### Build Docker Image
 
@@ -39,28 +40,35 @@ docker run -p 8080:8080 nshmp-apps
 
 ## Docker Registry
 
-The [nshmp-apps](https://hub.docker.com/r/usgs/nshmp-apps)
-Docker image is available from the Docker registry. There are three main tags to pull:
+_nshmp-apps_ is available as a public image from the
+[GitLab registry](https://code.usgs.gov/ghsc/nshmp/nshmp-apps/container_registry) with tags:
 
-- latest
-- staging-latest
-- production-latest
+- `latest`,`staging-latest`: Latest updates associated with the
+  [main](https://code.usgs.gov/ghsc/nshmp/nshmp-apps/-/tree/main) branch
+- `production-latest`: Latest stable release associated with a
+  [tag](https://code.usgs.gov/ghsc/nshmp/nshmp-apps/-/tags)
 
-The `staging-latest` and `latest` refers to the
-[main](https://code.usgs.gov/ghsc/nshmp/nshmp-apps/-/tree/main) branch and
-`production-latest` refers to the
-[production](https://code.usgs.gov/ghsc/nshmp/nshmp-apps/-/tree/production) branch.
+### Pull Image
 
-### Download Registry Image
+To ensure you have the latest _nshmp-apps_ update associated with a specific tag,
+always first pull the image from Docker:
 
 ```bash
-docker pull usgs/nshmp-apps:production-latest
+docker pull code.usgs.gov:5001/ghsc/nshmp/nshmp-apps/nshmp-apps:<tag>
+```
+
+> Replace `<tag>` with one of the above tags.
+
+Example:
+
+```bash
+docker pull code.usgs.gov:5001/ghsc/nshmp/nshmp-apps/nshmp-apps:latest
 ```
 
 ### Run Registry Image
 
 ```bash
-docker run -p 8080:8080 usgs/nshmp-apps:production-latest
+docker run -p 8080:8080 code.usgs.gov:5001/ghsc/nshmp/nshmp-apps/nshmp-apps:latest
 ```
 
 ## Docker Environment Variables
@@ -70,7 +78,7 @@ By default the backend web services that nshmp-apps calls use
 the `BASE_SERVICE_URL` environment variable:
 
 ```bash
-docker run -p 8080:8080 -e BASE_SERVICE_URL="" usgs/nshmp-apps
+docker run -p 8080:8080 -e BASE_SERVICE_URL="" code.usgs.gov:5001/ghsc/nshmp/nshmp-apps/nshmp-apps:latest
 ```
 
 <br>
-- 
GitLab