Skip to content

Commit

Permalink
Create .env file from versioner to avoid hard-coded duplication of po…
Browse files Browse the repository at this point in the history
…rt numbers
  • Loading branch information
JonJagger committed Feb 2, 2025
1 parent 220ed1e commit de06f84
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
6 changes: 0 additions & 6 deletions .env

This file was deleted.

9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
/reports
.DS_Store

.env

reports/*
reports/.*

snyk.container.scan.json
snyk.code.scan.json
snyk.code.scan.json
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- An HTTP [Ruby](https://www.ruby-lang.org) [Sinatra](http://sinatrarb.com/) web service, offering a Group/Kata model+persistence API.
- Demonstrates a [Kosli](https://www.kosli.com/) instrumented [GitHub CI workflow](https://app.kosli.com/cyber-dojo/flows/saver-ci/trails/)
deploying, with Continuous Compliance, to [staging](https://app.kosli.com/cyber-dojo/environments/aws-beta/snapshots/) and [production](https://app.kosli.com/cyber-dojo/environments/aws-prod/snapshots/) AWS environments.
- Uses patterns from https://www.kosli.com/blog/using-kosli-attest-in-github-action-workflows-some-tips/
- Uses compliance reporting patterns from https://www.kosli.com/blog/using-kosli-attest-in-github-action-workflows-some-tips/

# Development

Expand Down Expand Up @@ -61,10 +61,10 @@ $ make {metrics_coverage_server|metrics_coverage_client}

## Probe

- [GET alive?](docs/api.md#get-alive)
- [GET ready?](docs/api.md#get-ready)
- [GET sha](docs/api.md#get-sha)
- [GET base_image](docs/api.md#get-base-image)
* [GET alive?](docs/api.md#get-alive)
* [GET ready?](docs/api.md#get-ready)
* [GET sha](docs/api.md#get-sha)
* [GET base_image](docs/api.md#get-base-image)

# Screenshots

Expand Down
15 changes: 12 additions & 3 deletions bin/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,26 @@ echo_base_image()
{
local -r json="$(curl --fail --silent --request GET https://beta.cyber-dojo.org/saver/base_image)"
echo "${json}" | jq -r '.base_image'
#echo cyberdojo/sinatra-base:edb2887@sha256:d40099e71ac46310a58cea1640f5fb842dbaadc148e4973bfb8d2092516370a1
}

echo_env_vars()
{
# --build-arg ...
# Setup port env-vars in .env file using versioner
local -r env_filename="${ROOT_DIR}/.env"
docker run --rm cyberdojo/versioner | grep PORT > "${env_filename}"
echo "CYBER_DOJO_SAVER_CLIENT_PORT=4538" >> "${env_filename}"

# Get identities of dependent services from versioner
# There are none

# Set env-vars for this repos runner service
if [[ ! -v CYBER_DOJO_SAVER_BASE_IMAGE ]] ; then
echo CYBER_DOJO_SAVER_BASE_IMAGE="$(echo_base_image)"
echo CYBER_DOJO_SAVER_BASE_IMAGE="$(echo_base_image)" # --build-arg
fi
if [[ ! -v COMMIT_SHA ]] ; then
local -r sha="$(cd "${ROOT_DIR}" && git rev-parse HEAD)"
echo COMMIT_SHA="${sha}"
echo COMMIT_SHA="${sha}" # --build-arg
fi

# From versioner ...
Expand Down

0 comments on commit de06f84

Please sign in to comment.