-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
67 lines (53 loc) · 1.81 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# syntax = docker/dockerfile:experimental
# [email protected]:phadej/docker-ghc.git
FROM docker-ghc:8.10.4-focal as builder
# A path we work in
WORKDIR /build
# cabal-install configuration
# - we'll be in better control of the build environment, than with default config.
COPY docker.cabal.config /build/cabal.config
ENV CABAL_CONFIG /build/cabal.config
# Update cabal-install database
RUN cabal update
# Install cabal-plan
# - we'll need it to find build artifacts
# - note: actual build tools ought to be specified in build-tool-depends field
RUN cabal install cabal-plan \
--constraint='cabal-plan ^>=0.7' \
--constraint='cabal-plan +exe' \
--installdir=/usr/local/bin
COPY *.cabal /build/
RUN --mount=type=cache,target=dist-newstyle cabal build --only-dependencies
# Add rest of the files into build environment
# - remember to keep .dockerignore up to date
COPY . /build
# BUILD!!!
RUN --mount=type=cache,target=dist-newstyle cabal build exe:franzd \
&& mkdir -p /build/artifacts && cp $(cabal-plan list-bin franzd) /build/artifacts/
# Make a final binary a bit smaller
# RUN upx /build/artifacts/franzd
# DEPLOYMENT IMAGE
##############################################################################
FROM ubuntu:20.04
LABEL author="Fumiaki Kinoshita <[email protected]>"
# Dependencies
# - no -dev stuff
# - cleanup apt stuff after installation
RUN apt-get -yq update && apt-get -yq --no-install-suggests --no-install-recommends install \
ca-certificates \
curl \
libgmp10 \
liblapack3 \
liblzma5 \
libpq5 \
libssl1.1 \
libyaml-0-2 \
netbase \
openssh-client \
zlib1g \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy build artifact from a builder stage
COPY --from=builder /build/artifacts/franzd /app/franzd
# Set up a default command to run
ENTRYPOINT ["/app/franzd"]