Skip to content

Commit

Permalink
Parameterize jdk and nginx base images for better M1 support (#11262)
Browse files Browse the repository at this point in the history
currently on m1 macs, switching between building for arm vs amd64
architectures is a bit cumbersome because some of the base docker images
have not been parameterized yet, so you will run into build errors unless
you untag those base images every time you switch between architectures.

This PR should allow you switch freely between the two without needing
that manual step.

This PR also adds a single env var BUILD_ARCH that can be used to
switch between building for arm vs amd64.

With this PR we can build and push images for individual platform components
which is much faster than trying to redeploy everything when iterating on
changes that are limited to only a few components.

Ideally we'd have a github action that allowed us to deploy individual platform
components, but until that exists this seems like a reasonable solution for faster
iteration.
  • Loading branch information
git-phu authored and suhomud committed May 23, 2022
1 parent 1982999 commit 3a7809e
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 8 deletions.
3 changes: 2 additions & 1 deletion airbyte-bootloader/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ARG JDK_VERSION=17.0.1
FROM openjdk:${JDK_VERSION}-slim
ARG JDK_IMAGE=openjdk:${JDK_VERSION}-slim
FROM ${JDK_IMAGE}

ARG VERSION=0.38.2-alpha

Expand Down
3 changes: 2 additions & 1 deletion airbyte-container-orchestrator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ARG JDK_VERSION=17.0.1
FROM openjdk:${JDK_VERSION}-slim AS sync-attempt
ARG JDK_IMAGE=openjdk:${JDK_VERSION}-slim
FROM ${JDK_IMAGE} AS sync-attempt

ARG DOCKER_BUILD_ARCH=amd64

Expand Down
3 changes: 2 additions & 1 deletion airbyte-metrics/reporter/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ARG JDK_VERSION=17.0.1
FROM openjdk:${JDK_VERSION}-slim AS metrics-reporter
ARG JDK_IMAGE=openjdk:${JDK_VERSION}-slim
FROM ${JDK_IMAGE} AS metrics-reporter

ARG VERSION=0.38.2-alpha

Expand Down
3 changes: 2 additions & 1 deletion airbyte-scheduler/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ARG JDK_VERSION=17.0.1
FROM openjdk:${JDK_VERSION}-slim AS scheduler
ARG JDK_IMAGE=openjdk:${JDK_VERSION}-slim
FROM ${JDK_IMAGE} AS scheduler

ARG VERSION=0.38.2-alpha

Expand Down
3 changes: 2 additions & 1 deletion airbyte-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ARG JDK_VERSION=17.0.1
FROM openjdk:${JDK_VERSION}-slim AS server
ARG JDK_IMAGE=openjdk:${JDK_VERSION}-slim
FROM ${JDK_IMAGE} AS server

EXPOSE 8000

Expand Down
3 changes: 2 additions & 1 deletion airbyte-webapp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM nginx:1.19-alpine as webapp
ARG NGINX_IMAGE=nginx:1.19-alpine
FROM ${NGINX_IMAGE} as webapp

EXPOSE 80

Expand Down
3 changes: 2 additions & 1 deletion airbyte-workers/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ARG JDK_VERSION=17.0.1
FROM openjdk:${JDK_VERSION}-slim AS worker
ARG JDK_IMAGE=openjdk:${JDK_VERSION}-slim
FROM ${JDK_IMAGE} AS worker

ARG DOCKER_BUILD_ARCH=amd64

Expand Down
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,13 @@ def Task getDockerBuildTask(String artifactName, String projectDir, String build
return task ("buildDockerImage-$artifactName"(type: DockerBuildImage) {
def jdkVersion = System.getenv('JDK_VERSION') ?: '17.0.1'

def arch = System.getProperty("os.arch").toLowerCase()
def arch = System.getenv('BUILD_ARCH') ?: System.getProperty("os.arch").toLowerCase()
def isArm64 = arch == "aarch64" || arch == "arm64"

def buildPlatform = System.getenv('DOCKER_BUILD_PLATFORM') ?: isArm64 ? 'linux/arm64' : 'linux/amd64'
def alpineImage = System.getenv('ALPINE_IMAGE') ?: isArm64 ? 'arm64v8/alpine:3.14' : 'amd64/alpine:3.14'
def nginxImage = System.getenv('NGINX_IMAGE') ?: isArm64 ? 'arm64v8/nginx:1.19-alpine' : 'amd64/nginx:1.19-alpine'
def openjdkImage = System.getenv('JDK_IMAGE') ?: isArm64 ? "arm64v8/openjdk:${jdkVersion}-slim" : "amd64/openjdk:${jdkVersion}-slim"
def buildArch = System.getenv('DOCKER_BUILD_ARCH') ?: isArm64 ? 'arm64' : 'amd64'

inputDir = file("$projectDir/build/docker")
Expand All @@ -157,6 +159,8 @@ def Task getDockerBuildTask(String artifactName, String projectDir, String build
buildArgs.put('JDK_VERSION', jdkVersion)
buildArgs.put('DOCKER_BUILD_ARCH', buildArch)
buildArgs.put('ALPINE_IMAGE', alpineImage)
buildArgs.put('NGINX_IMAGE', nginxImage)
buildArgs.put('JDK_IMAGE', openjdkImage)
buildArgs.put('VERSION', buildVersion)
})
}
Expand Down

0 comments on commit 3a7809e

Please sign in to comment.