Skip to content

Commit 8bf8484

Browse files
committed
multiarch init
1 parent f6d31eb commit 8bf8484

File tree

5 files changed

+89
-24
lines changed

5 files changed

+89
-24
lines changed

.github/actions/build/action.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Docker Build
2+
description: Build Docker image
3+
inputs:
4+
file:
5+
description: Dockerfile
6+
required: false
7+
platform:
8+
description: Docker build platform
9+
default: linux/amd64
10+
required: false
11+
runs:
12+
using: composite
13+
steps:
14+
- uses: docker/setup-qemu-action@v2
15+
- uses: docker/setup-buildx-action@v2
16+
- uses: actions/setup-python@v4
17+
with:
18+
python-version: "3.11"
19+
- run: pip install pipenv
20+
shell: bash
21+
- run: make ${{ inputs.file }} PLATFORM=${{ inputs.platform }}
22+
shell: bash

.github/actions/lint/action.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Docker Build
2+
description: Build Docker image
3+
inputs:
4+
file:
5+
description: Dockerfile
6+
required: false
7+
runs:
8+
using: composite
9+
steps:
10+
- uses: actions/setup-node@v3
11+
- run: npm install -g dockerlint
12+
shell: bash
13+
- run: dockerlint -f ${{ inputs.file }}
14+
shell: bash

.github/workflows/build.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,28 @@ jobs:
1212
matrix:
1313
file:
1414
- Dockerfile
15-
- Dockerfile.alpine
1615
- Dockerfile.jupyter
1716
- Dockerfile.slim
17+
platform:
18+
- linux/amd64
19+
- linux/arm64
1820
steps:
1921
- uses: actions/checkout@v3
20-
- uses: actions/setup-node@v3
21-
- uses: actions/setup-python@v4
22+
- uses: ./.github/actions/lint
2223
with:
23-
python-version: "3.11"
24-
- run: npm install -g dockerlint
25-
- run: dockerlint -f ${{ matrix.file }}
26-
- run: pip install pipenv
27-
- run: make ${{ matrix.file }}
24+
file: ${{ matrix.file }}
25+
- uses: ./.github/actions/build
26+
with:
27+
file: ${{ matrix.file }}
28+
platform: ${{ matrix.platform }}
29+
alpine:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v3
33+
- uses: ./.github/actions/lint
34+
with:
35+
file: Dockerfile.alpine
36+
- uses: ./.github/actions/build
37+
with:
38+
file: Dockerfile.alpine
39+
platform: linux/amd64

.github/workflows/push.yml

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,44 @@ on:
44
tags:
55
- "*"
66
jobs:
7-
lint:
8-
runs-on: ubuntu-latest
9-
steps:
10-
- uses: actions/checkout@v3
11-
- uses: actions/setup-node@v3
12-
- run: npm install -g dockerlint
13-
- run: dockerlint
147
build-push:
158
runs-on: ubuntu-latest
16-
needs: lint
179
strategy:
1810
matrix:
19-
target:
20-
- alpine
21-
- jupyter
22-
- latest
23-
- slim
11+
file:
12+
- Dockerfile
13+
- Dockerfile.jupyter
14+
- Dockerfile.slim
15+
platform:
16+
- linux/amd64
17+
- linux/arm64
2418
steps:
2519
- uses: actions/checkout@v3
2620
- uses: docker/login-action@v1
2721
with:
2822
username: ${{ secrets.DOCKERHUB_USERNAME }}
2923
password: ${{ secrets.DOCKERHUB_TOKEN }}
30-
- run: make ${{ matrix.target }}
24+
- uses: ./.github/actions/lint
25+
with:
26+
file: ${{ matrix.file }}
27+
- uses: ./.github/actions/build
28+
with:
29+
file: ${{ matrix.file }}
30+
platform: ${{ matrix.platform }}
31+
- run: make push
32+
alpine:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v3
36+
- uses: docker/login-action@v1
37+
with:
38+
username: ${{ secrets.DOCKERHUB_USERNAME }}
39+
password: ${{ secrets.DOCKERHUB_TOKEN }}
40+
- uses: ./.github/actions/lint
41+
with:
42+
file: Dockerfile.alpine
43+
- uses: ./.github/actions/build
44+
with:
45+
file: Dockerfile.alpine
46+
platform: linux/amd64
3147
- run: make push

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
REPO := amancevice/pandas
2+
PLATFORM := linux/amd64
23
PANDAS_VERSION := $(shell grep pandas Pipfile | grep -Eo '[0-9.]+')
34
PIPENV_VERSION := $(shell pipenv --version | grep -Eo '[0-9.]+')
45
PYTHON_VERSION := $(shell python --version | grep -Eo '[0-9.]+')
@@ -12,10 +13,10 @@ push:
1213
docker push --all-tags $(REPO)
1314

1415
Dockerfile: requirements.txt
15-
docker build --build-arg PYTHON_VERSION=$(PYTHON_VERSION) --tag $(REPO) --tag $(REPO):$(PANDAS_VERSION) .
16+
docker buildx build --load --build-arg PYTHON_VERSION=$(PYTHON_VERSION) --platform $(PLATFORM) --tag $(REPO) --tag $(REPO):$(PANDAS_VERSION) .
1617

1718
Dockerfile.%: requirements.txt requirements-dev.txt
18-
docker build --build-arg PYTHON_VERSION=$(PYTHON_VERSION) --file $@ --tag $(REPO):$* --tag $(REPO):$(PANDAS_VERSION)-$* .
19+
docker buildx build --load --build-arg PYTHON_VERSION=$(PYTHON_VERSION) --file $@ --platform $(PLATFORM) --tag $(REPO):$* --tag $(REPO):$(PANDAS_VERSION)-$* .
1920

2021
.PHONY: all clean push Dockerfile Dockerfile.%
2122

0 commit comments

Comments
 (0)