simplex-chat/Dockerfile

42 lines
1.2 KiB
Text
Raw Normal View History

2024-02-14 20:33:48 +00:00
ARG TAG=22.04
2022-11-18 12:00:43 +03:00
2024-02-14 20:33:48 +00:00
FROM ubuntu:${TAG} AS build
### Build stage
# Install curl and git and simplex-chat dependencies
RUN apt-get update && apt-get install -y curl git build-essential libgmp3-dev zlib1g-dev llvm-12 llvm-12-dev libnuma-dev libssl-dev
# Specify bootstrap Haskell versions
ENV BOOTSTRAP_HASKELL_GHC_VERSION=9.6.3
2024-02-14 20:33:48 +00:00
ENV BOOTSTRAP_HASKELL_CABAL_VERSION=3.10.1.0
2022-11-18 12:00:43 +03:00
# Install ghcup
2024-02-14 20:33:48 +00:00
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 sh
# Adjust PATH
ENV PATH="/root/.cabal/bin:/root/.ghcup/bin:$PATH"
2022-11-18 12:00:43 +03:00
# Set both as default
2024-02-14 20:33:48 +00:00
RUN ghcup set ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}" && \
ghcup set cabal "${BOOTSTRAP_HASKELL_CABAL_VERSION}"
2022-11-18 12:00:43 +03:00
COPY . /project
WORKDIR /project
2022-11-18 12:00:43 +03:00
2022-11-20 14:56:01 +03:00
# Adjust build
RUN cp ./scripts/cabal.project.local.linux ./cabal.project.local
2022-11-18 12:00:43 +03:00
# Compile simplex-chat
RUN cabal update
RUN cabal build exe:simplex-chat --constraint 'simplexmq +client_library'
2024-02-14 20:33:48 +00:00
# Strip the binary from debug symbols to reduce size
RUN bin=$(find /project/dist-newstyle -name "simplex-chat" -type f -executable) && \
mv "$bin" ./ && \
strip ./simplex-chat
2024-02-14 20:33:48 +00:00
# Copy compiled app from build stage
FROM scratch AS export-stage
2024-02-14 20:33:48 +00:00
COPY --from=build /project/simplex-chat /