docker/32bit.dockerfile

92 lines
3.3 KiB
Docker

##
# Fully build and distribute Linux and Windows binaries for Project: Doodle.
#
# Artifact outputs will be in the dist/mw/ folder.
#
# Windows binary cross-compiled with mingw from the Fedora
# docker container.
##
FROM i386/debian:latest
ENV GOPATH /go
ENV GOPROXY direct
ENV PATH /opt/go/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/go/bin
# Debian: Update all software and get dependencies.
RUN apt update && apt -y upgrade && apt -y dist-upgrade
RUN apt -y install git zip tar libsdl2-dev libsdl2-ttf-dev \
libsdl2-mixer-dev gcc-mingw-w64-i686 gcc make wget \
flatpak-builder ruby-dev gcc rpm libffi-dev
# Create a user to build the packages.
RUN useradd builder -u 1000 -m -G users && \
mkdir /go /git && chown -R builder:users /go /git
# Download and install modern Go.
WORKDIR /root
RUN wget https://go.dev/dl/go1.19.1.linux-386.tar.gz -O go.tgz && \
tar -xzvf go.tgz && \
cp -r go /opt/go
# Git clone all the repos.
RUN git clone https://git.kirsle.net/SketchyMaze/rtp /git/rtp
RUN git clone https://git.kirsle.net/SketchyMaze/vendor /git/vendor
RUN git clone https://git.kirsle.net/SketchyMaze/assets /git/assets
RUN git clone https://git.kirsle.net/SketchyMaze/doodle /go/src/git.kirsle.net/SketchyMaze/doodle
RUN git clone https://git.kirsle.net/SketchyMaze/doodads /go/src/git.kirsle.net/SketchyMaze/doodle/deps/doodads
# MinGW setup for Windows executable cross-compile.
WORKDIR /git/vendor/mingw-libs
RUN for i in *.tar.gz; do tar -xzvf $i; done
RUN cp -rv SDL2-2.0.9/i686-w64-mingw32 /usr && \
cp -rv SDL2_mixer-2.0.4/i686-w64-mingw32 /usr && \
cp -rv SDL2_ttf-2.0.15/i686-w64-mingw32 /usr
RUN mkdir -p /usr/lib/golang/pkg/windows_386 && \
chown -R builder:users /usr/lib/golang/pkg/windows_386
# Pre-download my Go render engine libraries
RUN git clone https://git.kirsle.net/go/ui /git/go/ui
RUN git clone https://git.kirsle.net/go/render /git/go/render
RUN git clone https://git.kirsle.net/go/audio /git/go/audio
# Enter Doodle's directory, patch the go.mod and fetch the guidebook.
WORKDIR /go/src/git.kirsle.net/SketchyMaze/doodle
RUN echo "replace git.kirsle.net/go/ui => /git/go/ui" >> go.mod && \
echo "replace git.kirsle.net/go/render => /git/go/render" >> go.mod && \
echo "replace git.kirsle.net/go/audio => /git/go/audio" >> go.mod && \
cat go.mod && \
wget -O - https://download.sketchymaze.com/guidebook.tar.gz | tar -xzvf -
# Install Go dependencies and such.
RUN make setup
# Install the doodad tool into our $PATH.
RUN make install
# Copy default vendored assets in.
RUN cp -r /git/vendor/fonts ./assets/fonts && \
cp -r /git/assets/levelpacks/levelpacks ./assets/levelpacks && \
mkdir rtp && cp -r /git/rtp/* rtp/
RUN ls -hal && pwd
RUN mkdir -p bin && cp /git/vendor/DLL-32bit/*.dll bin/
# Package rpm and deb for Linux.
# TODO: fpm doesn't like to install in Docker right now
RUN apt -y install ruby-dev ruby-rubygems rpm libffi-dev
RUN gem install fpm; exit 0
# Run the big mingw-release, which:
# - builds the doodads
# - embeds the bindata files
# - builds the program for Linux
# - builds for Windows via MinGW
# - runs `make dist/` creating an uber build for both OS's
# - runs release.sh to carve out the Linux and Windows versions and
# zip them all up nicely.
RUN make mingw32-release
CMD ["cp", "-r", "-v", \
"/go/src/git.kirsle.net/SketchyMaze/doodle/dist/release/", \
"/mnt/export/"]