Skip to content

Commit 5ba1186

Browse files
DavidEdellDavid LinkoBrianSipos
authored
Feature/177 ghcr container publishing (#251)
* Added workflow to test publishing of built containers to ghcr.io * Second take (GPT-assisted refinements) * Fixed GHCR container naming. * Fixed default .env path * Updating quickstart to pull prebuilt containers by default * Pin puppet-lint to compatible version * Updated README. --------- Co-authored-by: David Linko <david.linko@jhuapl.edu> Co-authored-by: Brian Sipos <brian.sipos@jhuapl.edu>
1 parent 05050b4 commit 5ba1186

File tree

7 files changed

+68
-7
lines changed

7 files changed

+68
-7
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ COMPOSE_PROFILES=full,dev
1515
#MQTT_PORT=11883
1616

1717

18-
DOCKER_IMAGE_PREFIX=localhost/
18+
DOCKER_IMAGE_PREFIX=ghcr.io/nasa-ammos/anms/
1919
DOCKER_IMAGE_TAG=latest
2020

2121
ANMS_VERSION=0
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# On merge to main publish with the 'latest' label
2+
# Publish with release label when a releaes is published.
3+
name: Build and publish containers
4+
on:
5+
push:
6+
branches:
7+
- main
8+
release:
9+
types: [published]
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
14+
jobs:
15+
build-and-push:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
submodules: recursive
22+
- name: Log in to GitHub Container Registry
23+
uses: docker/login-action@v3
24+
with:
25+
registry: ${{ env.REGISTRY }}
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Set prefix
30+
run: |
31+
echo "DOCKER_IMAGE_PREFIX=${REGISTRY}/${REPO,,}/" >>${GITHUB_ENV}
32+
env:
33+
REPO: '${{ github.repository }}'
34+
- name: Set image tag
35+
id: vars
36+
run: |
37+
if [[ "${{ github.event_name }}" == "release" ]]; then
38+
echo "DOCKER_IMAGE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
39+
else
40+
echo "DOCKER_IMAGE_TAG=latest" >> $GITHUB_ENV
41+
fi
42+
43+
- name: Build and push base images via compose
44+
run: |
45+
docker compose build --push
46+
- name: Build and push testenv images via compose
47+
run: |
48+
docker compose -f testenv-compose.yml build --push

.github/workflows/puppet.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
bundler-cache: true
4848

4949
- name: Install puppet-lint
50-
run: gem install puppet-lint
50+
run: gem install puppet-lint -v 4.3.0
5151

5252
- name: Run puppet-lint
5353
run: puppet-lint puppet --sarif --ignore-paths 'puppet/modules/anms/files/*' > puppet-lint-results.sarif

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ docker stop $(docker ps -q); docker rm $(docker ps --all -q); docker system prun
7979

8080
`./quickstart.sh`
8181

82-
The quickstart script will configure, build, and start the ANMS system for the first time. See comments in the script for additional details, including optional ENV variables to override default behavior.
82+
The quickstart script will configure, pull, and start the ANMS system for the first time. See comments in the script for additional details, including optional ENV variables to override default behavior.
83+
84+
NOTICE: By default, quick start will pull pre-built containers from the github registry (ghcr.io). To force a rebuild, run it as `FORCE_REBULD=y ./quickstart.sh`. See the script header for details.
8385

8486
To stop the system use `podman compose -f testenv-compose.yml -f docker-compose.yml down`.
8587

@@ -104,6 +106,7 @@ Choose the appropriate docker, podman or podman-compose commands in the directio
104106
- Clone this repository recursively (`git clone --recursive https://github.com/NASA-AMMOS/anms.git`)
105107
- Setup Volume containing PKI configuration (certificate chains and private keys):
106108
- `./create_volume.sh ./puppet/modules/apl_test/files/anms/tls`
109+
- OPTIONAL: The next 2 steps will build all ANMS containers. If desired, these steps can be replaced with 'pull'ing prebuilt containers from ghcr.
107110
- Build Core Images using one of the following:
108111
- `docker compose -f docker-compose.yml build`
109112
- `podman compose -f docker-compose.yml build`
@@ -228,6 +231,8 @@ Refer to the `.env` file for port binding overrides, or `docker-compose.yml` for
228231

229232
### ANMS-UI is not visible at hostname
230233

234+
Ensure that you are running with the 'full' profile. This is the default option when using the `.env` file, however some older versions of podman-compose may not parse the COMPOSE_PROFILES ENV variable correctly. If this is the case, specify the profile explicitly in your compose up commands. For example, `podman compose --profile full up`.
235+
231236
Check the startup logs for any errors. If using podman, some port numbers may need to be remapped using the `.env` file to higher numbered ports, or the system configuration modified to adjust permissions (not recommended).
232237

233238
If you go to your browser and hostname:9030 (replace hostname with the server's hostname) and you see the ANMS UI,

anms-core/anms/routes/ARIs/reports.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ async def report_def_by_id(agent_id: int):
102102
final_res.append(addition)
103103
except Exception as e:
104104
logger.error(f"Error {e}, while processing nonce:{nonce_cbor} for agent: {agent_id_str}")
105-
105+
106106
return final_res
107107

108108

@@ -215,4 +215,4 @@ async def report_ac(agent_id: int, nonce_cbor: str):
215215
logger.error(err)
216216

217217
return list(exec_set_dir.values())
218-
218+

quickstart.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
# is not specified the #AUTHNZ_* lines in .env will be uncommented to
2626
# use ports that do not require root permissions.
2727
#
28+
# FORCE_BUILD=y If 'y', all ANMS-specific containers will be built locally.
29+
# Otherwise, prebuilt containers will be pulled from ghcr for quicker startup.
30+
#
2831
# Note: This script was created with assistance from openai/gpt-oss-120b
2932
set -e
3033

@@ -81,8 +84,12 @@ cp docker-compose.no-security-override.yml docker-compose.override.yml
8184
./create_volume.sh ./puppet/modules/apl_test/files/anms/tls
8285

8386
# Build system
84-
${DOCKER_CMD} compose build
85-
87+
if [[ ${FORCE_BUILD:-} == y ]]; then
88+
${DOCKER_CMD} compose --profile full --profile dev build
89+
else
90+
${DOCKER_CMD} compose --profile full --profile dev pull
91+
fi
92+
8693
# Start testenv (unless disabled)
8794
if [[ ${USE_TESTENV:-} != n ]]; then
8895
${DOCKER_CMD} compose -f testenv-compose.yml up -d

testenv.Containerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ RUN dnf -y install container-tools
128128
# Container service config
129129
RUN systemctl disable dnf-makecache.timer
130130

131+
COPY --chmod=755 deps/dtnma-tools/systemd/service_is_running.sh /usr/local/bin/service_is_running
131132

132133
# Image for the test environment manager transport with ION node and the
133134
# ion-app-proxy daemon

0 commit comments

Comments
 (0)