nim-censor-bot/Dockerfile
baalajimaestro 3cb6f91086
Some more size optimizations
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
2022-04-25 10:33:18 +05:30

40 lines
1.1 KiB
Docker

FROM nimlang/nim:alpine as builder
RUN apk update && apk add git build-base 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 \
-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" \
-d:danger \
--opt:speed \
--accept
# Our binary lives in this image
FROM gcr.io/distroless/base:latest
COPY --from=builder /app/nim_censor_bot /
ENV DB_HOST="/data/censordata.db"
EXPOSE 8080
VOLUME /data
CMD ["./nim_censor_bot"]