From 34307e77ce9c5e8de93948380fff411004c3135d Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Fri, 5 Nov 2021 20:03:40 -0700 Subject: [PATCH] New Dockerfiles --- 32bit.dockerfile | 88 ++++++++++++++++++++++++++++ MinGW.dockerfile => 64bit.dockerfile | 2 - MacOS.dockerfile | 82 ++++++++++++++++++++++++++ Makefile | 17 ++++-- 4 files changed, 182 insertions(+), 7 deletions(-) create mode 100644 32bit.dockerfile rename MinGW.dockerfile => 64bit.dockerfile (97%) create mode 100644 MacOS.dockerfile diff --git a/32bit.dockerfile b/32bit.dockerfile new file mode 100644 index 0000000..7c973cd --- /dev/null +++ b/32bit.dockerfile @@ -0,0 +1,88 @@ +## +# 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:/go/bin + +# Debian: Update all software and get dependencies. +# RUN dnf -y update +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 + +# 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://golang.org/dl/go1.17.1.linux-386.tar.gz -O go.tgz && \ + tar -xzvf go.tgz && \ + cp -r go /opt/go + +# Docker cache invalidation here. +# ADD . /home/builder + +# Git clone all the repos. XXX: passwords exposed here +RUN git clone https://doodle:hiRN6wp-XPDBc@git.kirsle.net/apps/doodle-rtp /git/rtp +RUN git clone https://doodle:hiRN6wp-XPDBc@git.kirsle.net/apps/doodle-vendor /git/vendor +RUN git clone https://doodle:hiRN6wp-XPDBc@git.kirsle.net/apps/doodle-masters /git/masters +RUN git clone https://doodle:hiRN6wp-XPDBc@git.kirsle.net/apps/doodle /go/src/git.kirsle.net/apps/doodle + +# 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/apps/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 + +# Copy default vendored assets in. +RUN cp -r /git/vendor/fonts ./assets/fonts && \ + cp -r /git/masters/levels ./assets/levels && \ + mkdir rtp && cp -r /git/rtp/* rtp/ + +RUN ls -hal && pwd +RUN mkdir -p bin && cp /git/vendor/DLL/*.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/apps/doodle/dist/", "/mnt/export/"] diff --git a/MinGW.dockerfile b/64bit.dockerfile similarity index 97% rename from MinGW.dockerfile rename to 64bit.dockerfile index a66b822..8d5a161 100644 --- a/MinGW.dockerfile +++ b/64bit.dockerfile @@ -54,8 +54,6 @@ RUN echo "replace git.kirsle.net/go/ui => /git/go/ui" >> go.mod && \ wget -O - https://download.sketchymaze.com/guidebook.tar.gz | tar -xzvf - # Install Go dependencies and such. -RUN go get -u git.kirsle.net/go/bindata/... -RUN make bindata-dev RUN make setup # Copy default vendored assets in. diff --git a/MacOS.dockerfile b/MacOS.dockerfile new file mode 100644 index 0000000..d4a0b1f --- /dev/null +++ b/MacOS.dockerfile @@ -0,0 +1,82 @@ +## +# Fully build and distribute MacOS releases cross-compiled from Linux. +# +# Artifact outputs will be in the dist/mac/ folder. +# +# WORK IN PROGRESS. +## + +FROM manjaro:latest +MAINTAINER Noah Petherbridge +ENV GOPATH /go +ENV GOPROXY direct +ENV PATH /bin:/sbin:/usr/bin:/usr/sbin:/go/bin + +# Manjaro: Update all software and get dependencies. +RUN pacman -Syu --noconfirm && \ + pacman -S --noconfirm go sdl2 sdl2_ttf sdl2_mixer pkg-config + +# Get the OS X cross compile toolchain. +RUN git clone https://github.com/tpoechtrager/osxcross /git/osxcross && + cd /git/osxcross && + makepkg -si + +# Create a user to build the packages. +RUN useradd builder -u 1000 -m -G users && \ + mkdir /go /git && chown -R builder:users /go /git + +# Docker cache invalidation here. +# ADD . /home/builder + +# Git clone all the repos. XXX: passwords exposed here +RUN git clone https://doodle:hiRN6wp-XPDBc@git.kirsle.net/apps/doodle-rtp /git/rtp +RUN git clone https://doodle:hiRN6wp-XPDBc@git.kirsle.net/apps/doodle-vendor /git/vendor +RUN git clone https://doodle:hiRN6wp-XPDBc@git.kirsle.net/apps/doodle-masters /git/masters +RUN git clone https://doodle:hiRN6wp-XPDBc@git.kirsle.net/apps/doodle /go/src/git.kirsle.net/apps/doodle + +# 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. +WORKDIR /go/src/git.kirsle.net/apps/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 + +# Install Go dependencies and such. +RUN go get -u git.kirsle.net/go/bindata/... +RUN make bindata-dev +RUN make setup + +# Copy default vendored assets in. +RUN cp -r /git/vendor/fonts ./assets/fonts && \ + cp -r /git/masters/levels ./assets/levels && \ + mkdir rtp && cp -r /git/rtp/* rtp/ + +# 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/x86_64-w64-mingw32 /usr && \ + cp -rv SDL2_mixer-2.0.4/x86_64-w64-mingw32 /usr && \ + cp -rv SDL2_ttf-2.0.15/x86_64-w64-mingw32 /usr +RUN mkdir -p /usr/lib/go/pkg/windows_amd64 && \ + chown -R builder:users /usr/lib/go/pkg/windows_amd64 +WORKDIR /go/src/git.kirsle.net/apps/doodle + +RUN make mingw +RUN cp /git/vendor/DLL/*.dll bin/ + +RUN make dist + +# Package rpm and deb for Linux. +# TODO: fpm doesn't like to install in Docker right now +# RUN dnf -y install ruby-devel gcc rpm-build libffi-devel +# RUN gem install fpm; exit 0 +# WORKDIR /go/src/git.kirsle.net/apps/doodle/dist/doodle-latest +# RUN pwd +# RUN ../../scripts/fpm-bundle.sh + +CMD ["sudo", "cp", "-r", "-v", "/go/src/git.kirsle.net/apps/doodle/dist/", "/mnt/export/"] diff --git a/Makefile b/Makefile index 314a4af..50364d9 100644 --- a/Makefile +++ b/Makefile @@ -9,9 +9,16 @@ clean: rm -rf ./dist docker system prune -a -.PHONY: mingw -mingw: - mkdir -p ./dist/mingw +.PHONY: 64bit +64bit: + mkdir -p ./dist/64bit echo pwd is $(shell pwd) - docker build -t doodle_mingw -f ./MinGW.dockerfile . - docker run --rm --mount type=bind,src=$(shell pwd)/dist/mingw,dst=/mnt/export doodle_mingw + docker build -t doodle_64bit -f ./64bit.dockerfile . + docker run --rm --mount type=bind,src=$(shell pwd)/dist/64bit,dst=/mnt/export doodle_64bit + +.PHONY: 32bit +32bit: + mkdir -p ./dist/32bit + echo pwd is $(shell pwd) + docker build -t doodle_32bit -f ./32bit.dockerfile . + docker run --rm --mount type=bind,src=$(shell pwd)/dist/32bit,dst=/mnt/export doodle_32bit \ No newline at end of file