Skip to content

Commit

Permalink
Add docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed Mar 1, 2019
1 parent ac5d660 commit 99e171e
Show file tree
Hide file tree
Showing 13 changed files with 696 additions and 0 deletions.
1 change: 1 addition & 0 deletions docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*-image
63 changes: 63 additions & 0 deletions docker/Dockerfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM ubuntu:xenial
MAINTAINER Oleg Grenrus <[email protected]>

# UTF FTW
ENV LANG C.UTF-8

# hvr-ppa and some core packages
RUN apt-get -yq update && apt-get -yq --no-install-suggests --no-install-recommends install \
autoconf \
build-essential \
ca-certificates \
git \
python-software-properties \
pkg-config \
software-properties-common \
sudo \
&& apt-add-repository -y "ppa:hvr/ghc" \
&& apt-get autoremove -y --purge && apt-get clean && rm -rf /var/lib/apt/lists/*

# Dependencies
RUN apt-get -yq update && apt-get -yq --no-install-suggests --no-install-recommends install \
libbz2-dev \
libfftw3-dev \
libgmp-dev \
liblapack-dev \
libncurses-dev \
libncursesw5-dev \
libpq-dev \
libsqlite3-dev \
libssl-dev \
lzma-dev \
zlib1g-dev \
&& apt-get autoremove -y --purge && apt-get clean && rm -rf /var/lib/apt/lists/*

# User
RUN adduser haskellci --gecos "Haskell CI builds" --disabled-password
RUN echo "haskellci ALL = NOPASSWD : ALL" > /etc/sudoers.d/ghc
USER haskellci
WORKDIR /home/haskellci
ENV PATH /home/haskellci/.cabal/bin:$PATH

# Cmd
CMD ["/bin/bash"]

# We install cabal-install always, also for generic image
RUN sudo apt-get -yq update && sudo apt-get -yq --no-install-suggests --no-install-recommends install \
cabal-install-2.4 \
&& sudo apt-get autoremove -y --purge && sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/* && rm -rf /home/haskellci/.cabal/packages

# TODO: when cabal-install-3.0 is out with `copy`; install cabal-plan :)

# We also perform initial v2-update
# 01-index.tar.gz is large, but rather it's downloaded during the image download
RUN /opt/ghc/bin/cabal v2-update \
&& mv /home/haskellci/.cabal/packages/hackage.haskell.org/01-index.tar.gz /home/haskellci/01-index.tar.gz \
&& rm -rf /home/haskellci/.cabal \
&& mkdir -p /home/haskellci/.cabal/packages/hackage.haskell.org \
&& mv /home/haskellci/01-index.tar.gz /home/haskellci/.cabal/packages/hackage.haskell.org/01-index.tar.gz

__ # Image specific GHC GHC
__ RUN sudo apt-get -yq update && sudo apt-get -yq --no-install-suggests --no-install-recommends install \
__ __HC__ \
__ && sudo apt-get autoremove -y --purge && sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/*
41 changes: 41 additions & 0 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
TAG=1

COMPILERS=ghc-8.4.4 ghc-8.2.2 ghc-8.0.2 ghc-7.10.3 ghc-7.8.4 ghc-7.6.3 ghc-7.4.2 ghc-7.0.2

IMAGES=generic-image $(COMPILERS:%=%-image)

.PHONY : all clean images push-images
.PRECIOUS : generic/Dockerfile $(COMPILERS:%=%/Dockerfile)

all : images

clean :
rm -f $(IMAGES)

generic/Dockerfile : Dockerfile.template
mkdir -p generic
cat $< | sed 's/^__.*//' > $@

%/Dockerfile : Dockerfile.template
mkdir -p $*
cat $< | sed 's/__HC__/$*/g' | sed 's/^__ //' > $@

images : $(IMAGES)

# Strips __ section
generic-image : generic/Dockerfile
docker build -t registry.gitlab.com/haskell-ci/haskell-ci/generic generic
docker build -t registry.gitlab.com/haskell-ci/haskell-ci/generic:1 generic
touch $@

