nim-censor-bot/Dockerfile
baalajimaestro 99868f5986
Add back stripping and use GCC LTO
I have tested this to work fine for a few days now

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
2022-05-08 20:29:52 +05:30

45 lines
1.2 KiB
Docker

FROM nimlang/nim:alpine as builder
RUN apk update && apk add git \
build-base \
curl \
bash \
openssl3 \
openssl3-dev \
openssl3-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 \
-p:. \
--dynlibOverride:ssl \
--dynlibOverride:crypto \
--dynlibOverride:sqlite3 \
--passl:-lssl \
--passl:-lsqlite3 \
--passl:-lcrypto \
--passL:-static \
--passL:"-flto" \
-d:release \
--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"]