Skip to content

Commit 9412252

Browse files
committed
Update ACA image workflow to pass ref to dockerfiles [no ci]
1 parent 5445278 commit 9412252

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

.ci/docker/Dockerfile.aca-rocky

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ LABEL org.opencontainers.image.vendor NSA Laboratory for Advanced Cybersecurity
33
LABEL org.opencontainers.image.source https://github.com/nsacyber/hirs
44
LABEL org.opencontainers.image.description NSA\'s HIRS Attestation Certificate Authority. Expose port 8443 to access the portal from outside the container.
55

6+
# REF can be specified as a docker run environment variable to select the HIRS branch to work with
7+
ENV REF=main
8+
69
SHELL ["/bin/bash", "-c"]
710

811
# Rocky 9 has a different channel for some apps
@@ -50,7 +53,7 @@ RUN echo "#!/bin/bash" > /tmp/tpm_config && \
5053
EXPOSE 8443
5154

5255
# Checkout HIRS
53-
RUN git clone -b main https://github.com/nsacyber/HIRS.git /repo
56+
RUN git clone -b ${REF} https://github.com/nsacyber/HIRS.git /repo
5457

5558
# Defensive copy of the repo so it's easy to start fresh if needed
5659
RUN mkdir /hirs

.ci/docker/Dockerfile.aca-windows

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ LABEL org.opencontainers.image.source https://github.com/nsacyber/hirs
99
LABEL org.opencontainers.image.description NSA\'s HIRS Attestation Certificate Authority in a Windows-native image. Expose port 8443 to access the portal from outside the container.
1010
LABEL org.opencontainers.image.base.name mcr.microsoft.com/powershell:${BASE_IMAGE_TAG}
1111

12+
# REF can be specified as a docker run environment variable to select the HIRS branch to work with
13+
ENV REF=main
14+
1215
SHELL ["pwsh", "-Command"]
1316

1417
# Output Powershell Version
@@ -105,11 +108,11 @@ RUN setx PATH '%JAVA_HOME%\bin;C:\Program Files\MariaDB 11.1\bin;%GIT_HOME%\bin;
105108
# Echo PATH after update
106109
RUN echo $Env:PATH
107110

108-
# Clone HIRS main
111+
# Clone HIRS main (or REF)
109112
WORKDIR C:/
110113
RUN git config --global --add core.autocrlf false
111114
RUN git config --global --add safe.directory '*'
112-
RUN git clone -b main https://github.com/nsacyber/hirs.git C:/repo
115+
RUN git clone -b ${REF} https://github.com/nsacyber/hirs.git C:/repo
113116

114117
# Defensive copy of the repo so it's easy to start fresh if needed
115118
WORKDIR C:/repo

.github/workflows/create_aca_images.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
echo "PUBLIC_IMAGE_TAG=$PUBLIC_IMAGE_NAME:$IMAGE_TAG_VAR" >> "$GITHUB_OUTPUT"
5252
- name: Print env
5353
run: |
54+
echo GITHUB_REF=$GITHUB_REF
5455
echo DOCKERFILE_ROCKY=$DOCKERFILE_ROCKY
5556
echo DOCKERFILE_WINDOWS=$DOCKERFILE_WINDOWS
5657
echo IMAGE_NAME_ROCKY=$IMAGE_NAME_ROCKY
@@ -86,6 +87,7 @@ jobs:
8687
with:
8788
context: "{{defaultContext}}:.ci/docker"
8889
file: Dockerfile.${{env.DOCKERFILE_ROCKY}}
90+
build-args: REF=$GITHUB_REF
8991
tags: ${{env.TAG}}
9092
push: true
9193

@@ -108,7 +110,7 @@ jobs:
108110
- name: Build the docker image for ${{ github.repository }}
109111
run: |
110112
cd ./.ci/docker
111-
docker build -f ./Dockerfile.${{env.DOCKERFILE_WINDOWS}} -t ${{env.TAG}} .
113+
docker build -e "REF=$GITHUB_REF" -f ./Dockerfile.${{env.DOCKERFILE_WINDOWS}} -t ${{env.TAG}} .
112114
113115
- name: Push the docker image
114116
run: |
@@ -133,7 +135,7 @@ jobs:
133135
- name: Build the docker image for ${{ github.repository }}
134136
run: |
135137
cd ./.ci/docker
136-
docker build -f ./Dockerfile.${{env.DOCKERFILE_WINDOWS}} -t ${{env.TAG}} --build-arg BASE_IMAGE_TAG=lts-windowsservercore-1809 .
138+
docker build -e "REF=$GITHUB_REF" -f ./Dockerfile.${{env.DOCKERFILE_WINDOWS}} -t ${{env.TAG}} --build-arg BASE_IMAGE_TAG=lts-windowsservercore-1809 .
137139
138140
- name: Push the docker image
139141
run: |

0 commit comments

Comments
 (0)