Skip to content

Commit bcfa336

Browse files
committed
Separate builder and runner image
1 parent 1355b12 commit bcfa336

File tree

5 files changed

+99
-23
lines changed

5 files changed

+99
-23
lines changed

.github/workflows/detect-changes-matrix.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
core:
1212
value: ${{ jobs.detect-changes.outputs.core }}
1313
description: "Determine if any core changes per git commit changes"
14+
infra:
15+
value: ${{ jobs.detect-changes.outputs.infra }}
16+
description: "Determine if any changes to docker infra"
1417

1518
jobs:
1619
detect-changes:
@@ -42,6 +45,8 @@ jobs:
4245
- 'integrations/**'
4346
- '!integrations/**/*.md'
4447
- '!integrations/_infra/*'
48+
infra:
49+
- 'integrations/_infra/*'
4550
4651
- name: Set integrations and all matrix
4752
id: set-all-matrix
@@ -50,8 +55,11 @@ jobs:
5055
HAS_CORE=${{ steps.changed-files.outputs.core_all_changed_files != '[]' }}
5156
echo "Core changes : ${HAS_CORE}"
5257
MATRIX=$(node -e "integrations=${INTEGRATIONS}; hasCore=${HAS_CORE}; console.log(JSON.stringify(hasCore ? integrations.concat(['.']) : integrations))")
58+
HAS_INFRA=${{ steps.changed-files.outputs.infra_all_changed_files != '[]' }}
59+
echo "Infra changes : ${HAS_INFRA}"
5360
echo "Integration changes : ${INTEGRATIONS}"
5461
echo "All changes : ${MATRIX}"
5562
echo "core=${HAS_CORE}" >> $GITHUB_OUTPUT
5663
echo "integrations=${INTEGRATIONS}" >> $GITHUB_OUTPUT
5764
echo "matrix=${MATRIX}" >> $GITHUB_OUTPUT
65+
echo "infra=${HAS_INFRA}" >> $GITHUB_OUTPUT

.github/workflows/infra.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build infra images
2+
on:
3+
pull_request:
4+
workflow_dispatch:
5+
6+
jobs:
7+
detect-changes:
8+
uses: ./.github/workflows/detect-changes-matrix.yml
9+
build-infra:
10+
# runs-on: ${{ matrix.platform == 'linux/arm64' && 'macos-13' || 'ubuntu-latest' }}
11+
runs-on: 'ubuntu-latest'
12+
if: ${{ needs.detect-changes.outputs.infra == 'true' }}
13+
steps:
14+
- name: Check out code
15+
uses: actions/checkout@v4
16+
17+
# - name: Setup docker (missing on MacOS)
18+
# if: matrix.platform == 'linux/arm64'
19+
# uses: douglascamata/setup-docker-macos-action@v1-alpha
20+
21+
- name: Set up QEMU
22+
uses: docker/setup-qemu-action@v3
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Login to Docker Hub
28+
uses: docker/login-action@v3
29+
with:
30+
registry: ghcr.io
31+
username: ${{ secrets.DOCKER_MACHINE_USER }}
32+
password: ${{ secrets.DOCKER_MACHINE_TOKEN }}
33+
34+
- name: Build Builder Image
35+
uses: docker/build-push-action@v6
36+
with:
37+
context: .
38+
file: ./integrations/_infra/Dockerfile.base.builder
39+
platforms: linux/amd64,linux/arm64
40+
push: true
41+
tags: ghcr.io/port-labs/port-ocean-base-builder:latest
42+
43+
- name: Build Runner Image
44+
uses: docker/build-push-action@v6
45+
with:
46+
context: .
47+
file: ./integrations/_infra/Dockerfile.base.runner
48+
platforms: linux/amd64,linux/arm64
49+
push: true
50+
tags: ghcr.io/port-labs/port-ocean-base-runner:latest

integrations/_infra/Dockerfile.Deb

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
ARG BASE_PYTHON_IMAGE=debian:trixie-slim
1+
ARG BASE_BUILDER_PYTHON_IMAGE=ghcr.io/port-labs/port-ocean-base-builder:latest
2+
ARG BASE_RUNNER_PYTHON_IMAGE=ghcr.io/port-labs/port-ocean-base-runner:latest
23

3-
FROM ${BASE_PYTHON_IMAGE} AS base
4+
FROM ${BASE_BUILDER_PYTHON_IMAGE} AS base
45

56
ARG BUILD_CONTEXT
67
ARG BUILDPLATFORM
@@ -10,29 +11,13 @@ ENV LIBRDKAFKA_VERSION=1.9.2 \
1011
POETRY_VIRTUALENVS_IN_PROJECT=1 \
1112
PIP_ROOT_USER_ACTION=ignore
1213

13-
RUN apt-get update \
14-
&& apt-get install -y \
15-
--no-install-recommends \
16-
wget \
17-
g++ \
18-
libssl-dev \
19-
autoconf \
20-
automake \
21-
libtool \
22-
curl \
23-
librdkafka-dev \
24-
python3 \
25-
python3-pip \
26-
python3-poetry \
27-
&& apt-get clean
28-
2914
WORKDIR /app
3015

3116
COPY ./${BUILD_CONTEXT}/pyproject.toml ./${BUILD_CONTEXT}/poetry.lock /app/
3217

3318
RUN poetry install --without dev --no-root --no-interaction --no-ansi --no-cache
3419

35-
FROM ${BASE_PYTHON_IMAGE} AS prod
20+
FROM ${BASE_RUNNER_PYTHON_IMAGE} AS prod
3621

3722
ARG INTEGRATION_VERSION
3823
ARG BUILD_CONTEXT
@@ -45,10 +30,6 @@ LABEL org.opencontainers.image.source=https://github.com/port-labs/ocean
4530

4631
ENV PIP_ROOT_USER_ACTION=ignore
4732

48-
RUN apt-get update \
49-
&& apt-get install -y --no-install-recommends librdkafka-dev python3 \
50-
&& apt-get clean
51-
5233
WORKDIR /app
5334

5435
# Copy the application code
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
ARG BASE_PYTHON_IMAGE=debian:trixie-slim
2+
FROM ${BASE_PYTHON_IMAGE}
3+
4+
LABEL org.opencontainers.image.source=https://github.com/port-labs/ocean
5+
6+
ENV LIBRDKAFKA_VERSION=1.9.2 \
7+
PYTHONUNBUFFERED=1 \
8+
POETRY_VIRTUALENVS_IN_PROJECT=1 \
9+
PIP_ROOT_USER_ACTION=ignore
10+
11+
RUN apt-get update \
12+
&& apt-get install -y \
13+
--no-install-recommends \
14+
wget \
15+
g++ \
16+
libssl-dev \
17+
autoconf \
18+
automake \
19+
libtool \
20+
curl \
21+
librdkafka-dev \
22+
python3 \
23+
python3-pip \
24+
python3-poetry \
25+
&& apt-get clean
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ARG BASE_PYTHON_IMAGE=debian:trixie-slim
2+
FROM ${BASE_PYTHON_IMAGE}
3+
4+
LABEL org.opencontainers.image.source=https://github.com/port-labs/ocean
5+
6+
ENV LIBRDKAFKA_VERSION=1.9.2
7+
8+
ENV PIP_ROOT_USER_ACTION=ignore
9+
10+
RUN apt-get update \
11+
&& apt-get install -y --no-install-recommends librdkafka-dev python3 \
12+
&& apt-get clean

0 commit comments

Comments
 (0)