Initial commit

master
Noah 2022-09-24 17:49:10 -07:00
commit 8ed008cf55
5 changed files with 237 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
ssh/*

91
32bit.dockerfile Normal file
View File

@ -0,0 +1,91 @@
##
# 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/"]

91
64bit.dockerfile Normal file
View File

@ -0,0 +1,91 @@
##
# 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 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-x86-64 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-amd64.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/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/golang/pkg/windows_amd64 && \
chown -R builder:users /usr/lib/golang/pkg/windows_amd64
# 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/*.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 mingw-release
CMD ["cp", "-r", "-v", \
"/go/src/git.kirsle.net/SketchyMaze/doodle/dist/release/", \
"/mnt/export/"]

29
Makefile Normal file
View File

@ -0,0 +1,29 @@
SHELL := /bin/bash
# NOTE:
# Fedora likes `podman` instead of `docker` but most other
# distros (Debian, Manjaro) `docker` is easier to use.
# ln -s /usr/bin/podman ~/bin/docker
.PHONY: clean
clean:
rm -rf ./dist
podman system prune -a
podman system reset
.PHONY: 64bit
64bit:
mkdir -p ./dist/64bit
echo pwd is $(shell pwd)
podman build -t doodle_64bit -f ./64bit.dockerfile .
podman 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)
podman build -t doodle_32bit -f ./32bit.dockerfile .
podman run --rm --mount type=bind,src=$(shell pwd)/dist/32bit,dst=/mnt/export doodle_32bit
.PHONY: all
all: 64bit 32bit

25
README.md Normal file
View File

@ -0,0 +1,25 @@
# Dockerfiles for Project: Doodle
To ensure consistent builds of Project: Doodle, these Dockerfiles will
set up a clean Linux environment and run all the steps to gather assets from
all the git repos and build and release the app in a consistent way.
It uses the `podman` command, which is compatible with `docker` but doesn't
require elevated privileges. From a fresh Fedora environment, `dnf install podman`
and the makefile ought to "just work" (provided all the git repositories are
up and the heads are not broken). Also reading the Dockerfile can give you
an idea of the end-to-end process of the build.
Run `make setup` to add flathub (--if-not-exists) and download the dependency
layers.
```
make 64bit
```
Podman tip: `podman system reset` to nuke all of it, cached images and build
steps, for a fresh start when testing the dockerfiles.
**Fedora tip:** run `setenforce permissive` to disable SELinux for the
bind mount, or podman/docker can't copy artifacts from the Docker
container up to the host.