Skip to content

Commit

Permalink
docker: build linux/arm64 images (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtretyakov authored and mstorsjo committed Feb 8, 2024
1 parent 6775203 commit becddc3
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 10 deletions.
56 changes: 46 additions & 10 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,51 @@ jobs:
cat parameters.txt >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
docker-build:
docker-build-toolchain:
needs: [prepare]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ (inputs.commit != '' && inputs.commit) || inputs.branch }}
- name: Download toolchain
uses: dawidd6/action-download-artifact@v3
with:
workflow: build.yml
workflow_conclusion: success
commit: ${{inputs.commit}}
branch: ${{inputs.branch}}
event: push
name: linux-ucrt-.*
name_is_regexp: true
path: toolchain
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
if: ${{inputs.login}}
uses: docker/login-action@v2
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}
- name: Build Docker images
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{inputs.push}}
file: ./Dockerfile.toolchain
tags: |
mstorsjo/llvm-mingw:latest
mstorsjo/llvm-mingw:${{needs.prepare.outputs.TAG}}
- name: Inspect Docker images
run: |
docker images
docker-build-dev:
needs: [prepare]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- { file: Dockerfile, maintag: latest, prefix: }
- { file: Dockerfile.dev, maintag: dev, prefix: dev- }
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -62,10 +98,10 @@ jobs:
with:
context: .
push: ${{inputs.push}}
file: ./${{matrix.file}}
file: ./Dockerfile.dev
tags: |
mstorsjo/llvm-mingw:${{matrix.maintag}}
mstorsjo/llvm-mingw:${{matrix.prefix}}${{needs.prepare.outputs.TAG}}
mstorsjo/llvm-mingw:dev
mstorsjo/llvm-mingw:dev-${{needs.prepare.outputs.TAG}}
- name: Inspect Docker images
run: |
docker images
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/libffi
/cpython*
/python-native
/toolchain
36 changes: 36 additions & 0 deletions Dockerfile.toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:20.04

RUN apt-get update -qq && \
DEBIAN_FRONTEND="noninteractive" apt-get install -qqy --no-install-recommends \
git wget bzip2 file unzip libtool pkg-config cmake build-essential \
automake yasm gettext autopoint vim-tiny python3 python3-distutils \
ninja-build ca-certificates curl less zip && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*

# Manually install a newer version of CMake; this is needed since building
# LLVM requires CMake 3.20, while Ubuntu 20.04 ships with 3.16.3. If
# updating to a newer distribution, this can be dropped.
RUN cd /opt && \
curl -LO https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-Linux-$(uname -m).tar.gz && \
tar -zxf cmake-*.tar.gz && \
rm cmake-*.tar.gz && \
mv cmake-* cmake
ENV PATH=/opt/cmake/bin:$PATH


RUN git config --global user.name "LLVM MinGW" && \
git config --global user.email root@localhost

WORKDIR /build

ENV TOOLCHAIN_PREFIX=/opt/llvm-mingw

ARG TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64"

# Copy prebuild toolchains for the current architecture
RUN --mount=type=bind,source=toolchain,target=/toolchain \
mkdir -p $TOOLCHAIN_PREFIX && ARCH=`uname -m` && \
tar xf /toolchain/llvm-mingw-*-$ARCH.tar.xz --strip-components 1 -C $TOOLCHAIN_PREFIX

ENV PATH=$TOOLCHAIN_PREFIX/bin:$PATH

0 comments on commit becddc3

Please sign in to comment.