Skip to content

Commit

Permalink
Merge pull request #836 from peti/master
Browse files Browse the repository at this point in the history
Fix the Dockerfile so that it actually builds
  • Loading branch information
ocramz authored Aug 5, 2019
2 parents 6ca0f52 + f416962 commit 530f892
Showing 1 changed file with 21 additions and 37 deletions.
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

0 comments on commit 530f892

Please sign in to comment.