Skip to content

Commit

Permalink
docker: make multi-platform atlantis image (#1943)
Browse files Browse the repository at this point in the history
* docker: multi-platform image for atlantis

* workflow: update for multi platform image builds

Signed-off-by: Rui Chen <[email protected]>

* update branch trigger for testing dev image

Signed-off-by: Rui Chen <[email protected]>

* revert to use testing-env:2021.08.31

Signed-off-by: Rui Chen <[email protected]>

* Revert "update branch trigger for testing dev image"

This reverts commit 266e04d.
  • Loading branch information
chenrui333 authored Dec 17, 2021
1 parent fad1c75 commit 45e8513
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 21 deletions.
7 changes: 6 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
*
!cmd/
!server/
!testdrive/
!main.go
!go.mod
!go.sum
!docker-entrypoint.sh
!atlantis
45 changes: 27 additions & 18 deletions .github/workflows/atlantis-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: arm64,arm

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Packages Container registry
uses: docker/login-action@v1
with:
Expand All @@ -25,28 +35,27 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

# Publish dev image to container registry
- name: build atlantis:dev image
- name: Build and push atlantis:dev image
if: ${{ github.event_name == 'push'}}
run: |
make build-service
docker build -t ghcr.io/runatlantis/atlantis:dev .
- name: publish atlantis:dev image
if: ${{ github.event_name == 'push'}}
run: |
docker push ghcr.io/runatlantis/atlantis:dev
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/arm64/v8,linux/amd64,linux/arm/v7
push: true
tags: |
ghcr.io/runatlantis/atlantis:dev
# Publish release to container registry
- name: populate release version
if: ${{ github.event_name == 'release'}}
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: build atlantis:$RELEASE_VERSION release image
- name: Build and push atlantis:$RELEASE_VERSION image
if: ${{ github.event_name == 'release'}}
run: |
make build-service
docker build -t ghcr.io/runatlantis/atlantis:$RELEASE_VERSION .
- name: publish atlantis:$RELEASE_VERSION release image
if: ${{ github.event_name == 'release'}}
run: |
docker push ghcr.io/runatlantis/atlantis:$RELEASE_VERSION
docker tag ghcr.io/runatlantis/atlantis:$RELEASE_VERSION ghcr.io/runatlantis/atlantis:latest
docker push ghcr.io/runatlantis/atlantis:latest
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/arm64/v8,linux/amd64,linux/arm/v7
push: true
tags: |
ghcr.io/runatlantis/atlantis:$RELEASE_VERSION
ghcr.io/runatlantis/atlantis:latest
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Stage 1: build artifact
FROM golang:1.17-alpine AS builder

WORKDIR /app
COPY . /app
RUN CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -v -o atlantis .

# Stage 2
# The runatlantis/atlantis-base is created by docker-base/Dockerfile.
FROM ghcr.io/runatlantis/atlantis-base:2021.08.31
FROM ghcr.io/runatlantis/atlantis-base:2021.12.15 AS base

# install terraform binaries
ENV DEFAULT_TERRAFORM_VERSION=1.1.1
Expand Down Expand Up @@ -35,7 +43,7 @@ RUN AVAILABLE_CONFTEST_VERSIONS="${DEFAULT_CONFTEST_VERSION}" && \
RUN ln -s /usr/local/bin/cft/versions/${DEFAULT_CONFTEST_VERSION}/conftest /usr/local/bin/conftest

# copy binary
COPY atlantis /usr/local/bin/atlantis
COPY --from=builder /app/atlantis /usr/local/bin/atlantis

# copy docker entrypoint
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
Expand Down

0 comments on commit 45e8513

Please sign in to comment.