mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
Compare commits
1 Commits
fix-master
...
sh/docker
| Author | SHA1 | Date | |
|---|---|---|---|
| 2abee7edf8 |
+28
-10
@@ -1,11 +1,20 @@
|
|||||||
ARG TAG=22.04
|
FROM alpine:latest AS build-stage
|
||||||
|
|
||||||
FROM ubuntu:${TAG} AS build
|
# Alpine Linux doesn't provide libtinfow.so.6 library, so we need to symlink it.
|
||||||
|
# Add essential packages for ghc/cabal to work.
|
||||||
### Build stage
|
RUN apk add --no-cache \
|
||||||
|
curl \
|
||||||
# Install curl and git and simplex-chat dependencies
|
git \
|
||||||
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
|
xz \
|
||||||
|
grep \
|
||||||
|
ghc-dev \
|
||||||
|
gmp-dev \
|
||||||
|
zlib-static \
|
||||||
|
zlib-dev \
|
||||||
|
openssl-libs-static \
|
||||||
|
openssl-dev \
|
||||||
|
alpine-sdk &&\
|
||||||
|
ln -s /usr/lib/libncursesw.so.6 /usr/lib/libtinfow.so.6
|
||||||
|
|
||||||
# Specify bootstrap Haskell versions
|
# Specify bootstrap Haskell versions
|
||||||
ENV BOOTSTRAP_HASKELL_GHC_VERSION=9.6.3
|
ENV BOOTSTRAP_HASKELL_GHC_VERSION=9.6.3
|
||||||
@@ -21,21 +30,30 @@ ENV PATH="/root/.cabal/bin:/root/.ghcup/bin:$PATH"
|
|||||||
RUN ghcup set ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}" && \
|
RUN ghcup set ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}" && \
|
||||||
ghcup set cabal "${BOOTSTRAP_HASKELL_CABAL_VERSION}"
|
ghcup set cabal "${BOOTSTRAP_HASKELL_CABAL_VERSION}"
|
||||||
|
|
||||||
|
# Install hpack
|
||||||
|
RUN cabal install --install-method=copy --installdir=/usr/local/bin hpack-0.36.0
|
||||||
|
|
||||||
|
# Copy project in PWD to dontainer
|
||||||
COPY . /project
|
COPY . /project
|
||||||
WORKDIR /project
|
WORKDIR /project
|
||||||
|
|
||||||
# Adjust build
|
# Adjust build
|
||||||
RUN cp ./scripts/cabal.project.local.linux ./cabal.project.local
|
RUN cp ./scripts/cabal.project.local.linux ./cabal.project.local
|
||||||
|
|
||||||
|
# Add optimization flags and build statically
|
||||||
|
RUN sed -i '/- -Wunused-type-patterns/a\ - -O2\n\ - -split-sections\n\ - -with-rtsopts=-N\n\ - -static\n\cc-options: -static\n\ld-options: -static -pthread' package.yaml
|
||||||
|
|
||||||
|
# Reconfigure cabal project
|
||||||
|
RUN hpack
|
||||||
|
|
||||||
# Compile simplex-chat
|
# Compile simplex-chat
|
||||||
RUN cabal update
|
RUN cabal update
|
||||||
RUN cabal build exe:simplex-chat
|
RUN cabal build -j exe:simplex-chat
|
||||||
|
|
||||||
# Strip the binary from debug symbols to reduce size
|
# Strip the binary from debug symbols to reduce size
|
||||||
RUN bin=$(find /project/dist-newstyle -name "simplex-chat" -type f -executable) && \
|
RUN bin=$(find /project/dist-newstyle -name "simplex-chat" -type f -executable) && \
|
||||||
mv "$bin" ./ && \
|
mv "$bin" ./ && \
|
||||||
strip ./simplex-chat
|
strip ./simplex-chat
|
||||||
|
|
||||||
# Copy compiled app from build stage
|
|
||||||
FROM scratch AS export-stage
|
FROM scratch AS export-stage
|
||||||
COPY --from=build /project/simplex-chat /
|
COPY --from=build-stage /project/simplex-chat /
|
||||||
|
|||||||
Reference in New Issue
Block a user