2022-04-11 07:14:51 +00:00
|
|
|
FROM nimlang/nim:alpine as builder
|
2022-04-11 06:56:39 +00:00
|
|
|
|
2022-04-25 06:49:15 +00:00
|
|
|
RUN apk update && apk add git \
|
|
|
|
build-base \
|
|
|
|
curl \
|
|
|
|
bash \
|
2023-01-05 09:01:30 +00:00
|
|
|
openssl \
|
|
|
|
openssl-dev \
|
|
|
|
openssl-libs-static \
|
2022-04-25 06:49:15 +00:00
|
|
|
sqlite-dev \
|
|
|
|
sqlite-static
|
2022-04-11 06:56:39 +00:00
|
|
|
|
|
|
|
COPY . /app
|
2022-04-11 07:14:51 +00:00
|
|
|
WORKDIR /app
|
2022-04-11 06:56:39 +00:00
|
|
|
|
2023-04-21 05:17:17 +00:00
|
|
|
RUN nimble install nimble --accept
|
|
|
|
|
2022-04-11 06:56:39 +00:00
|
|
|
# Build with necessary params to enable statically linking openssl, glibc and sqlite3
|
2023-04-21 05:17:17 +00:00
|
|
|
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
|
2022-04-11 06:56:39 +00:00
|
|
|
|
2022-05-08 14:59:52 +00:00
|
|
|
RUN strip -s /app/nim_censor_bot && \
|
|
|
|
strip -R .comment -R .note -R .note.ABI-tag /app/nim_censor_bot
|
|
|
|
|
2022-04-25 07:02:20 +00:00
|
|
|
FROM scratch
|
2022-04-11 06:56:39 +00:00
|
|
|
|
2022-04-11 07:14:51 +00:00
|
|
|
COPY --from=builder /app/nim_censor_bot /
|
2022-04-25 07:02:20 +00:00
|
|
|
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
|
2022-04-11 07:14:51 +00:00
|
|
|
|
|
|
|
ENV DB_HOST="/data/censordata.db"
|
|
|
|
|
2022-04-11 10:15:42 +00:00
|
|
|
EXPOSE 8080
|
2022-04-11 07:14:51 +00:00
|
|
|
VOLUME /data
|
|
|
|
|
2022-04-11 06:56:39 +00:00
|
|
|
CMD ["./nim_censor_bot"]
|