Skip to content

Commit dc32b6e

Browse files
committed
docker: build linux/arm64 images (#398)
1 parent c2a38eb commit dc32b6e

File tree

3 files changed

+83
-10
lines changed

3 files changed

+83
-10
lines changed

.github/workflows/docker.yml

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,51 @@ jobs:
3838
cat parameters.txt >> $GITHUB_OUTPUT
3939
cat $GITHUB_OUTPUT
4040
41-
docker-build:
41+
docker-build-toolchain:
42+
needs: [prepare]
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
with:
47+
ref: ${{ (inputs.commit != '' && inputs.commit) || inputs.branch }}
48+
- name: Download toolchain
49+
uses: dawidd6/action-download-artifact@v3
50+
with:
51+
workflow: build.yml
52+
workflow_conclusion: success
53+
commit: ${{inputs.commit}}
54+
branch: ${{inputs.branch}}
55+
event: push
56+
name: linux-ucrt-.*
57+
name_is_regexp: true
58+
path: toolchain
59+
- name: Set up QEMU
60+
uses: docker/setup-qemu-action@v3
61+
- name: Set up Docker Buildx
62+
uses: docker/setup-buildx-action@v3
63+
- name: Log in to Docker Hub
64+
if: ${{inputs.login}}
65+
uses: docker/login-action@v2
66+
with:
67+
username: ${{secrets.DOCKER_USERNAME}}
68+
password: ${{secrets.DOCKER_PASSWORD}}
69+
- name: Build Docker images
70+
uses: docker/build-push-action@v4
71+
with:
72+
context: .
73+
platforms: linux/amd64,linux/arm64
74+
push: ${{inputs.push}}
75+
file: ./Dockerfile.toolchain
76+
tags: |
77+
mstorsjo/llvm-mingw:latest
78+
mstorsjo/llvm-mingw:${{needs.prepare.outputs.TAG}}
79+
- name: Inspect Docker images
80+
run: |
81+
docker images
82+
83+
docker-build-dev:
4284
needs: [prepare]
4385
runs-on: ubuntu-latest
44-
strategy:
45-
fail-fast: false
46-
matrix:
47-
include:
48-
- { file: Dockerfile, maintag: latest, prefix: }
49-
- { file: Dockerfile.dev, maintag: dev, prefix: dev- }
5086
steps:
5187
- uses: actions/checkout@v4
5288
with:
@@ -62,10 +98,10 @@ jobs:
6298
with:
6399
context: .
64100
push: ${{inputs.push}}
65-
file: ./${{matrix.file}}
101+
file: ./Dockerfile.dev
66102
tags: |
67-
mstorsjo/llvm-mingw:${{matrix.maintag}}
68-
mstorsjo/llvm-mingw:${{matrix.prefix}}${{needs.prepare.outputs.TAG}}
103+
mstorsjo/llvm-mingw:dev
104+
mstorsjo/llvm-mingw:dev-${{needs.prepare.outputs.TAG}}
69105
- name: Inspect Docker images
70106
run: |
71107
docker images

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/libffi
66
/cpython*
77
/python-native
8+
/toolchain

Dockerfile.toolchain

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM ubuntu:20.04
2+
3+
RUN apt-get update -qq && \
4+
DEBIAN_FRONTEND="noninteractive" apt-get install -qqy --no-install-recommends \
5+
git wget bzip2 file unzip libtool pkg-config cmake build-essential \
6+
automake yasm gettext autopoint vim-tiny python3 python3-distutils \
7+
ninja-build ca-certificates curl less zip && \
8+
apt-get clean -y && \
9+
rm -rf /var/lib/apt/lists/*
10+
11+
# Manually install a newer version of CMake; this is needed since building
12+
# LLVM requires CMake 3.20, while Ubuntu 20.04 ships with 3.16.3. If
13+
# updating to a newer distribution, this can be dropped.
14+
RUN cd /opt && \
15+
curl -LO https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-Linux-$(uname -m).tar.gz && \
16+
tar -zxf cmake-*.tar.gz && \
17+
rm cmake-*.tar.gz && \
18+
mv cmake-* cmake
19+
ENV PATH=/opt/cmake/bin:$PATH
20+
21+
22+
RUN git config --global user.name "LLVM MinGW" && \
23+
git config --global user.email root@localhost
24+
25+
WORKDIR /build
26+
27+
ENV TOOLCHAIN_PREFIX=/opt/llvm-mingw
28+
29+
ARG TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64"
30+
31+
# Copy prebuild toolchains for the current architecture
32+
RUN --mount=type=bind,source=toolchain,target=/toolchain \
33+
mkdir -p $TOOLCHAIN_PREFIX && ARCH=`uname -m` && \
34+
tar xf /toolchain/llvm-mingw-*-$ARCH.tar.xz --strip-components 1 -C $TOOLCHAIN_PREFIX
35+
36+
ENV PATH=$TOOLCHAIN_PREFIX/bin:$PATH

0 commit comments

Comments
 (0)