nim-censor-bot/Dockerfile

59 lines
1.7 KiB
Text
Raw Normal View History

FROM nimlang/nim:alpine as builder
RUN apk update && apk add git \
build-base \
clang \
llvm \
llvm-dev \
lld \
curl \
bash \
openssl \
openssl-dev \
openssl-libs-static \
sqlite-dev \
sqlite-static
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 \
--os:any \
-d:posix \
--deepcopy:on \
-d:useMalloc \
-d:noSignalHandler \
--cc:clang \
-p:. \
--dynlibOverride:ssl \
--dynlibOverride:crypto \
--dynlibOverride:sqlite3 \
--passl:-lssl \
--passl:-lsqlite3 \
--passl:-lcrypto \
--passL:-static \
--passL:"-flto=full" \
--passL:"-fuse-ld=lld" \
--gc:arc \
--panics:on \
-d:danger \
--opt:speed \
--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"]