Skip to content

Instantly share code, notes, and snippets.

@lg
Last active February 12, 2023 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lg/b89ddc46c553ac5ae3808157520fb49a to your computer and use it in GitHub Desktop.
Save lg/b89ddc46c553ac5ae3808157520fb49a to your computer and use it in GitHub Desktop.
Dockerfile to download and build firefox for multiple architectures (run on x86_64 host/platform)
FROM ubuntu:jammy as builder
ARG FIREFOX_REF=FIREFOX_109_0_1_RELEASE
# download firefox and its build dependencies
WORKDIR /usr/local/src/firefox
ARG DEBIAN_FRONTEND="noninteractive"
RUN apt update && apt install --no-install-recommends -y mercurial python3-pip build-essential \
binutils-aarch64-linux-gnu curl rsync
RUN hg --config format.generaldelta=true init mozilla-unified \
&& echo "\n[paths]\ndefault = https://hg.mozilla.org/mozilla-unified\n\n[format]\nmaxchainlen = 10000\n" >> mozilla-unified/.hg/hgrc \
&& cd mozilla-unified && hg pull --update -r $FIREFOX_REF
WORKDIR /usr/local/src/firefox/mozilla-unified
ARG PATH=/root/.cargo/bin:$PATH
RUN ./mach bootstrap --application-choice "Firefox for Desktop" \
&& rustup target add aarch64-unknown-linux-gnu aarch64-apple-darwin x86_64-unknown-linux-gnu
# x86_64
COPY mozconfig .
RUN echo "\nac_add_options --target=x86_64-unknown-linux-gnu\n" >> mozconfig && ./mach build
# aarch64
COPY mozconfig .
RUN echo "\nac_add_options --target=aarch64-linux\n" >> mozconfig && ./mach build
# macos aarch64
COPY mozconfig .
RUN curl -OL "https://github.com/alexey-lysiuk/macos-sdk/releases/download/11.3/MacOSX11.3.tar.bz2" \
&& echo "extracting" && tar xf MacOSX11.3.tar.bz2 \
&& echo "\nac_add_options --target=aarch64-darwin\nac_add_options --with-macos-sdk=$(pwd)/MacOSX11.3.sdk\n" >> mozconfig \
&& ./mach build
FROM scratch
COPY --from=builder /usr/local/src/firefox/mozilla-unified/obj-x86_64-unknown-linux-gnu/dist /firefox-x86_64-linux
COPY --from=builder /usr/local/src/firefox/mozilla-unified/obj-x86_64-unknown-linux-gnu/dist /firefox-aarch64-linux
COPY --from=builder /usr/local/src/firefox/mozilla-unified/obj-aarch64-unknown-darwin/dist /firefox-aarch64-macos
ac_add_options --enable-bootstrap
ac_add_options --enable-application=browser
ac_add_options --disable-tests
ac_add_options --enable-release
ac_add_options --with-branding=browser/branding/official
ac_add_options --disable-updater
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment