nim-censor-bot/Dockerfile
baalajimaestro 5eab571e37
Include upstream patch to fix libressl
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
2023-05-31 10:58:08 +05:30

61 lines
1.9 KiB
Docker

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 && \
git config user.name gitlab && \
git config user.email gitlab-ci@git.baalajimaestro.me && \
curl https://github.com/nim-lang/Nim/commit/7c96eb45482dae4a78cf05d7fa85ae5018e2fe5f.patch | git am && \
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"]