Dockerfile updates

Noah 2021-07-11 18:14:52 -07:00
parent 5358e3e907
commit 2b354c0c33
2 changed files with 35 additions and 26 deletions

View File

@ -1,13 +1,17 @@
SHELL := /bin/bash
# NOTE:
# Fedora likes `podman` instead of `docker` but most other
# distros (Debian, Manjaro) `docker` is easier to use.
.PHONY: clean
clean:
rm -rf ./dist
podman system prune -a
docker system prune -a
.PHONY: mingw
mingw:
mkdir -p ./dist/mingw
echo pwd is $(shell pwd)
podman build -t doodle_mingw -f ./MinGW.dockerfile .
podman run --rm --mount type=bind,src=$(shell pwd)/dist/mingw,dst=/mnt/export doodle_mingw
docker build -t doodle_mingw -f ./MinGW.dockerfile .
docker run --rm --mount type=bind,src=$(shell pwd)/dist/mingw,dst=/mnt/export doodle_mingw

View File

@ -15,8 +15,8 @@ ENV PATH /bin:/sbin:/usr/bin:/usr/sbin:/go/bin
# Fedora: Update all software and get dependencies.
# RUN dnf -y update
RUN dnf -y install git zip golang SDL2-devel SDL2_ttf-devel \
SDL2_mixer-devel mingw64-gcc make
RUN dnf -y install git zip tar golang SDL2-devel SDL2_ttf-devel \
SDL2_mixer-devel mingw64-gcc make wget
# Create a user to build the packages.
RUN useradd builder -u 1000 -m -G users && \
@ -31,17 +31,27 @@ RUN git clone https://doodle:hiRN6wp-XPDBc@git.kirsle.net/apps/doodle-vendor /gi
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/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.
# 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
cat 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/...
@ -53,27 +63,22 @@ 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/golang/pkg/windows_amd64 && \
chown -R builder:users /usr/lib/golang/pkg/windows_amd64
WORKDIR /go/src/git.kirsle.net/apps/doodle
RUN make mingw
RUN cp /git/vendor/DLL/*.dll bin/
RUN make dist
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 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
RUN dnf -y install ruby-devel gcc rpm-build libffi-devel
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 ["sudo", "cp", "-r", "-v", "/go/src/git.kirsle.net/apps/doodle/dist/", "/mnt/export/"]