Skip to content

Commit

Permalink
Merge pull request #3 from sagudev/docker-images
Browse files Browse the repository at this point in the history
Docker cross images
  • Loading branch information
mukilan authored Sep 14, 2023
2 parents d5a7f55 + ccf64b1 commit afddd30
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 2 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish Docker images

on:
push:
pull_request:
schedule:
# update images every month
- cron: "1 1 12 * *"
workflow_dispatch:

# You may need to go to Repo Settings > Actions > General > Workflow permissions and select Read and Write permissions
permissions:
packages: write

jobs:
docker:
runs-on: ubuntu-latest
strategy:
matrix:
image:
- cross-aarch64-unknown-linux-gnu
- cross-armv7-unknown-linux-gnueabihf
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}
# https://github.com/docker/metadata-action
tags: |
type=schedule,pattern={{date 'YYYYMM'}}
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
file: ./docker/${{ matrix.image }}.dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# servo-build-deps
This repository is used to host the prebuilt dependencies useful for building and running Servo.
# Servo Build Dependencies

This repository is used to host the prebuilt dependencies useful for building and running Servo. It is also used for generating docker images.
30 changes: 30 additions & 0 deletions docker/cross-aarch64-unknown-linux-gnu.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM ubuntu:22.04
# ubuntu 22.04 is called jammy

# add arch
RUN sed 's/^deb http/deb [arch=amd64] http/' -i '/etc/apt/sources.list'
RUN echo 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy main universe multiverse restricted' >> /etc/apt/sources.list && \
echo 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main universe multiverse restricted' >> /etc/apt/sources.list && \
echo 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy-backports main universe multiverse restricted' >> /etc/apt/sources.list && \
echo 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main universe multiverse restricted' >> /etc/apt/sources.list
RUN dpkg --add-architecture arm64
# add for actions
RUN apt update && apt install -y curl git && apt-get clean
# add main build deps
RUN apt install --no-install-recommends -y build-essential pkg-config m4 python3 python3-distutils llvm llvm-dev lld libclang-dev clang && apt-get clean
# add cross deps
RUN apt install --no-install-recommends -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu qemu-user qemu-user-static && apt-get clean
# add runtime deps
RUN apt install --no-install-recommends -y libc6:arm64 libstdc++6:arm64 && apt-get clean
# set runner to qemu
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="/usr/bin/qemu-aarch64"
# set linker to cross linker
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER="/usr/bin/aarch64-linux-gnu-gcc"

# use clang compiler
RUN echo '#!/bin/bash \nclang -target aarch64-unknown-linux-gnu -isysroot=/usr/aarch64-linux-gnu --sysroot=/ -Wno-unused-command-line-argument -fuse-ld=lld "$@"' > /bin/clang-aarch64 && chmod +x /bin/clang-aarch64
RUN echo '#!/bin/bash \nclang++ -target aarch64-unknown-linux-gnu -isysroot=/usr/aarch64-linux-gnu --sysroot=/ -Wno-unused-command-line-argument -fuse-ld=lld "$@"' > /bin/clang++-aarch64 && chmod +x /bin/clang++-aarch64
ENV CC="clang-aarch64"
ENV CXX="clang++-aarch64"
ENV BINDGEN_EXTRA_CLANG_ARGS="-isysroot=/usr/aarch64-linux-gnu --sysroot=/ -Wno-unused-command-line-argument -fuse-ld=lld"
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER="clang-aarch64"
30 changes: 30 additions & 0 deletions docker/cross-armv7-unknown-linux-gnueabihf.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM ubuntu:22.04
# ubuntu 22.04 is called jammy

# add arch
RUN sed 's/^deb http/deb [arch=amd64] http/' -i '/etc/apt/sources.list'
RUN echo 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy main universe multiverse restricted' >> /etc/apt/sources.list && \
echo 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-updates main universe multiverse restricted' >> /etc/apt/sources.list && \
echo 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-backports main universe multiverse restricted' >> /etc/apt/sources.list && \
echo 'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports jammy-security main universe multiverse restricted' >> /etc/apt/sources.list
RUN dpkg --add-architecture armhf
# add for actions
RUN apt update && apt install -y curl git && apt-get clean
# add main build deps
RUN apt install --no-install-recommends -y build-essential pkg-config m4 python3 python3-distutils llvm llvm-dev lld libclang-dev clang && apt-get clean
# add cross deps
RUN apt install --no-install-recommends -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf qemu-user qemu-user-static && apt-get clean
# add runtime deps
RUN apt install --no-install-recommends -y libc6:armhf libstdc++6:armhf && apt-get clean
# set runner to qemu
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER="/usr/bin/qemu-arm"
# set linker to cross linker
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER="/usr/bin/arm-linux-gnueabihf-gcc"

# use clang compiler
RUN echo '#!/bin/bash \nclang -target armv7-unknown-linux-gnueabihf -isysroot=/usr/arm-linux-gnueabihf --sysroot=/ -Wno-unused-command-line-argument -fuse-ld=lld "$@"' > /bin/clang-arm && chmod +x /bin/clang-arm
RUN echo '#!/bin/bash \nclang++ -target armv7-unknown-linux-gnueabihf -isysroot=/usr/arm-linux-gnueabihf --sysroot=/ -Wno-unused-command-line-argument -fuse-ld=lld "$@"' > /bin/clang++-arm && chmod +x /bin/clang++-arm
ENV CC="clang-arm"
ENV CXX="clang++-arm"
ENV BINDGEN_EXTRA_CLANG_ARGS="-isysroot=/usr/arm-linux-gnueabihf --sysroot=/ -Wno-unused-command-line-argument -fuse-ld=lld"
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER="clang-arm"

0 comments on commit afddd30

Please sign in to comment.