FROM alpine:edge as builder RUN apk update && apk add git \ build-base \ curl \ bash \ openssl \ openssl-dev \ openssl-libs-static \ sqlite-dev \ sqlite-static ENV NIM_VERSION v1.6.12 RUN git clone https://github.com/nim-lang/Nim.git --depth=1 -b ${NIM_VERSION} && \ cd Nim && \ bash build_all.sh # Add built nim to path ENV PATH=/Nim/bin:$PATH RUN nimble install nimble --accept COPY . /app WORKDIR /app # Build with necessary params to enable statically linking openssl, glibc and sqlite3 RUN /root/.nimble/bin/nimble build --passL:-L/usr/lib \ -d:ssl \ -p:. \ --dynlibOverride:ssl \ --dynlibOverride:crypto \ --dynlibOverride:sqlite3 \ --passl:-lssl \ --passl:-lsqlite3 \ --passl:-lcrypto \ --passL:-static \ --passL:"-flto" \ -d:release \ --opt:speed \ --mm:orc \ --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"]