Skip to content

Fix the Dockerfile so that it actually builds #836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 21 additions & 37 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,59 +10,43 @@
# Docker> # hackage-server run --static-dir=datafiles
#

# Set up the system environment.
FROM ubuntu

RUN apt-get update

# Install apt-add-repository
RUN apt-get install -y software-properties-common

# Use Herbert's PPA on Ubuntu for getting GHC and cabal-install
RUN apt-add-repository ppa:hvr/ghc

RUN apt-get update

# Dependencies
RUN apt-get install -yy unzip libicu-dev postfix
RUN apt-get install -y ghc-8.2.1 cabal-install-2.0
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y ghc-8.2.2 cabal-install-2.4
ENV PATH /opt/ghc/bin:$PATH
RUN cabal update

# Required Header files
RUN apt-get install -y zlib1g-dev libssl-dev

# haskell dependencies
RUN cabal v2-update

# Install current HEAD version of cabal-install.
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y curl zlib1g-dev
WORKDIR /tmp
RUN curl --silent -L https://github.com/haskell/cabal/tarball/dc138034d469973fee43af86764567e4202ca84b | tar xz
WORKDIR /tmp/haskell-cabal-dc13803
RUN cabal v2-install -j cabal-install
ENV PATH /root/.cabal/bin:$PATH

# Build hackage-server.
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y zlib1g-dev libssl-dev unzip libicu-dev postfix
RUN mkdir /build
WORKDIR /build
ADD ./hackage-server.cabal ./hackage-server.cabal
RUN cabal sandbox init
# TODO: Switch to Nix-style cabal new-install
RUN cabal install --only-dependencies --enable-tests -j --force-reinstalls
ENV PATH /build/.cabal-sandbox/bin:$PATH

# needed for creating TUF keys
RUN cabal install hackage-repo-tool

# add code
# note: this must come after installing the dependencies, such that
# we don't need to rebuilt the dependencies every time the code changes
ADD . /build

# generate keys (needed for tests)
ADD hackage-server.cabal cabal.project ./
RUN cabal v2-build --only-dependencies --enable-tests
RUN cabal v2-install --help
RUN cabal v2-install --installdir=/root/.cabal/bin hackage-repo-tool
ADD . ./
RUN hackage-repo-tool create-keys --keys keys
RUN cp keys/timestamp/*.private datafiles/TUF/timestamp.private
RUN cp keys/snapshot/*.private datafiles/TUF/snapshot.private
RUN hackage-repo-tool create-root --keys keys -o datafiles/TUF/root.json
RUN hackage-repo-tool create-mirrors --keys keys -o datafiles/TUF/mirrors.json

# build & test & install hackage
RUN cabal configure -f-build-hackage-mirror --enable-tests
RUN cabal build
# tests currently don't pass: the hackage-security work introduced some
# backup/restore errors (though they look harmless)
# see https://github.com/haskell/hackage-server/issues/425
#RUN cabal test
RUN cabal copy && cabal register
#RUN cabal v2-test
RUN cabal v2-install --installdir=/root/.cabal/bin all

# setup server runtime environment
RUN mkdir /runtime
Expand Down