DivestOS/Container/Dockerfile
ryneeverett 3999fe1e1f Container: Scripted builds
I had a hard time following the [Build
Guide](https://divestos.org/pages/build) and IMO a script does a much
better job of removing the ambiguity and is more likely to be updated
if it fails. Per
https://github.com/Divested-Mobile/DivestOS-Website/issues/40 I think
this script, as documentation, makes it much more clear what it means to
"color in the lines" and suggests an efficient way of doing so. I'd like
to update the Build Guide too, but I wanted to get your feedback on some
of this first.

The main thing I'm not thrilled with is that the workspace needs to be
patched and reset twice (if I understand correctly). I got this notion
from your guidance on a Reddit post a couple months back which I can't
find now that Reddit seems to have taken down your content.
Unfortunately I don't recall the details but the basic issue is that
generating the signing keys was giving an error and the solution was to
patch the workspace. But one of the workspace patching "phases" is to
copy the keys to the kernel and this fails if the keys don't exist yet.
So it's not clear how to get around doing this step twice.

A couple notes on future work:
- How to do incremental updates? There's no story on this yet and I
  haven't looked into it.
- I found a wealth of information on building android in docker in this
  repository: https://github.com/lineageos4microg/docker-lineage-cicd.
  It might be worth considering trying to integrate DivestOS into that
  project or building on top of their image.
2024-07-26 22:02:12 +00:00

41 lines
2.4 KiB
Docker

FROM fedora:latest
ARG userid
ARG groupid
ARG username
#
RUN dnf -y update \
# && dnf -y install bash coreutils bzip2 curl java-1.8.0-openjdk java-1.8.0-openjdk-devel unzip zip zlib \
# && dnf -y install @development-tools tini android-tools automake bc bison bzip2-libs ccache
&& dnf -y install @development-tools android-tools automake bc bison bzip2 bzip2-libs ccache curl dpkg-dev flex gcc gcc-c++ git git-lfs glibc-devel.{x86_64,i686} gnupg gperf ImageMagick ImageMagick-c++-devel ImageMagick-devel java-1.8.0-openjdk java-1.8.0-openjdk-devel libgcc.{x86_64,i686} libstdc++.{x86_64,i686} libX11-devel.{x86_64,i686} libxml2-devel libXrandr.{x86_64,i686} libXrender.{x86_64,i686} libxslt lz4-libs lzop make maven mesa-libGL-devel.{x86_64,i686} ncurses ncurses-compat-libs ncurses-devel.{x86_64,i686} ninja-build openssl-devel optipng jpegoptim perl perl-Digest-MD5-File perl-Switch pngcrush python python2 python3-virtualenv python3 python3-mako python-mako python-markdown python-networkx readline-devel.{x86_64,i686} rsync schedtool SDL squashfs-tools syslinux-devel unzip wxGTK xml2 xz-lzma-compat zip zlib zlib-devel vim-common vboot-utils mozilla-fira-mono-fonts mozilla-fira-sans-fonts openssl nano htop wget libxcrypt-compat.x86_64 golang \
&& dnf clean all \
&& curl -o /usr/local/bin/repo https://storage.googleapis.com/git-repo-downloads/repo \
&& chmod a+x /usr/local/bin/repo \
&& sudo ln -sf /usr/share/crypto-policies/LEGACY/java.txt /etc/crypto-policies/back-ends/java.config
RUN git clone https://github.com/rfjakob/gocryptfs.git \
&& cd gocryptfs \
&& ./build-without-openssl.bash
RUN cp $(go env GOPATH | cut -f1 -d:)/bin/gocryptfs /usr/local/bin/
RUN groupadd --non-unique --gid $groupid $username \
&& useradd --create-home --shell /bin/bash --uid $userid --gid $groupid $username \
&& echo $username >/root/username \
&& echo "export USER="$username >>/home/$username/.gitconfig
COPY gitconfig /home/$username/.gitconfig
RUN mkdir -p /home/$username/android \
&& mkdir -p /home/$username/.ccache \
&& chown $userid:$groupid /home/$username/.gitconfig /home/$username/android /home/$username/.ccache
COPY phase-*.sh /home/$username/
ENV HOME=/home/$username
ENV USER=$username
ENV USE_CCACHE=1
ENV CCACHE_COMPRESS=1
ENV CCACHE_COMPRESSLEVEL=1
ENV CCACHE_EXEC=/usr/bin/ccache
ENV CCACHE_DIR=/home/$username/.ccache
ENTRYPOINT chroot --userspec=$(cat /root/username):$(cat /root/username) --skip-chdir / /bin/bash -i