Commit 9344dd67 authored by Vladimír Štill's avatar Vladimír Štill
Browse files

Split dockerfiles into separate files

• prevent building parts that are not needed
• improve make dependency tracking
parent 4a1e2ae5
Loading
Loading
Loading
Loading

Dockerfile

deleted100644 → 0
+0 −79
Original line number Original line Diff line number Diff line
FROM docker.io/debian:bullseye-20220711 as base

ENV LANG            C.UTF-8
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        gnupg ca-certificates dirmngr curl git apt-utils \
        zlib1g-dev libtinfo-dev libsqlite3-dev netbase xz-utils make locales wget \
        python-is-python3

RUN echo "Europe/Prague" > /etc/timezone && \
    unlink /etc/localtime && \
    dpkg-reconfigure tzdata && \
    echo "cs_CZ.UTF-8 UTF-8" >> /etc/locale.gen && \
    echo "sk_SK.UTF-8 UTF-8" >> /etc/locale.gen && \
    echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \
    echo "en_DK.UTF-8 UTF-8" >> /etc/locale.gen && \
    dpkg-reconfigure locales &&\
    update-locale LANG=en_US.UTF-8

ENV LANG en_US.UTF-8


###############################################################################
from base as texlive

# New TeX Live
COPY texlive.profile /root/texlive.profile
RUN cd /root && \
    wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz && \
    tar xaf install-tl-unx.tar.gz && \
    cd install-tl-* && \
    ./install-tl --profile=/root/texlive.profile
RUN ls /opt/texlive/bin/x86_64-linux
ENV PATH /opt/texlive/bin/x86_64-linux:$PATH
ENV MANPATH /opt/texlive/texmf-dist/doc/man:$MANPATH
ENV INFOPATH /opt/texlive/texmf-dist/doc/info:$INFOPATH
RUN pdflatex --version && lualatex --version && context --version && latexmk --version

###############################################################################
from base as haskell-base

# g++
RUN echo 'deb http://downloads.haskell.org/debian bullseye main' > /etc/apt/sources.list.d/ghc.list && \
    apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA3CBA3FFE22B574
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
          ghc-8.4.4 ghc-8.6.5 ghc-8.8.4 ghc-8.10.4 ghc-9.0.1 cabal-install-3.6
ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/cabal/3.4/bin:/opt/ghc/9.0.1/bin:/opt/ghc/8.10.4/bin:$PATH:/opt/ghc/8.8.4/bin:/opt/ghc/8.6.5/bin:/opt/ghc/8.4.4/bin
RUN ghc --version && ghci --version

from haskell-base as haskell-ib015

# here we also need TeXLive
COPY --from texlive /opt/texlive
ENV PATH /opt/texlive/bin/x86_64-linux:$PATH
ENV MANPATH /opt/texlive/texmf-dist/doc/man:$MANPATH
ENV INFOPATH /opt/texlive/texmf-dist/doc/info:$INFOPATH
RUN pdflatex --version && lualatex --version && context --version && latexmk --version

# install dependencies for Haskell study materials
RUN cabal v2-update && cabal v2-install pandoc-2.14
RUN for GHC in ghc-8.4.4 ghc-8.6.5 ghc-8.8.4 ghc-8.10.4 ghc-9.0.1; do cabal v2-install --lib --with-ghc $GHC HUnit QuickCheck deepseq random printf-mauke aeson data-default-class text; done

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        fonts-lmodern make rubber pandoc-citeproc \
         hlint zip swi-prolog graphviz inkscape dot2tex \
         python3-pkg-resources python3-yaml python3-pip python3-setuptools \
         python3-pygments rsync ssh ca-certificates \
         libicu-dev context texlive-font-utils \
         libpoppler-glib-dev

RUN pip3 install flake8 pylint pycodestyle mypy mypy-extensions pytest hypothesis
RUN pytest --version && mypy --version && flake8 --version


CMD ["bash"]
+17 −10
Original line number Original line Diff line number Diff line
DOCKER   = docker
DOCKER   = docker
IMAGES   = base haskell-base texlive haskell-ib015
IMAGES   = base haskell-base texlive haskell-ib015
# the tag of the built images, that is basically their version
TAG      = v2022.0.0
TAG      = v2022.0.0
# what debian image to use as base for base image
DEBIAN   = bullseye-20220711
REGISTRY = gitlab.fi.muni.cz:5050
REGISTRY = gitlab.fi.muni.cz:5050
PROJECT  = xstill/ci-images
PROJECT  = xstill/ci-images
USERNAME != whoami
USERNAME != whoami


-include local.make
-include local.make


all: Dockerfile
PREFIX = $(REGISTRY)/$(PROJECT)
	$(DOCKER) build $(DOCKEROPTS) -t '$(IMAGE):$(TAG)' .
BUILD_FLAGS += --build-arg DEBIAN_VERSION=$(DEBIAN) --build-arg TAG=$(TAG) --build-arg PREFIX=$(PREFIX)/
	$(DOCKER) tag '$(IMAGE):$(TAG)' '$(IMAGE):latest'


push : $(IMAGES:%=_stamps/push.%)
all: $(IMAGES)
	@echo "images build, use `make push` to publish them"


$(IMAGES) : % : _stamps/build.%
push : $(IMAGES:%=push-%)

