Skip to content

Commit ab0004d

Browse files
committed
new container images for minimal alpine runtime
for this commit, image sizes: debian = 812.08 MB alpine = 647.28 MB alpine-slim-terraform = 209.72 MB alpine-slim-tofu = 204.51 MB Signed-off-by: Drew Paettie <[email protected]>
1 parent 9d78ee5 commit ab0004d

File tree

4 files changed

+51
-10
lines changed

4 files changed

+51
-10
lines changed

.github/workflows/atlantis-image.yml

+21-6
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
attestations: write
5858
strategy:
5959
matrix:
60-
image_type: [alpine, debian]
60+
image_type: [alpine, alpine-slim-terraform, alpine-slim-tofu, debian]
6161
runs-on: ubuntu-24.04
6262
env:
6363
# Set docker repo to either the fork or the main repo where the branch exists
@@ -202,7 +202,19 @@ jobs:
202202
runs-on: ubuntu-24.04
203203
strategy:
204204
matrix:
205-
image_type: [alpine, debian]
205+
image_type:
206+
- target: alpine
207+
EXPECT_TERRAFORM: true
208+
EXPECT_TOFU: true
209+
- target: alpine-slim-terraform
210+
EXPECT_TERRAFORM: true
211+
EXPECT_TOFU: false
212+
- target: alpine-slim-tofu
213+
EXPECT_TERRAFORM: false
214+
EXPECT_TOFU: true
215+
- target: debian
216+
EXPECT_TERRAFORM: true
217+
EXPECT_TOFU: true
206218
platform: [linux/arm64/v8, linux/amd64, linux/arm/v7]
207219
env:
208220
# Set docker repo to either the fork or the main repo where the branch exists
@@ -230,11 +242,11 @@ jobs:
230242
cache-to: type=gha,mode=max
231243
context: .
232244
build-args: |
233-
ATLANTIS_BASE_TAG_TYPE=${{ matrix.image_type }}
245+
ATLANTIS_BASE_TAG_TYPE=${{ matrix.image_type.target }}
234246
push: false
235247
load: true
236248
tags: "${{ env.DOCKER_REPO }}:goss-test"
237-
target: ${{ matrix.image_type }}
249+
target: ${{ matrix.image_type.target }}
238250

239251
- name: "Setup Goss"
240252
uses: e1himself/goss-installation-action@fbb6fb55d3e59c96045b2500eeb8ce0995d99ac1 # v1.2.1
@@ -243,15 +255,18 @@ jobs:
243255

244256
- name: Execute Goss tests
245257
run: |
246-
dgoss run --rm ${{ env.DOCKER_REPO }}:goss-test bash -c 'while true; do sleep 1; done;'
258+
dgoss run \
259+
-e EXPECT_TERRAFORM=${{matrix.image_type.EXPECT_TERRAFORM}} \
260+
-e EXPECT_TOFU=${{matrix.image_type.EXPECT_TOFU}} \
261+
--rm ${{ env.DOCKER_REPO }}:goss-test bash -c 'while true; do sleep 1; done;'
247262
248263
skip-build:
249264
needs: [changes]
250265
if: needs.changes.outputs.should-run-build == 'false'
251266
name: Build Image
252267
strategy:
253268
matrix:
254-
image_type: [alpine, debian]
269+
image_type: [alpine, alpine-slim-terraform, alpine-slim-tofu, debian]
255270
runs-on: ubuntu-24.04
256271
steps:
257272
- name: Harden Runner

Dockerfile

+12-4
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ RUN ./download-release.sh \
135135

136136
# Stage 2 - Alpine
137137
# Creating the individual distro builds using targets
138-
FROM alpine:${ALPINE_TAG} AS alpine
138+
FROM alpine:${ALPINE_TAG} AS alpine-base
139139

140140
EXPOSE ${ATLANTIS_PORT:-4141}
141141

@@ -150,9 +150,6 @@ RUN addgroup atlantis && \
150150

151151
# copy atlantis binary
152152
COPY --from=builder /app/atlantis /usr/local/bin/atlantis
153-
# copy terraform binaries
154-
COPY --from=deps /usr/local/bin/terraform/terraform* /usr/local/bin/
155-
COPY --from=deps /usr/local/bin/tofu/tofu* /usr/local/bin/
156153
# copy dependencies
157154
COPY --from=deps /usr/local/bin/conftest /usr/local/bin/conftest
158155
COPY --from=deps /usr/bin/git-lfs /usr/bin/git-lfs
@@ -179,6 +176,17 @@ USER atlantis
179176
ENTRYPOINT ["docker-entrypoint.sh"]
180177
CMD ["server"]
181178

179+
FROM alpine-base as alpine
180+
# copy terraform binaries
181+
COPY --from=deps /usr/local/bin/terraform/terraform* /usr/local/bin/
182+
COPY --from=deps /usr/local/bin/tofu/tofu* /usr/local/bin/
183+
184+
FROM alpine-base as alpine-slim-terraform
185+
COPY --from=deps /usr/local/bin/terraform/terraform /usr/local/bin/terraform
186+
187+
FROM alpine-base as alpine-slim-tofu
188+
COPY --from=deps /usr/local/bin/tofu/tofu /usr/local/bin/tofu
189+
182190
# Stage 2 - Debian
183191
FROM debian-base AS debian
184192

Makefile

+14
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ docker/dev: ## Build dev Dockerfile as atlantis-dev
8282
GOOS=linux GOARCH=amd64 go build -o atlantis .
8383
docker build -f Dockerfile.dev -t atlantis-dev .
8484

85+
ALPINE_MINIMAL_VARIANT := terraform
86+
.PHONY: docker/alpine-slim
87+
docker/alpine-slim: ## Build slim terraform or tofu images
88+
docker build --target alpine-slim-$(ALPINE_MINIMAL_VARIANT) -f Dockerfile -t localhost/$(IMAGE_NAME):latest-alpine-slim-$(ALPINE_MINIMAL_VARIANT) .
89+
90+
.PHONY: docker/alpine
91+
docker/alpine: ## Build Dockerfile for alpine runtime target
92+
docker build --target alpine -f Dockerfile -t localhost/$(IMAGE_NAME):latest-alpine .
93+
94+
.PHONY: docker/debian
95+
docker/debian: ## Build Dockerfile for debian runtime target
96+
docker build --target debian -f Dockerfile -t localhost/$(IMAGE_NAME):latest-debian .
97+
98+
8599
.PHONY: release
86100
release: ## Create packages for a release
87101
docker run -v $$(pwd):/go/src/github.com/runatlantis/atlantis cimg/go:1.20 sh -c 'cd /go/src/github.com/runatlantis/atlantis && scripts/binary-release.sh'

goss.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,20 @@ command:
2222
stdout: []
2323
stderr: []
2424

25+
{{if eq .Env.EXPECT_TERRAFORM "true"}}
2526
# ensure terraform is available
2627
terraform-available:
2728
exec: "terraform version"
2829
exit-status: 0
2930
stdout: []
3031
stderr: []
32+
{{end}}
3133

34+
{{if eq .Env.EXPECT_TOFU "true"}}
3235
# ensure tofu binary is available
3336
tofu-available:
3437
exec: "tofu version"
3538
exit-status: 0
3639
stdout: []
3740
stderr: []
41+
{{end}}

0 commit comments

Comments
 (0)