Skip to content

Commit f6a516e

Browse files
committed
switch to more standard & flexible CI/CD variable. Documentation++. Some no-longer-used lines decluttered
1 parent 11440c4 commit f6a516e

File tree

4 files changed

+30
-15
lines changed

4 files changed

+30
-15
lines changed

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ _**Note:** For urls like https://archive.org/services/project -- watch out for r
5656
### Customizing
5757
There are various options that can be used in conjunction with the `project.nomad` and `.gitlab-ci.yml` files, keys:
5858
```text
59+
NOMAD_VAR_BUILD_DEPLOY
5960
NOMAD_VAR_CHECK_PATH
6061
NOMAD_VAR_CHECK_PROTOCOL
6162
NOMAD_VAR_CHECK_TIMEOUT
@@ -81,12 +82,21 @@ NOMAD_VAR_VOLUMES
8182
- You can simply insert them, with values, in your project's `.gitlab-ci.yml` file before including _our_ [ci.yml](ci.yml) like above.
8283
- Examples 👇
8384
#### Don't actually deploy containers to nomad
84-
Perhaps your project just wants to leverage the CI (Continuous Integration) for [buil] and/or [test] steps - but not CD (Continuous Deployment). An example might be a back-end container that runs elsewhere and doesn't have web listener.
85+
Perhaps your project just wants to leverage the CI (Continuous Integration) for [build] and/or [test] steps - but not CD (Continuous Deployment). An example might be a back-end container that runs elsewhere and doesn't have web listener.
8586
```yaml
8687
variables:
8788
NOMAD_VAR_NO_DEPLOY: 'true'
8889
```
8990

91+
#### Build one docker image for CI and one docker image for CD
92+
If your project might want to build & use a larger docker image for the CI (Continuous Integration)
93+
and a smaller docker image for CD (Continuous Deploy), you can set this variable to an alternate
94+
Dockerfile location in your repo, relative to the top dir.
95+
```yaml
96+
variables:
97+
NOMAD_VAR_BUILD_DEPLOY: 'Dockerfile.deploy'
98+
```
99+
90100
#### Custom default RAM expectations from (default) 300 MB to 1 GB
91101
This value is the _expected_ value for your container's average running needs/usage, helpful for `nomad` scheduling purposes. It is a "soft limit" and we use *ten times* this amount to be the amount used for a "hard limit". If your allocated container exceeds the hard limit, the container may be restarted by `nomad` if there is memory pressure on the Virtual Machine the container is running on.
92102
```yaml
@@ -216,6 +226,16 @@ variables:
216226
NOMAD_VAR_NAMESPACE: 'team-titan'
217227
```
218228

229+
#### Only `docker tag` to `:latest` after all CI passes
230+
This is useful for repos that are setting up "serverless" docker images (typically don't do CD),
231+
and the `:latest` tag could get re-pulled anytime after that tag is pushed to the registry.
232+
The normal commit hash related tag will still get tagged & pushed, during [build], for CI tests.
233+
The `:latest` tag will get tagged & pushed *after* all CI tests have succeeded.
234+
```yaml
235+
variables:
236+
NOMAD_VAR_SERVERLESS: 'true'
237+
```
238+
219239

220240

221241
#### More customizations

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ if [ "$NOMAD_VAR_SERVERLESS" != "" ]; then
3434
PUSH_LATEST=
3535
fi
3636

37-
if [ "$BUILD_DEPLOY" = true ]; then
37+
if [ "$NOMAD_VAR_BUILD_DEPLOY" ]; then
3838
PUSH_LATEST=
3939
export CI_REGISTRY_TAG=${CI_COMMIT_SHA}-deploy
40-
export DOCKERFILE_PATH=$(ls Dockerfile.deploy Containerfile.deploy Containerfile.in.deploy 2>/dev/null |head -1)
40+
export DOCKERFILE_PATH=$NOMAD_VAR_BUILD_DEPLOY
4141
fi
4242

4343
if [[ -z "$CI_REGISTRY_TAG" ]]; then

ci.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# to whatever your Nomad cluster was setup to.
1414

1515

16-
# NOTE: changes to *this* repo, will fire of GitHub Actions here:
16+
# NOTE: changes to *this* repo, will fire off GitHub Actions here:
1717
# https://github.com/internetarchive/nomad/blob/main/.github/workflows/cicd.yml
1818
# which will re/make this container image:
1919
image: ghcr.io/internetarchive/nomad:main
@@ -29,12 +29,9 @@ build:
2929
# This was adapted & simplified from:
3030
# https://gitlab.com/gitlab-org/gitlab/-/raw/master/lib/gitlab/ci/templates/Jobs/Build.gitlab-ci.yml
3131
stage: build
32-
variables:
33-
DOCKER_HOST: 'unix:///run/podman/podman.sock'
34-
DOCKER_TLS_CERTDIR: ''
35-
DOCKER_BUILDKIT: 1
3632
script:
3733
# https://github.com/internetarchive/nomad/blob/main/build.sh
34+
- export NOMAD_VAR_BUILD_DEPLOY=""
3835
- /build.sh
3936
artifacts:
4037
reports:
@@ -48,14 +45,11 @@ build_deploy:
4845
stage: build
4946
script:
5047
# https://github.com/internetarchive/nomad/blob/main/build.sh
51-
- export BUILD_DEPLOY=true
5248
- /build.sh
53-
5449
rules:
55-
- exists:
56-
- Dockerfile.deploy
57-
- Containerfile.deploy
58-
- Containerfile.in.deploy
50+
- if: '$BUILD_DISABLED'
51+
when: never
52+
- if: '$NOMAD_VAR_BUILD_DEPLOY && $CI_COMMIT_BRANCH'
5953

6054
deploy:
6155
stage: deploy

deploy.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ function main() {
2323
NOMAD_VAR_DEPLOY_WITH_PODMAN=${NOMAD_VAR_DEPLOY_WITH_PODMAN:-""}
2424
NOMAD_VAR_LEGACY_SERVICE_NAMES_URLPREFIX=${NOMAD_VAR_LEGACY_SERVICE_NAMES_URLPREFIX:-""}
2525
CI_REGISTRY_TAG=${CI_REGISTRY_TAG:-""}
26+
NOMAD_VAR_BUILD_DEPLOY=${NOMAD_VAR_BUILD_DEPLOY:-""}
2627
fi
2728

28-
if [ -e Dockerfile.deploy -o -e Containerfile.deploy -o -e Containerfile.in.deploy ]; then
29+
if [ "$NOMAD_VAR_BUILD_DEPLOY" ]; then
2930
CI_REGISTRY_TAG=${CI_COMMIT_SHA}-deploy
3031
else
3132
CI_REGISTRY_TAG=$CI_COMMIT_SHA

0 commit comments

Comments
 (0)