Skip to content

Commit 25f3257

Browse files
feat: switch to Alpine base image and update package installation method
1 parent 749b8c7 commit 25f3257

4 files changed

Lines changed: 20 additions & 16 deletions

File tree

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
!LICENSE
77
!README.md
88
!entrypoint.sh
9-
!pip
9+
§!alpine-packages.txt

Dockerfile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
FROM devopsinfra/docker-terragrunt:slim-latest AS builder
33

44
# Use a clean tiny image to store artifacts in
5-
FROM ubuntu:questing-20251217
6-
7-
# Disable interactive mode
8-
ENV DEBIAN_FRONTEND=noninteractive
5+
FROM alpine:3.23.4
96

107
# Copy all needed files
118
COPY --from=builder /usr/bin/terraform /usr/bin/format-hcl /usr/bin/fmt.sh /usr/bin/terragrunt-fmt.sh /usr/bin/
129
COPY entrypoint.sh /
10+
COPY alpine-packages.txt /tmp/alpine-packages.txt
1311

1412
# Install needed packages
15-
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
16-
# hadolint ignore=DL3008
17-
RUN set -eux ;\
18-
apt-get update -y ;\
19-
chmod +x /entrypoint.sh /usr/bin/format-hcl /usr/bin/fmt.sh /usr/bin/terragrunt-fmt.sh ;\
20-
apt-get clean ;\
21-
rm -rf /var/lib/apt/lists/*
13+
SHELL ["/bin/sh", "-euxo", "pipefail", "-c"]
14+
# hadolint ignore=DL3018
15+
RUN set -eux; \
16+
xargs -r apk add --no-cache < /tmp/alpine-packages.txt; \
17+
chmod +x /entrypoint.sh /usr/bin/terraform /usr/bin/format-hcl /usr/bin/fmt.sh /usr/bin/terragrunt-fmt.sh; \
18+
terraform version; \
19+
rm -rf /var/cache/*; \
20+
rm -rf /root/.cache/*; \
21+
rm -rf /tmp/*
2222

2323
# Finish up
24-
CMD ["terraform --version"]
24+
CMD ["terraform", "version"]
2525
WORKDIR /github/workspace
2626
ENTRYPOINT ["/entrypoint.sh"]

alpine-packages.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bash~=5.3

tests/docker/local-image.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ commandTests:
44
- name: OS version check
55
command: cat
66
args: [/etc/os-release]
7-
expectedOutput: [VERSION_ID="25\.10"]
7+
expectedOutput: [VERSION_ID=3\.23]
88

99
- name: Required tools installed
1010
command: bash
@@ -31,11 +31,14 @@ commandTests:
3131
>/tmp/check-write.log 2>&1 || (cat /tmp/check-write.log && exit 1)
3232
grep -q 'check=true requires write=false; overriding write to false' /tmp/check-write.log
3333
34-
- name: Apt cache cleaned
34+
- name: Temporary and APK cache cleaned
3535
command: bash
3636
args:
3737
- -lc
38-
- test ! -d /var/lib/apt/lists || test -z "$(find /var/lib/apt/lists -mindepth 1 -maxdepth 1 2>/dev/null)"
38+
- >-
39+
test ! -f /tmp/alpine-packages.txt &&
40+
(test ! -d /var/cache/apk || test -z "$(find /var/cache/apk -mindepth 1 -maxdepth 1 2>/dev/null)") &&
41+
(test ! -d /root/.cache || test -z "$(find /root/.cache -mindepth 1 -maxdepth 1 2>/dev/null)")
3942
4043
fileExistenceTests:
4144
- name: entrypoint exists

0 commit comments

Comments
 (0)