# Uses __ section and rewrites __HC__ to the actual compiler
%-image : %/Dockerfile
docker build -t registry.gitlab.com/haskell-ci/haskell-ci/$* $*
docker build -t registry.gitlab.com/haskell-ci/haskell-ci/$*:$(TAG) $*
touch $@

push-images : images
for HC in generic $(COMPILERS); do \
docker push registry.gitlab.com/haskell-ci/haskell-ci/$$HC; \
docker push registry.gitlab.com/haskell-ci/haskell-ci/$$HC:$(TAG); \
done
24 changes: 24 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Build docker images

Current registry is: https://gitlab.com/haskell-ci/haskell-ci/container_registry

We don't build images for each compiler, only for latest in series (for now)

All images are built from the same template, `Dockerfile.template`
We install few C `-dev` dependencies. Make a PR if you need some more.

There's also a `generic` image without `ghc` and `cabal`, which is used
in cases where there are no image for that ghc&cabal pair.

- `make all` will build images
- `make push-images` will also push them to the registry
- `make ghc-8.4.4-image` or `make generic-image` to build single image.
This is useful when making changes (and checking the size of resulting images)

## Misc

Docker cleanup:

```
docker system prune --volumes
```
63 changes: 63 additions & 0 deletions docker/generic/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM ubuntu:xenial
MAINTAINER Oleg Grenrus <[email protected]>

# UTF FTW
ENV LANG C.UTF-8

