FROM nimlang/nim:2.0.0-alpine as builder RUN apk update && apk add autoconf \ automake \ bash \ build-base \ cmake \ curl \ git \ libtool \ ninja \ perl \ sqlite-dev \ sqlite-static ENV LIBRESSL_VERSION v3.8.2 # Compile LibreSSL Portable from source RUN git clone https://github.com/libressl/portable --depth=1 -b ${LIBRESSL_VERSION} libressl && \ cd libressl && \ ./autogen.sh && \ mkdir build-ninja && \ cd build-ninja && \ cmake -G"Ninja" .. && \ ninja COPY . /app WORKDIR /app # Build with necessary params to enable statically linking openssl, glibc and sqlite3 RUN nimble build --passL:-L/usr/lib \ -d:ssl \ -d:libressl \ -p:. \ --dynlibOverride:ssl \ --dynlibOverride:crypto \ --dynlibOverride:sqlite3 \ --dynlibOverride:tls \ --passl:-lssl \ --passl:-lsqlite3 \ --passl:-lcrypto \ --passl:-ltls \ --passL:-L/libressl/build-ninja/ssl \ --passL:-L/libressl/build-ninja/crypto \ --passL:-L/libressl/build-ninja/tls \ --passL:-static \ --passL:"-flto" \ -d:release \ --opt:speed \ --mm:orc \ --threadAnalysis:off \ --deepcopy=on \ --accept RUN strip -s /app/nim_censor_bot && \ strip -R .comment -R .note -R .note.ABI-tag /app/nim_censor_bot FROM scratch COPY --from=builder /app/nim_censor_bot / COPY --from=builder /etc/ssl/certs /etc/ssl/certs ENV DB_HOST="/data/censordata.db" EXPOSE 8080 VOLUME /data CMD ["./nim_censor_bot"]