2023-05-31 05:27:11 +00:00
|
|
|
FROM alpine:edge 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-05-31 05:27:11 +00:00
|
|
|
ENV NIM_VERSION v1.6.12
|
2023-05-31 05:31:12 +00:00
|
|
|
ENV LIBRESSL_VERSION v3.8.0
|
|
|
|
|
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
|
|
|
|
2023-05-31 05:33:17 +00:00
|
|
|
# Compile Nim from source including upstream patch
|
2023-05-31 05:27:11 +00:00
|
|
|
RUN git clone https://github.com/nim-lang/Nim.git --depth=1 -b ${NIM_VERSION} && \
|
|
|
|
cd Nim && \
|
2023-05-31 05:28:08 +00:00
|
|
|
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 && \
|
2023-05-31 05:27:11 +00:00
|
|
|
bash build_all.sh
|
|
|
|
|
|
|
|
# Add built nim to path
|
|
|
|
ENV PATH=/Nim/bin:$PATH
|
2022-04-11 06:56:39 +00:00
|
|
|
|
2023-05-31 05:33:17 +00:00
|
|
|
# Update nimble
|
2023-04-21 05:17:17 +00:00
|
|
|
RUN nimble install nimble --accept
|
|
|
|
|
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-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 \
|
2023-05-31 05:31:12 +00:00
|
|
|
--dynlibOverride:tls \
|
2023-04-21 05:17:17 +00:00
|
|
|
--passl:-lssl \
|
|
|
|
--passl:-lsqlite3 \
|
|
|
|
--passl:-lcrypto \
|
2023-05-31 05:31:12 +00:00
|
|
|
--passl:-ltls \
|
|
|
|
--passL:-L/libressl/build-ninja/ssl \
|
|
|
|
--passL:-L/libressl/build-ninja/crypto \
|
|
|
|
--passL:-L/libressl/build-ninja/tls \
|
2023-05-31 05:33:17 +00:00
|
|
|
--passL:-static \
|
|
|
|
--passL:"-flto" \
|
2023-04-21 05:17:17 +00:00
|
|
|
-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"]
|