# hvr-ppa and some core packages
RUN apt-get -yq update && apt-get -yq --no-install-suggests --no-install-recommends install \
autoconf \
build-essential \
ca-certificates \
git \
python-software-properties \
pkg-config \
software-properties-common \
sudo \
&& apt-add-repository -y "ppa:hvr/ghc" \
&& apt-get autoremove -y --purge && apt-get clean && rm -rf /var/lib/apt/lists/*

# Dependencies
RUN apt-get -yq update && apt-get -yq --no-install-suggests --no-install-recommends install \
libbz2-dev \
libfftw3-dev \
libgmp-dev \
liblapack-dev \
libncurses-dev \
libncursesw5-dev \
libpq-dev \
libsqlite3-dev \
libssl-dev \
lzma-dev \
zlib1g-dev \
&& apt-get autoremove -y --purge && apt-get clean && rm -rf /var/lib/apt/lists/*

# User
RUN adduser haskellci --gecos "Haskell CI builds" --disabled-password
RUN echo "haskellci ALL = NOPASSWD : ALL" > /etc/sudoers.d/ghc
USER haskellci
WORKDIR /home/haskellci
ENV PATH /home/haskellci/.cabal/bin:$PATH

# Cmd
CMD ["/bin/bash"]

# We install cabal-install always, also for generic image
RUN sudo apt-get -yq update && sudo apt-get -yq --no-install-suggests --no-install-recommends install \
cabal-install-2.4 \
&& sudo apt-get autoremove -y --purge && sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/* && rm -rf /home/haskellci/.cabal/packages

# TODO: when cabal-install-3.0 is out with `copy`; install cabal-plan :)

# We also perform initial v2-update
# 01-index.tar.gz is large, but rather it's downloaded during the image download
RUN /opt/ghc/bin/cabal v2-update \
&& mv /home/haskellci/.cabal/packages/hackage.haskell.org/01-index.tar.gz /home/haskellci/01-index.tar.gz \
&& rm -rf /home/haskellci/.cabal \
&& mkdir -p /home/haskellci/.cabal/packages/hackage.haskell.org \
&& mv /home/haskellci/01-index.tar.gz /home/haskellci/.cabal/packages/hackage.haskell.org/01-index.tar.gz





63 changes: 63 additions & 0 deletions docker/ghc-7.0.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM ubuntu:xenial
MAINTAINER Oleg Grenrus <[email protected]>

# UTF FTW
ENV LANG C.UTF-8

# hvr-ppa and some core packages
RUN apt-get -yq update && apt-get -yq --no-install-suggests --no-install-recommends install \
autoconf \
build-essential \
ca-certificates \
git \
python-software-properties \
pkg-config \
software-properties-common \
sudo \
&& apt-add-repository -y "ppa:hvr/ghc" \
&& apt-get autoremove -y --purge && apt-get clean && rm -rf /var/lib/apt/lists/*

# Dependencies
RUN apt-get -yq update && apt-get -yq --no-install-suggests --no-install-recommends install \
libbz2-dev \
libfftw3-dev \
libgmp-dev \
liblapack-dev \
libncurses-dev \
libncursesw5-dev \
libpq-dev \
libsqlite3-dev \
libssl-dev \
lzma-dev \
zlib1g-dev \
&& apt-get autoremove -y --purge && apt-get clean && rm -rf /var/lib/apt/lists/*

# User
RUN adduser haskellci --gecos "Haskell CI builds" --disabled-password
RUN echo "haskellci ALL = NOPASSWD : ALL" > /etc/sudoers.d/ghc
USER haskellci
WORKDIR /home/haskellci
ENV PATH /home/haskellci/.cabal/bin:$PATH

# Cmd
CMD ["/bin/bash"]

# We install cabal-install always, also for generic image
RUN sudo apt-get -yq update && sudo apt-get -yq --no-install-suggests --no-install-recommends install \
cabal-install-2.4 \
&& sudo apt-get autoremove -y --purge && sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/* && rm -rf /home/haskellci/.cabal/packages

# TODO: when cabal-install-3.0 is out with `copy`; install cabal-plan :)

# We also perform initial v2-update
# 01-index.tar.gz is large, but rather it's downloaded during the image download
RUN /opt/ghc/bin/cabal v2-update \
&& mv /home/haskellci/.cabal/packages/hackage.haskell.org/01-index.tar.gz /home/haskellci/01-index.tar.gz \
&& rm -rf /home/haskellci/.cabal \
&& mkdir -p /home/haskellci/.cabal/packages/hackage.haskell.org \
&& mv /home/haskellci/01-index.tar.gz /home/haskellci/.cabal/packages/hackage.haskell.org/01-index.tar.gz

# Image specific GHC GHC
RUN sudo apt-get -yq update && sudo apt-get -yq --no-install-suggests --no-install-recommends install \
ghc-7.0.2 \
&& sudo apt-get autoremove -y --purge && sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/*
63 changes: 63 additions & 0 deletions docker/ghc-7.10.3/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM ubuntu:xenial
MAINTAINER Oleg Grenrus <[email protected]>

# UTF FTW
ENV LANG C.UTF-8

# hvr-ppa and some core packages
RUN apt-get -yq update && apt-get -yq --no-install-suggests --no-install-recommends install \
autoconf \
build-essential \
ca-certificates \
git \
python-software-properties \
pkg-config \
software-properties-common \
sudo \
&& apt-add-repository -y "ppa:hvr/ghc" \
&& apt-get autoremove -y --purge && apt-get clean && rm -rf /var/lib/apt/lists/*

# Dependencies
RUN apt-get -yq update && apt-get -yq --no-install-suggests --no-install-recommends install \
libbz2-dev \
libfftw3-dev \
libgmp-dev \
liblapack-dev \
libncurses-dev \
libncursesw5-dev \
libpq-dev \
libsqlite3-dev \
libssl-dev \
lzma-dev \
zlib1g-dev \
&& apt-get autoremove -y --purge && apt-get clean && rm -rf /var/lib/apt/lists/*

# User
RUN adduser haskellci --gecos "Haskell CI builds" --disabled-password
RUN echo "haskellci ALL = NOPASSWD : ALL" > /etc/sudoers.d/ghc
USER haskellci
WORKDIR /home/haskellci
ENV PATH /home/haskellci/.cabal/bin:$PATH

# Cmd
CMD ["/bin/bash"]

# We install cabal-install always, also for generic image
RUN sudo apt-get -yq update && sudo apt-get -yq --no-install-suggests --no-install-recommends install \
cabal-install-2.4 \
&& sudo apt-get autoremove -y --purge && sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/* && rm -rf /home/haskellci/.cabal/packages

# TODO: when cabal-install-3.0 is out with `copy`; install cabal-plan :)

# We also perform initial v2-update
# 01-index.tar.gz is large, but rather it's downloaded during the image download
RUN /opt/ghc/bin/cabal v2-update \
&& mv /home/haskellci/.cabal/packages/hackage.haskell.org/01-index.tar.gz /home/haskellci/01-index.tar.gz \
&& rm -rf /home/haskellci/.cabal \
&& mkdir -p /home/haskellci/.cabal/packages/hackage.haskell.org \
&& mv /home/haskellci/01-index.tar.gz /home/haskellci/.cabal/packages/hackage.haskell.org/01-index.tar.gz

# Image specific GHC GHC
RUN sudo apt-get -yq update && sudo apt-get -yq --no-install-suggests --no-install-recommends install \
ghc-7.10.3 \
&& sudo apt-get autoremove -y --purge && sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/*
63 changes: 63 additions & 0 deletions docker/ghc-7.4.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM ubuntu:xenial
MAINTAINER Oleg Grenrus <[email protected]>

# UTF FTW
ENV LANG C.UTF-8

# hvr-ppa and some core packages
RUN apt-get -yq update && apt-get -yq --no-install-suggests --no-install-recommends install \
autoconf \
build-essential \
ca-certificates \
git \
python-software-properties \
pkg-config \
software-properties-common \
sudo \
&& apt-add-repository -y "ppa:hvr/ghc" \
&& apt-get autoremove -y --purge && apt-get clean && rm -rf /var/lib/apt/lists/*

# Dependencies
RUN apt-get -yq update && apt-get -yq --no-install-suggests --no-install-recommends install \
libbz2-dev \
libfftw3-dev \
libgmp-dev \
liblapack-dev \
libncurses-dev \
libncursesw5-dev \
libpq-dev \
libsqlite3-dev \
libssl-dev \
lzma-dev \
zlib1g-dev \
&& apt-get autoremove -y --purge && apt-get clean && rm -rf /var/lib/apt/lists/*

# User
RUN adduser haskellci --gecos "Haskell CI builds" --disabled-password
RUN echo "haskellci ALL = NOPASSWD : ALL" > /etc/sudoers.d/ghc
USER haskellci
WORKDIR /home/haskellci
ENV PATH /home/haskellci/.cabal/bin:$PATH

# Cmd
CMD ["/bin/bash"]

# We install cabal-install always, also for generic image
RUN sudo apt-get -yq update && sudo apt-get -yq --no-install-suggests --no-install-recommends install \
cabal-install-2.4 \
&& sudo apt-get autoremove -y --purge && sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/* && rm -rf /home/haskellci/.cabal/packages

# TODO: when cabal-install-3.0 is out with `copy`; install cabal-plan :)

# We also perform initial v2-update
# 01-index.tar.gz is large, but rather it's downloaded during the image download
RUN /opt/ghc/bin/cabal v2-update \
&& mv /home/haskellci/.cabal/packages/hackage.haskell.org/01-index.tar.gz /home/haskellci/01-index.tar.gz \
&& rm -rf /home/haskellci/.cabal \
&& mkdir -p /home/haskellci/.cabal/packages/hackage.haskell.org \
&& mv /home/haskellci/01-index.tar.gz /home/haskellci/.cabal/packages/hackage.haskell.org/01-index.tar.gz

# Image specific GHC GHC
RUN sudo apt-get -yq update && sudo apt-get -yq --no-install-suggests --no-install-recommends install \
ghc-7.4.2 \
&& sudo apt-get autoremove -y --purge && sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/*
Loading

0 comments on commit 99e171e

Please sign in to comment.