diff --git a/.dockerignore b/.dockerignore index 72ec49f7c8..874eeae12f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,8 @@ * +!cmd/ +!server/ +!testdrive/ +!main.go +!go.mod +!go.sum !docker-entrypoint.sh -!atlantis diff --git a/.github/workflows/atlantis-image.yml b/.github/workflows/atlantis-image.yml index 6b769dd3aa..14830bc199 100644 --- a/.github/workflows/atlantis-image.yml +++ b/.github/workflows/atlantis-image.yml @@ -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: @@ -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 diff --git a/Dockerfile b/Dockerfile index 15be9f598f..857d6991e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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