Docker Build Scripts for Debian and Ubuntu

This commit is contained in:
Noah 2019-02-28 18:32:44 -08:00
parent bca848d534
commit 92847fc3b7
7 changed files with 93 additions and 3 deletions

3
.gitignore vendored
View File

@ -1,6 +1,9 @@
fonts/ fonts/
maps/ maps/
bin/ bin/
dist/
docker/ubuntu
docker/debian
screenshot-*.png screenshot-*.png
map-*.json map-*.json
pkg/wallpaper/*.png pkg/wallpaper/*.png

View File

@ -1,6 +1,6 @@
SHELL := /bin/bash SHELL := /bin/bash
VERSION=$(shell grep -e 'Version' doodle.go | head -n 1 | cut -d '"' -f 2) VERSION=$(shell grep -e 'Version =' doodle.go | head -n 1 | cut -d '"' -f 2)
BUILD=$(shell git describe --always) BUILD=$(shell git describe --always)
CURDIR=$(shell curdir) CURDIR=$(shell curdir)
@ -10,7 +10,7 @@ LDFLAGS := -ldflags "-X main.Build=$(BUILD)"
# `make setup` to set up a new environment, pull dependencies, etc. # `make setup` to set up a new environment, pull dependencies, etc.
.PHONY: setup .PHONY: setup
setup: clean setup: clean
go get -u ./... go get ./...
# `make build` to build the binary. # `make build` to build the binary.
.PHONY: build .PHONY: build
@ -34,6 +34,27 @@ guitest:
test: test:
go test ./... go test ./...
# `make dist` builds and tars up a release.
.PHONY: dist
dist: build
mkdir -p dist/doodle-$(VERSION)
cp bin/* dist/doodle-$(VERSION)/
cp -r assets fonts README.md Changes.md dist/doodle-$(VERSION)/
cd dist && tar -czvf doodle-$(VERSION).tar.gz doodle-$(VERSION)
cd dist && zip -r doodle-$(VERSION).zip doodle-$(VERSION)
# `make docker` to run the Docker builds
.PHONY: docker docker.ubuntu docker.debian __docker.dist
docker.ubuntu:
mkdir -p docker/ubuntu
./docker/dist-ubuntu.sh
docker.debian:
mkdir -p docker/debian
./docker/dist-debian.sh
docker: docker.ubuntu docker.debian
__docker.dist: dist
cp dist/*.tar.gz dist/*.zip /mnt/export/
# `make clean` cleans everything up. # `make clean` cleans everything up.
.PHONY: clean .PHONY: clean
clean: clean:

23
docker/Debian.dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM debian:latest
MAINTAINER Noah Petherbridge <root@kirsle.net>
ENV GOPATH /home/builder/go
RUN apt update && apt -y upgrade && \
apt -y install git zip golang \
libsdl2-dev libsdl2-ttf-dev make && \
apt clean
# Create a user to build the packages.
RUN useradd builder -u 1000 -m -G users && \
echo "builder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Add the project to the GOPATH
ADD . /home/builder/go/src/git.kirsle.net/apps/doodle
RUN chown -R builder:builder /home/builder/go
# Build the app
USER builder
WORKDIR /home/builder/go/src/git.kirsle.net/apps/doodle
RUN make setup
RUN make dist
CMD ["make", "__docker.dist"]

23
docker/Ubuntu.dockerfile Normal file
View File

@ -0,0 +1,23 @@
FROM ubuntu:latest
MAINTAINER Noah Petherbridge <root@kirsle.net>
ENV GOPATH /home/builder/go
RUN apt update && apt -y upgrade && \
apt -y install git zip golang \
libsdl2-dev libsdl2-ttf-dev make && \
apt clean
# Create a user to build the packages.
RUN useradd builder -u 1000 -m -G users && \
echo "builder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Add the project to the GOPATH
ADD . /home/builder/go/src/git.kirsle.net/apps/doodle
RUN chown -R builder:builder /home/builder/go
# Build the app
USER builder
WORKDIR /home/builder/go/src/git.kirsle.net/apps/doodle
RUN make setup
RUN make dist
CMD ["make", "__docker.dist"]

10
docker/dist-debian.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
# Run this script from the root of the repo.
if [[ ! -f "./docker/dist-debian.sh" ]]; then
echo "Run this script from the root of the doodle repo, i.e.: ./docker/dist-debian.sh"
exit 1
fi
sudo docker build -t doodle_debian -f ./docker/Debian.dockerfile .
sudo docker run --rm -v "$(pwd)/docker/debian:/mnt/export:z" doodle_debian

10
docker/dist-ubuntu.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
# Run this script from the root of the repo.
if [[ ! -f "./docker/dist-ubuntu.sh" ]]; then
echo "Run this script from the root of the doodle repo, i.e.: ./docker/dist-ubuntu.sh"
exit 1
fi
sudo docker build -t doodle_ubuntu -f ./docker/Ubuntu.dockerfile .
sudo docker run --rm -v "$(pwd)/docker/ubuntu:/mnt/export:z" doodle_ubuntu

View File

@ -28,7 +28,7 @@ func TestWallpaper(t *testing.T) {
img := image.NewRGBA(image.Rect(0, 0, width, height)) img := image.NewRGBA(image.Rect(0, 0, width, height))
draw.Draw( draw.Draw(
// Corner: red // Corner: red
img, // dst Image img, // dst Image
image.Rect(0, 0, qWidth, qHeight), // r Rectangle image.Rect(0, 0, qWidth, qHeight), // r Rectangle
image.NewUniform(red), // src Image image.NewUniform(red), // src Image
image.Point{0, 0}, // sp Point image.Point{0, 0}, // sp Point