-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile
54 lines (43 loc) · 1.48 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
# To correctly make a statically-linked binary, we use Alpine Linux.
# The distro entirely uses musl instead of glibc which is unfriendly to be
# statically linked.
FROM docker.io/alpine:3.19 AS build
LABEL "org.opencontainers.image.title"="Seonbi"
LABEL "org.opencontainers.image.licenses"="LGPL-2.1"
RUN apk add --no-cache \
build-base=0.5-r3 \
bzip2-dev=1.0.8-r6 \
ghc=9.4.7-r1 \
libbz2=1.0.8-r6 \
xz=5.4.5-r0 \
zlib-dev=1.3.1-r0 \
zlib-static=1.3.1-r0
RUN wget -q "https://github.com/commercialhaskell/stack/releases/download/v3.3.1/stack-3.3.1-linux-$(uname -m)-bin" \
&& mv "stack-3.3.1-linux-$(uname -m)-bin" /usr/bin/stack \
&& chmod +x /usr/bin/stack
RUN stack config set system-ghc --global true
# Add just the package.yaml file to capture dependencies
COPY package.yaml /src/seonbi/package.yaml
COPY stack-ghc-9.4.yaml /src/seonbi/stack.yaml
WORKDIR /src/seonbi
# Docker will cache this command as a layer, freeing us up to
# modify source code without re-installing dependencies
# (unless the .cabal file changes!)
RUN stack setup --system-ghc
RUN stack build \
--system-ghc \
--only-snapshot \
--flag seonbi:iconv \
--flag seonbi:static
COPY . /src/seonbi
RUN cp /src/seonbi/stack-ghc-9.4.yaml /src/seonbi/stack.yaml
RUN stack build \
--system-ghc \
--flag seonbi:iconv \
--flag seonbi:static \
--copy-bins
FROM docker.io/alpine:3.19
COPY --from=build /root/.local/bin/seonbi* /usr/local/bin/
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8
CMD ["seonbi"]