$(IMAGES:%=push-%) : push-% : _stamps/push.%.$(TAG)

$(IMAGES) : % : _stamps/build.%.$(TAG)


login :
login :
	$(DOCKER) login $(REGISTRY) || $(DOCKER) login --username $(USERNAME) $(REGISTRY)
	$(DOCKER) login --get-login $(REGISTRY) || $(DOCKER) login --username $(USERNAME) $(REGISTRY)


_stamps/build.% : Dockerfile
_stamps/build.%.$(TAG) : %.Dockerfile
	mkdir -p _stamps
	mkdir -p _stamps
	$(DOCKER) build --tag $(@:_stamps/build.%=%):$(TAG) --target $(@:_stamps/build.%=%) .
	$(DOCKER) build $(BUILD_FLAGS) --tag $(PREFIX)/$(@:_stamps/build.%.$(TAG)=%):$(TAG) -f $(@:_stamps/build.%.$(TAG)=%).Dockerfile .
	touch $@
	touch $@


_stamps/push.% : _stamps/build.% login
_stamps/push.%.$(TAG) : _stamps/build.%.$(TAG) login
	$(DOCKER) push $(@:_stamps/push.%=%):$(TAG)  $(REGISTRY)/$(PROJECT)/$(@:_stamps/push.%=%):$(TAG)
	$(DOCKER) push $(PREFIX)/$(@:_stamps/push.%.$(TAG)=%):$(TAG)
	touch $@
	touch $@


.PHONY: push all login $(IMAGES)
.PHONY: push all login $(IMAGES)

base.Dockerfile

0 → 100644
+27 −0
Original line number Original line Diff line number Diff line
ARG DEBIAN_VERSION=latest
ARG TAG=latest
ARG PREFIX=
FROM docker.io/debian:${DEBIAN_VERSION} as ${PREFIX}base:${TAG}

ENV LANG            C.UTF-8
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        gnupg ca-certificates dirmngr curl git apt-utils \
        zlib1g-dev libtinfo-dev libsqlite3-dev netbase xz-utils make locales wget \
        python-is-python3

RUN echo "Europe/Prague" > /etc/timezone && \
    unlink /etc/localtime && \
    dpkg-reconfigure tzdata && \
    echo "cs_CZ.UTF-8 UTF-8" >> /etc/locale.gen && \
    echo "sk_SK.UTF-8 UTF-8" >> /etc/locale.gen && \
    echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \
    echo "en_DK.UTF-8 UTF-8" >> /etc/locale.gen && \
    dpkg-reconfigure locales &&\
    update-locale LANG=en_US.UTF-8

ENV LANG en_US.UTF-8

CMD ["bash"]
+22 −0
Original line number Original line Diff line number Diff line
ARG DEBIAN_VERSION=latest
ARG TAG=latest
ARG PREFIX=
from ${PREFIX}base:${TAG} as ${PREFIX}haskell-base:${TAG}

ARG CABAL_VERSION=3.6

# g++
RUN echo 'deb http://downloads.haskell.org/debian bullseye main' > /etc/apt/sources.list.d/ghc.list && \
    apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA3CBA3FFE22B574
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
          ghc-8.4.4 ghc-8.6.5 ghc-8.8.4 ghc-8.10.4 ghc-9.0.1 cabal-install-${CABAL_VERSION} \
	  hlint
ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/cabal/${CABAL_VERSION}/bin:/opt/ghc/9.0.1/bin:/opt/ghc/8.10.4/bin:$PATH:/opt/ghc/8.8.4/bin:/opt/ghc/8.6.5/bin:/opt/ghc/8.4.4/bin

# validate
RUN ghc --version
RUN ghci --version
RUN cabal --version

CMD ["bash"]
+27 −0
Original line number Original line Diff line number Diff line
ARG DEBIAN_VERSION=latest
ARG TAG=latest
ARG PREFIX=
from ${PREFIX}haskell-base:${TAG} as ${PREFIX}haskell-ib015:${TAG}

# here we also need TeXLive
COPY --from=${PREFIX}texlive:${TAG} /opt/texlive /opt/texlive
ENV PATH /opt/texlive/bin/x86_64-linux:$PATH
ENV MANPATH /opt/texlive/texmf-dist/doc/man:$MANPATH
ENV INFOPATH /opt/texlive/texmf-dist/doc/info:$INFOPATH
RUN pdflatex --version && lualatex --version && context --version && latexmk --version

# install dependencies for Haskell study materials
RUN cabal v2-update && cabal v2-install pandoc-2.14
RUN for GHC in ghc-8.4.4 ghc-8.6.5 ghc-8.8.4 ghc-8.10.4 ghc-9.0.1; do cabal v2-install --lib --with-ghc $GHC HUnit QuickCheck deepseq random printf-mauke aeson data-default-class text; done

RUN apt-get install -y --no-install-recommends \
        fonts-lmodern pandoc-citeproc \
         zip swi-prolog graphviz inkscape \
         python3-pkg-resources python3-yaml python3-pip python3-setuptools \
         python3-pygments rsync ssh ca-certificates \
         libicu-dev libpoppler-glib-dev

RUN pip3 install flake8 pylint pycodestyle mypy mypy-extensions pytest hypothesis
RUN pytest --version && mypy --version && flake8 --version

CMD ["bash"]
Loading