Skip to content

Commit

Permalink
Add Dockerfile and make CI use docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
Witiko committed Aug 25, 2021
1 parent 38ade1f commit cbc0089
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 39 deletions.
51 changes: 13 additions & 38 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,15 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
container:
image: texlive/texlive:latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install additional packages
run: |
set -ex
apt-get -qy update
apt-get -qy install curl gawk graphviz m4 pandoc parallel python3-pygments ruby wget
- name: Generate the ConTeXt file database
run: |
set -ex
mtxrun --generate
- name: Install the Markdown package
run: |
set -ex
make base
mkdir -p ~/texmf/tex/luatex/markdown/
cp -f markdown.lua ~/texmf/tex/luatex/markdown/
mkdir -p ~/texmf/scripts/markdown/
cp -f markdown-cli.lua ~/texmf/scripts/markdown/
mkdir -p ~/texmf/tex/generic/markdown/
cp -f markdown.tex ~/texmf/tex/generic/markdown/
mkdir -p ~/texmf/tex/latex/markdown/
cp -f markdown.sty ~/texmf/tex/latex/markdown/
cp -f markdownthemewitiko_dot.sty ~/texmf/tex/latex/markdown/
cp -f markdownthemewitiko_graphicx_http.sty ~/texmf/tex/latex/markdown/
cp -f markdownthemewitiko_tilde.sty ~/texmf/tex/latex/markdown/
mkdir -p ~/texmf/tex/context/third/markdown/
cp -f t-markdown.tex ~/texmf/tex/context/third/markdown/
- name: Typeset documentation and example documents
run: |
set -ex
make -j `nproc` all
- name: Build Docker image
run: make docker-image
- name: Run tests
run: |
set -ex
make test
run: docker run -v "$PWD":/git-repo -w /git-repo witiko/markdown make test
- name: Build distribution archives
run: |
set -ex
make dist
run: docker run -v "$PWD":/git-repo -w /git-repo witiko/markdown make dist
- name: Upload artifact markdown.tds.zip
uses: actions/upload-artifact@v2
with:
Expand All @@ -80,3 +46,12 @@ jobs:
with:
name: markdown.pdf
path: markdown.pdf
- name: Authenticate registry
if: github.ref == 'refs/heads/main'
uses: azure/docker-login@v1
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Publish Docker image
if: github.ref == 'refs/heads/main'
run: docker push witiko/markdown --all-tags
79 changes: 79 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
ARG AUXILIARY_FILES="\
/tmp/* \
/var/tmp/* \
/var/log/* \
/var/lib/apt/lists/* \
/var/lib/{apt,dpkg,cache,log}/* \
/usr/share/man/* \
/usr/share/locale/* \
/var/cache/apt/* \
"
ARG DEPENDENCIES="\
curl \
gawk \
graphviz \
m4 \
pandoc \
parallel \
python3-pygments \
ruby \
wget \
zip \
"
ARG BUILD_DIR=/git-repo
ARG DIST_DIR=${BUILD_DIR}/dist
ARG INSTALL_DIR=/usr/local/texlive/texmf-local

FROM texlive/texlive:latest as build
ARG DEPENDENCIES
ARG BUILD_DIR
ARG DIST_DIR
ARG INSTALL_DIR
ENV DEBIAN_FRONTEND=noninteractive \
TERM=xterm
COPY . /git-repo/
RUN set -o errexit \
&& set -o nounset \
&& set -o xtrace \
&& apt-get -qy update \
&& apt-get -qy install --no-install-recommends ${DEPENDENCIES} \
&& mtxrun --generate \
&& make -C ${BUILD_DIR} base \
&& mkdir -p ${INSTALL_DIR}/tex/luatex/markdown/ \
&& cp -f ${BUILD_DIR}/markdown.lua ${INSTALL_DIR}/tex/luatex/markdown/ \
&& mkdir -p ${INSTALL_DIR}/scripts/markdown/ \
&& cp -f ${BUILD_DIR}/markdown-cli.lua ${INSTALL_DIR}/scripts/markdown/ \
&& mkdir -p ${INSTALL_DIR}/tex/generic/markdown/ \
&& cp -f ${BUILD_DIR}/markdown.tex ${INSTALL_DIR}/tex/generic/markdown/ \
&& mkdir -p ${INSTALL_DIR}/tex/latex/markdown/ \
&& cp -f ${BUILD_DIR}/markdown.sty ${INSTALL_DIR}/tex/latex/markdown/ \
&& cp -f ${BUILD_DIR}/markdownthemewitiko_dot.sty ${INSTALL_DIR}/tex/latex/markdown/ \
&& cp -f ${BUILD_DIR}/markdownthemewitiko_graphicx_http.sty ${INSTALL_DIR}/tex/latex/markdown/ \
&& cp -f ${BUILD_DIR}/markdownthemewitiko_tilde.sty ${INSTALL_DIR}/tex/latex/markdown/ \
&& mkdir -p ${INSTALL_DIR}/tex/context/third/markdown/ \
&& cp -f ${BUILD_DIR}/t-markdown.tex ${INSTALL_DIR}/tex/context/third/markdown/ \
&& texhash \
&& make -C ${BUILD_DIR} dist \
&& mkdir ${DIST_DIR} \
&& unzip ${BUILD_DIR}/markdown.tds.zip -d ${DIST_DIR}

FROM texlive/texlive:latest
ARG AUXILIARY_FILES
ARG DEPENDENCIES
ARG DIST_DIR
ARG INSTALL_DIR
LABEL authors="Vít Novotný <witiko@mail.muni.cz>"
ENV DEBIAN_FRONTEND=noninteractive \
TERM=xterm
COPY --from=build ${DIST_DIR} ${INSTALL_DIR}/
RUN set -o errexit \
&& set -o nounset \
&& set -o xtrace \
&& apt-get -qy update \
&& apt-get -qy install --no-install-recommends ${DEPENDENCIES} \
&& apt-get -qy autoclean \
&& apt-get -qy clean \
&& apt-get -qy autoremove --purge \
&& rm -rf ${AUXILIARY_FILES} \
&& mtxrun --generate \
&& texhash
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all base clean implode dist test examples
.PHONY: all base clean implode dist test examples docker-image
AUXFILES=markdown.bbl markdown.cb markdown.cb2 markdown.glo markdown.bbl \
markdown.run.xml markdown.bib markdown.markdown.in markdown.markdown.lua \
markdown.markdown.out markdown-interfaces.md markdown-miscellanea.md \
Expand Down Expand Up @@ -45,6 +45,11 @@ all: $(MAKEABLES)
base: $(INSTALLABLES)
$(MAKE) clean

# This target builds a witiko/markdown Docker image.
docker-image:
docker build -t witiko/markdown:latest .
docker tag witiko/markdown:latest witiko/markdown:$(shell git describe --tags --always --long)

# This target extracts the source files out of the DTX archive.
$(INSTALLABLES) $(MARKDOWN_USER_MANUAL): $(INSTALLER) $(DTXARCHIVE)
xetex $<
Expand Down

0 comments on commit cbc0089

Please sign in to comment.