Skip to content

Commit 719a1aa

Browse files
committed
Merge branch 'main' of github.com:CDLUC3/mrt-admin-sinatra
2 parents 69b817e + dd96e69 commit 719a1aa

File tree

1 file changed

+102
-4
lines changed

1 file changed

+102
-4
lines changed

present/tagging/build.md

Lines changed: 102 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,69 @@ Merritt Java services can be configured to auto-deploy to ECS Dev from the main
159159

160160
### Image Rebuild Conventions
161161

162-
Each of the service branch/tags that are registered in the [ecs manifest](https://github.com/CDLUC3/mrt-service-release-manifest/blob/main/ecs-release-manifest.yaml) will be rebuilt daily. Each rebuild will also create an "archive" tag. A lifecycle policy will expire old archive tags based on image push date.
162+
Each of the service branch/tags that are registered in the [ecs manifest](https://github.com/CDLUC3/mrt-service-release-manifest/blob/main/ecs-release-manifest.yaml) will be rebuilt daily.
163+
164+
Each rebuild will also create an "archive" tag. A lifecycle policy will expire old archive tags based on image push date.
163165

164166
- Docker Image Patched After Code Deployment of tag `tag`
165-
- `subservice:archive-${stack}-${TAG_OR_BRANCH}-${BUILDDATE}`
167+
- `subservice:archive-${TAG_OR_BRANCH}-${BUILDDATE}`
168+
169+
<details>
170+
171+
<summary> Sample Rebuild Code</summary>
172+
173+
```
174+
git fetch --all
175+
if [[ "$MODE" == "OnDemand" ]]
176+
then
177+
for stack in ecs-dev ecs-ephemeral ecs-stg ecs-prd
178+
do
179+
TAG_ECS=$(yq -r ".\"ecs-tagmap\".\"${REPONAME}\".\"$stack\"" /tmp/ecs-release-manifest.yaml)
180+
if [[ "$TAG_ECS" == "null" ]]
181+
then
182+
echo "${TAG_ECS} undefined for ${stack}"
183+
elif [[ "$BRANCHTAG" == "$TAG_ECS" ]]
184+
then
185+
echo "${TAG_ECS} Already Built for ${stack}"
186+
else
187+
# perform get checkout get the specific dockerfile
188+
git checkout $TAG_ECS
189+
190+
#mkdir -p store-war/target
191+
192+
# this command will succeed if TAG_ECS is a valid tag
193+
mvn dependency:copy \
194+
-DrepoUrl=${CODEARTIFACT_URL} \
195+
-Dartifact=org.cdlib.mrt:mrt-storewar:${TAG_ECS}:war \
196+
-DoutputDirectory=store-war/target \
197+
-Dtransitive=false
198+
199+
# if TAG_ECS is a branch, then rebuild the war
200+
if [[ $? -ne 0 ]]
201+
then
202+
mvn -ntp clean install -Ddocker.skip -DskipITs -Dmaven.test.skip=true
203+
bstate=$?
204+
mkdir -p /build/static
205+
echo "build_tag: ${TAG_ECS}" > /build/static/build.content.txt
206+
${JAVA_HOME}/bin/jar uf $(ls store-war/target/mrt-storewar-*.war) -C /build static/build.content.txt
207+
fi
208+
209+
if [[ $bstate -eq 0 ]]
210+
then
211+
docker build --quiet --push \
212+
--build-arg ECR_REGISTRY=${ECR_REGISTRY} \
213+
-t ${ECR_REGISTRY}/${REPONAME}:${TAG_ECS} .
214+
215+
docker build --quiet --push \
216+
--build-arg ECR_REGISTRY=${ECR_REGISTRY} \
217+
-t ${ECR_REGISTRY}/${REPONAME}:archive-${TAG_ECS}-${BUILDDATE} .
218+
fi
219+
fi
220+
done
221+
fi
222+
```
223+
224+
</details>
166225

167226
---
168227

@@ -255,10 +314,49 @@ Merritt UI and Admin Tool will auto-deploy to ECS development environments from
255314

256315
### Image Rebuild Conventions
257316

258-
Each of the service branch/tags that are registered in the [ecs manifest](https://github.com/CDLUC3/mrt-service-release-manifest/blob/main/ecs-release-manifest.yaml) will be rebuilt daily. Each rebuild will also create an "archive" tag. A lifecycle policy will expire old archive tags based on image push date.
317+
Each of the service branch/tags that are registered in the [ecs manifest](https://github.com/CDLUC3/mrt-service-release-manifest/blob/main/ecs-release-manifest.yaml) will be rebuilt daily.
318+
319+
Each rebuild will also create an "archive" tag. A lifecycle policy will expire old archive tags based on image push date.
259320

260321
- Docker Image Patched After Code Deployment of tag `tag`
261-
- `subservice:archive-archive-${stack}-${TAG_OR_BRANCH}-${BUILDDATE}`
322+
- `subservice:archive-${TAG_OR_BRANCH}-${BUILDDATE}`
323+
324+
325+
<details>
326+
327+
<summary> Sample Rebuild Code</summary>
328+
329+
```
330+
git fetch --all
331+
# daily / on-demand rebuild of deployed images
332+
# note that this also applied to a main branch build
333+
if [[ "$MODE" == "OnDemand" ]]
334+
then
335+
for stack in ecs-dev ecs-ephemeral ecs-dbsnapshot ecs-stg ecs-prd
336+
do
337+
TAG_ECS=$(yq -r ".\"ecs-tagmap\".\"${REPONAME}\".\"$stack\"" /tmp/ecs-release-manifest.yaml)
338+
339+
if [[ "$BRANCHTAG" != "$TAG_ECS" ]]
340+
then
341+
git checkout $TAG_ECS
342+
CA_CERT_NAME=UC3-Self-Signed-CA.crt
343+
aws ssm get-parameter --name /uc3/default/uc3_ca/$CA_CERT_NAME --output text --query 'Parameter.Value' > $CA_CERT_NAME
344+
345+
docker build --quiet --push \
346+
--build-arg ECR_REGISTRY=${ECR_REGISTRY} \
347+
--build-arg BUILD_TAG=${TAG_ECS} \
348+
-t ${ECR_REGISTRY}/${REPONAME}:$TAG_ECS .
349+
350+
docker build --quiet --push \
351+
--build-arg ECR_REGISTRY=${ECR_REGISTRY} \
352+
--build-arg BUILD_TAG=${TAG_ECS} \
353+
-t ${ECR_REGISTRY}/${REPONAME}:archive-${TAG_ECS}-${BUILDDATE} .
354+
fi
355+
done
356+
fi
357+
```
358+
359+
</details>
262360

263361
----
264362

0 commit comments

Comments
 (0)