Skip to content

Commit

Permalink
Merge pull request #4 from theleagueof/docker
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque authored Apr 15, 2020
2 parents 4cbb5ee + f8f1a53 commit f57857f
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 3 deletions.
49 changes: 49 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM archlinux AS fontship-base

# Setup Caleb's hosted Arch repository with prebuilt dependencies
RUN pacman-key --init && pacman-key --populate
RUN sed -i /etc/pacman.conf -e \
'/^.community/{n;n;s!^!\n\[alerque\]\nServer = https://arch.alerque.com/$arch\n!}'
RUN pacman-key --recv-keys 63CC496475267693 && pacman-key --lsign-key 63CC496475267693

# Freshen all base system packages
RUN pacman --needed --noconfirm -Syuq && yes | pacman -Sccq

# Install fontship run-time dependecies
RUN pacman --needed --noconfirm -Syq \
font-v git make python zsh \
python-{ufonormalizer,font{make,tools}} \
&& yes | pacman -Sccq

# Setup separate image to build fontship so we don't bloat the final image
FROM fontship-base AS fontship-builder

# Install build time dependecies
RUN pacman --needed --noconfirm -Syq base-devel && yes | pacman -Sccq

# Set at build time, forces Docker's layer caching to reset at this point
ARG VCS_REF=0

COPY ./ /src
WORKDIR /src

RUN git clean -dxf ||:
RUN git fetch --unshallow ||:
RUN git fetch --tags ||:

RUN ./bootstrap.sh
RUN ./configure
RUN make
RUN make install DESTDIR=/pkgdir

FROM fontship-base AS fontship

LABEL maintainer="Caleb Maclennan <[email protected]>"
LABEL version="$VCS_REF"

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

COPY --from=fontship-builder /pkgdir /

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 @@ -6,3 +6,7 @@ license_DATA = LICENSE
licensedir = $(datadir)/licenses/fontship

CLEANFILES = $(bin_SCRIPTS)

.PHONY: docker
docker: Dockerfile build-aux/docker-entrypoint.sh
docker build --tag theleagueof/fontship:HEAD ./
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ League of Moveable Type](https://www.theleagueofmoveabletype.com/).

## Setup & Usage

Fontship can be used in any of three different ways:
Fontship can be used in any of four different ways:

1. Directly on a local system that has all the required dependencies.
1. Directly on a local system that has all the required dependencies and fontship has been installed.
2. On a local system via a Docker image for low hastle setup.
3. Remotely via a CI runner.
4. By including fontship into your project's Makefile.

### Local Setup

Expand All @@ -33,9 +34,18 @@ run `./bootstrap.sh` or download and extract a tarball, then run:

### Docker Setup

Docker images are available from Docker Hub or you can build them yourself.

Add an alias:

$ alias fontship='docker run -it --volume "$(pwd):/data" --user "$(id -u):$(id -g)" theleagueof/fontship:master"
$ alias fontship='docker run -it --volume "$(pwd):/data" --user "$(id -u):$(id -g)" theleagueof/fontship:latest fontship"

You may substitute *latest*, which will always be the most recently released tagged version, with *master* to use the latest unreleased build, with a tag name to explicitly use a specific version, or with *HEAD* to use an image build locally.

To build a docker image locally, you'll want to clone this repository and run `./bootstrap.sh` or download and extract a tarball, then run:

$ ./configure
$ make docker

### CI Setup

Expand All @@ -56,3 +66,13 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
### Makefile Setup
If ⓐ your system has all the dependencies and ⓑ your project already has a `Makefile`, you can extend your existing makefile with fontship's targets my including it:

```makefile
include path/to/fontship/src/Makefile
```

This may reference a path to fontship as a git submodule (useful for locking the fontship version to your project's build), or just a relative path to somewhere you have the fontship source.
9 changes: 9 additions & 0 deletions build-aux/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env sh

set -e

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

exec "$@"
3 changes: 3 additions & 0 deletions fontship.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

VERSION = "@VERSION@"

import sys
sys.path.append("@pythondir@/".replace("${prefix}", "@prefix@"))

import fontship

# vim: ft=python

0 comments on commit f57857f

Please sign in to comment.