Skip to content

Commit

Permalink
chore: Build Meltano Docker image for arm64 and amd64 (meltano#7610)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillDaSilva committed Apr 26, 2023
1 parent 1a24fed commit 7aac488
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
54 changes: 43 additions & 11 deletions .github/actions/docker-build-scan-push/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,45 @@ inputs:
runs:
using: 'composite'
steps:
# Per: https://github.com/marketplace/actions/build-and-push-docker-images
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Build the image
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Prepare the tags
id: prepare-tags
shell: bash
run: |
BUILD_CMD="docker build \
--build-arg PYTHON_VERSION=${{ inputs.python-version }} \
--build-arg MELTANO_VERSION=${{ inputs.meltano-version }} \
$(echo "${{ inputs.tags }}" | sed "s/^/-t ${{ inputs.registry }}\/meltano\/meltano:/" | tr '\n' ' ') \
docker/meltano"
echo "${BUILD_CMD}"
eval "${BUILD_CMD}"
echo "tags=$(echo "${{ inputs.tags }}" | sed "s/^/${{ inputs.registry }}\/meltano\/meltano:/" | tr '\n' ',')" >> $GITHUB_OUTPUT
- name: Build the image for all supported architectures
uses: docker/build-push-action@v4
with:
context: docker/meltano
build-args: |
PYTHON_VERSION=${{ inputs.python-version }}
MELTANO_VERSION=${{ inputs.meltano-version }}
tags: ${{ steps.prepare-tags.outputs.tags }}
platforms: linux/amd64,linux/arm64
# Can't load multi-arch images; use workaround instead:
# https://github.com/docker/buildx/issues/59#issuecomment-1168619521
# We build both images first to ensure they can be built, and to
# store them in the build cache. Then we load one of them, and scan
# it. Then we optionally push both of them to the registry.
load: false
push: false

- name: Load the amd64 image for scanning
uses: docker/build-push-action@v4
with:
context: docker/meltano
build-args: |
PYTHON_VERSION=${{ inputs.python-version }}
MELTANO_VERSION=${{ inputs.meltano-version }}
tags: ${{ steps.prepare-tags.outputs.tags }}
platforms: linux/amd64
load: true

- name: Get the ID of the image
id: get-image-id
Expand Down Expand Up @@ -88,5 +113,12 @@ runs:

- name: Push the scanned image to the registry
if: ${{ inputs.push == 'true' }}
shell: bash
run: docker image push --all-tags ${{ inputs.registry }}/meltano/meltano
uses: docker/build-push-action@v4
with:
context: docker/meltano
build-args: |
PYTHON_VERSION=${{ inputs.python-version }}
MELTANO_VERSION=${{ inputs.meltano-version }}
tags: ${{ steps.prepare-tags.outputs.tags }}
platforms: linux/amd64,linux/arm64
push: true
3 changes: 1 addition & 2 deletions docker/meltano/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ ENV PIP_NO_CACHE_DIR=1

RUN mkdir "${WORKDIR}" && \
apt-get update && \
apt-get install -y build-essential git && \
apt-get install unixodbc unixodbc-dev freetds-dev freetds-bin tdsodbc libkrb5-dev libssl-dev -y &&\
apt-get install -y build-essential freetds-bin freetds-dev git libkrb5-dev libssl-dev tdsodbc unixodbc unixodbc-dev && \
rm -rf /var/cache/apt/archives /var/lib/apt/lists/*

WORKDIR "${WORKDIR}"
Expand Down

0 comments on commit 7aac488

Please sign in to comment.