Skip to content

Commit 74b6340

Browse files
16francejgregario
andcommitted
Fix immutable GitHub CLI install for MicroVMs
Co-authored-by: Greg Jackson <2814770+gregario@users.noreply.github.com>
1 parent e23a02f commit 74b6340

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

aws/microvm-agent/Dockerfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ RUN dnf install -y \
1212
&& setsid --version \
1313
&& seq 1 1
1414

15-
RUN curl -fsSL https://cli.github.com/packages/rpm/gh-cli.repo \
16-
-o /etc/yum.repos.d/gh-cli.repo \
17-
&& dnf install -y gh-2.97.0-1 \
18-
&& dnf clean all \
15+
RUN GH_VERSION=2.97.0 \
16+
&& GH_SHA256=73ea440ecad9c9e284429997ee6f93577bc6f7bc6fba357ef62c53ad8fb641a5 \
17+
&& curl -fsSL "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_arm64.tar.gz" -o /tmp/gh.tgz \
18+
&& echo "${GH_SHA256} /tmp/gh.tgz" | sha256sum -c - \
19+
&& tar -xzf /tmp/gh.tgz -C /usr/local/bin --strip-components=2 "gh_${GH_VERSION}_linux_arm64/bin/gh" \
20+
&& rm /tmp/gh.tgz \
1921
&& gh --version
2022

2123
RUN curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-aarch64-2.36.5.zip" -o /tmp/awscliv2.zip \

cli/templates/aws/microvm-agent/Dockerfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ RUN dnf install -y \
1212
&& setsid --version \
1313
&& seq 1 1
1414

15-
RUN curl -fsSL https://cli.github.com/packages/rpm/gh-cli.repo \
16-
-o /etc/yum.repos.d/gh-cli.repo \
17-
&& dnf install -y gh-2.97.0-1 \
18-
&& dnf clean all \
15+
RUN GH_VERSION=2.97.0 \
16+
&& GH_SHA256=73ea440ecad9c9e284429997ee6f93577bc6f7bc6fba357ef62c53ad8fb641a5 \
17+
&& curl -fsSL "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_arm64.tar.gz" -o /tmp/gh.tgz \
18+
&& echo "${GH_SHA256} /tmp/gh.tgz" | sha256sum -c - \
19+
&& tar -xzf /tmp/gh.tgz -C /usr/local/bin --strip-components=2 "gh_${GH_VERSION}_linux_arm64/bin/gh" \
20+
&& rm /tmp/gh.tgz \
1921
&& gh --version
2022

2123
RUN curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-aarch64-2.36.5.zip" -o /tmp/awscliv2.zip \

cli/test/microvm-dockerfile.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ test("the canonical and packaged MicroVM Dockerfiles stay snapshot-safe and exec
1212
);
1313
assert.match(canonical, /^FROM public\.ecr\.aws\/lambda\/microvms:al2023-minimal@sha256:[a-f0-9]{64}$/m);
1414
assert.match(canonical, /dnf install -y[\s\\]+curl-minimal\b/);
15-
assert.match(canonical, /dnf install -y gh-\d+\.\d+\.\d+-\d+/);
15+
assert.doesNotMatch(canonical, /cli\.github\.com\/packages\/rpm/);
16+
assert.doesNotMatch(canonical, /dnf install -y gh-/);
17+
assert.match(canonical, /GH_VERSION=\d+\.\d+\.\d+/);
18+
assert.match(canonical, /GH_SHA256=[a-f0-9]{64}/);
19+
assert.match(
20+
canonical,
21+
/github\.com\/cli\/cli\/releases\/download\/v\$\{GH_VERSION\}\/gh_\$\{GH_VERSION\}_linux_arm64\.tar\.gz/,
22+
);
23+
assert.match(canonical, /\$\{GH_SHA256\} {2}\/tmp\/gh\.tgz" \| sha256sum -c -/);
1624
assert.match(canonical, /awscli-exe-linux-aarch64-\d+\.\d+\.\d+\.zip/);
1725
assert.match(canonical, /[a-f0-9]{64} {2}\/tmp\/awscliv2\.zip" \| sha256sum -c -/);
1826
assert.match(canonical, /rpm -q openssl-snapsafe-libs/);

0 commit comments

Comments
 (0)