From 5fbdaa5a02717f4601c86c9b8c29764e13b301cb Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Sat, 21 Dec 2019 19:38:34 +0000 Subject: [PATCH] ci: GitLab pipeline for the cv-builder image. This is the first of a few commits for creating the GitLab CI pipeline for building and publishing my CV. This commit adds a pipeline for building and publishing the cv-builder docker image to the GitLab container registry. Additions: - The cv-builder docker image: This commit adds a Dockerfile for building the cv-builder docker image. The image is based on the golang (buster) image and installs ConTeXt (standalone version) and the Carlito font. - The gitlab-ci.yml file: This commit adds the gitlab-ci.yml file for running the pipeline for building and publishing the docker image to the GitLab Container Registry. Changes: - The Makefile now includes targets for building and publishing docker images. --- .dockerignore | 1 + .gitlab-ci.yml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 11 ++++++++++- docker/Dockerfile | 28 ++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 .gitlab-ci.yml create mode 100644 docker/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..d23f93f --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,47 @@ +--- +stages: +- test +- build +- publish + +variables: + IMAGE_NAME: ${CI_REGISTRY}/${CI_PROJECT_PATH}/cv-builder + IMAGE_TAG: ${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA} + +services: +- docker:19.03.5-dind + +.use-docker: + image: docker:19.03.5 + +.install-deps: &install-deps +- apk add --no-cache make + +test:docker-image: + extends: .use-docker + script: + - *install-deps + - make image + stage: test + only: + changes: + - docker/Dockerfile + except: + refs: + - master + +publish:docker-image: + extends: .use-docker + before_script: + - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} + after_script: + - docker logout ${CI_REGISTRY} + script: + - *install-deps + - make publish + stage: publish + only: + changes: + - docker/Dockerfile + refs: + - master@dananglin/cv diff --git a/Makefile b/Makefile index 0bad819..a7e1afc 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,18 @@ +DOCKERFILE = ./docker/Dockerfile +IMAGE_NAME ?= cv-builder +IMAGE_TAG ?= latest OUTPUT_DIR = __output/ -.PHONY: all tex pdf clean +.PHONY: all image publish tex pdf clean all: pdf +image: + @docker build -f $(DOCKERFILE) -t $(IMAGE_NAME):$(IMAGE_TAG) . + +publish: image + @docker push $(IMAGE_NAME):$(IMAGE_TAG) + tex: @go run . diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..25a257a --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,28 @@ +FROM golang:1.13.5-buster + +# Upgrade packages and install dependencies +RUN \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + fonts-crosextra-carlito \ + rsync \ + && \ + apt-get clean autoclean && \ + apt-get autoremove -y && \ + rm -rf /var/lib/apt/lists/* /tmp/* + +# Install ConTeXt standalone +RUN \ + mkdir /opt/context && \ + cd /opt/context && \ + curl -LO http://minimals.contextgarden.net/setup/first-setup.sh && \ + sh ./first-setup.sh \ + --context=current \ + --engine=luatex \ + && \ + rm -rf /opt/context/tex/texmf-context/doc + +ENV PATH=${PATH}:/opt/context/tex/texmf-linux-64/bin \ + OSFONTDIR=/usr/share/fonts + +RUN mtxrun --script fonts --reload