Skip to content

Commit

Permalink
feat(docker): Add dockerfile and setup to build an image
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jan 17, 2020
1 parent 4f24d4a commit 4424d44
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions .commitlintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ rules:
- 1
- 'always'
- - core
- docker
- utilities
- settings
- typesetter
Expand Down
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM archlinux

ARG sile_tag=master

LABEL maintainer='Caleb Maclennan <caleb@alerque.com>'
LABEL version="$sile_tag"

RUN pacman --needed --noconfirm -Syuq && yes | pacman -Sccq

COPY build-aux/build-for-docker.sh /usr/local/bin/
RUN build-for-docker.sh

COPY build-aux/docker-entrypoint.sh /usr/local/bin

WORKDIR /data
ENTRYPOINT ["docker-entrypoint.sh"]
4 changes: 4 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ endif

CLEANFILES = $(bin_SCRIPTS) $(dist_man_MANS) $(DEPFILES) $(ACTUALS) $(TESTPDFS)

.PHONY: docker
docker:
docker build --tag siletypesetter/sile:HEAD ./

gource.webm:
mkdir -p /tmp/gravatars
convert examples/images/sile-logo.jpg -negate -resize 50% /tmp/sile-logo.jpg
Expand Down
23 changes: 23 additions & 0 deletions build-aux/build-for-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e +o pipefail

# Setup AUR helper and other build time dependencies in a way they will be removed from the final image
pacman --needed --noconfirm --asdeps -S git base-devel go poppler
useradd -m docker
echo 'docker:' | chpasswd -e
mkdir -p /etc/sudoers.d
echo 'docker ALL = NOPASSWD: ALL' > /etc/sudoers.d/99-docker
su docker -c 'cd; git clone https://aur.archlinux.org/yay.git; cd yay; makepkg -i --noconfirm --asdeps'

# Install SILE's own prerequisites in a way they will stay in the final image
deps="fontconfig harfbuzza icu lua ttf-gentium-plus"
deps+=" lua-{luaepnf,lpeg,cassowary,linenoise,zlib,cliargs,filesystem,repl,sec,socket,penlight,stdlib,vstruct}"
su docker -c "yay --needed --noconfirm --asexplicit -S $deps"

# Build and install SILE itself

# Tear down build time depencies before layer gets imaged
su docker -c 'yay --noconfirm -Yccq'
yes | pacman -Sccq
userdel -r -f docker
rm -rf /etc/sudoers.d
8 changes: 8 additions & 0 deletions build-aux/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -e

if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
set -- sile "$@"
fi

exec "$@"

0 comments on commit 4424d44

Please sign in to comment.