2024-09-08 05:49:13 +00:00
|
|
|
FROM nimlang/nim:2.0.8-alpine as builder
|
2022-04-11 06:56:39 +00:00
|
|
|
|
2023-05-31 05:31:12 +00:00
|
|
|
RUN apk update && apk add autoconf \
|
|
|
|
automake \
|
|
|
|
bash \
|
2022-04-25 06:49:15 +00:00
|
|
|
build-base \
|
2023-05-31 05:31:12 +00:00
|
|
|
cmake \
|
2022-04-25 06:49:15 +00:00
|
|
|
curl \
|
2023-05-31 05:31:12 +00:00
|
|
|
git \
|
|
|
|
libtool \
|
|
|
|
ninja \
|
|
|
|
perl \
|
2022-04-25 06:49:15 +00:00
|
|
|
sqlite-dev \
|
|
|
|
sqlite-static
|
2022-04-11 06:56:39 +00:00
|
|
|
|
2023-08-21 09:35:53 +00:00
|
|
|
|
2024-09-08 05:49:13 +00:00
|
|
|
ENV LIBRESSL_VERSION v3.9.2
|
2023-05-31 05:31:12 +00:00
|
|
|
|
2023-05-31 05:33:17 +00:00
|
|
|
# Compile LibreSSL Portable from source
|
2023-05-31 05:31:12 +00:00
|
|
|
RUN git clone https://github.com/libressl/portable --depth=1 -b ${LIBRESSL_VERSION} libressl && \
|
|
|
|
cd libressl && \
|
|
|
|
./autogen.sh && \
|
|
|
|
mkdir build-ninja && \
|
|
|
|
cd build-ninja && \
|
|
|
|
cmake -G"Ninja" .. && \
|
|
|
|
ninja
|
2023-05-31 05:27:11 +00:00
|
|
|
|
|
|
|
COPY . /app
|
|
|
|
WORKDIR /app
|
|
|
|
|
2022-04-11 06:56:39 +00:00
|
|
|
# Build with necessary params to enable statically linking openssl, glibc and sqlite3
|
2023-08-21 09:35:53 +00:00
|
|
|
RUN nimble build --passL:-L/usr/lib \
|
|
|
|
-d:ssl \
|
|
|
|
-d:libressl \
|
|
|
|
-p:. \
|
|
|
|
--dynlibOverride:ssl \
|
|
|
|
--dynlibOverride:crypto \
|
|
|
|
--dynlibOverride:sqlite3 \
|
|
|
|
--dynlibOverride:tls \
|
|
|
|
--passl:-lssl \
|
|
|
|
--passl:-lsqlite3 \
|
|
|
|
--passl:-lcrypto \
|
|
|
|
--passl:-ltls \
|
|
|
|
--passL:-L/libressl/build-ninja/ssl \
|
|
|
|
--passL:-L/libressl/build-ninja/crypto \
|
|
|
|
--passL:-L/libressl/build-ninja/tls \
|
|
|
|
--passL:-static \
|
|
|
|
--passL:"-flto" \
|
|
|
|
-d:release \
|
|
|
|
--opt:speed \
|
|
|
|
--mm:orc \
|
|
|
|
--threadAnalysis:off \
|
|
|
|
--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"]
|