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:12:08 +00:00
|
|
|
RUN apk update && apk add git build-base clang perl autoconf automake libtool llvm llvm-dev lld curl bash openssl sqlite-dev sqlite-static
|
|
|
|
|
|
|
|
RUN git clone https://github.com/libressl-portable/portable && \
|
|
|
|
cd portable && \
|
2022-04-25 06:13:26 +00:00
|
|
|
./autogen.sh &> /dev/null && \
|
2022-04-25 06:12:08 +00:00
|
|
|
./configure --with-openssldir=/usr/local/libressl --disable-shared &> /dev/null && \
|
|
|
|
make -j$(nproc) &> /dev/null && \
|
|
|
|
make install &> /dev/null
|
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
|
|
|
|
|
|
|
# Build with necessary params to enable statically linking openssl, glibc and sqlite3
|
|
|
|
RUN nimble build --passL:-L/usr/lib \
|
2022-04-25 06:12:08 +00:00
|
|
|
--passL:-L/usr/local/lib \
|
2022-04-11 06:56:39 +00:00
|
|
|
-d:ssl \
|
2022-04-25 05:03:18 +00:00
|
|
|
--os:any \
|
|
|
|
-d:posix \
|
2022-04-25 06:12:08 +00:00
|
|
|
-d:libressl \
|
2022-04-25 05:03:18 +00:00
|
|
|
-d:useMalloc \
|
|
|
|
-d:noSignalHandler \
|
2022-04-25 04:38:24 +00:00
|
|
|
--cc:clang \
|
2022-04-11 06:56:39 +00:00
|
|
|
-p:. \
|
|
|
|
--dynlibOverride:ssl \
|
|
|
|
--dynlibOverride:crypto \
|
|
|
|
--dynlibOverride:sqlite3 \
|
|
|
|
--passl:-lssl \
|
|
|
|
--passl:-lsqlite3 \
|
|
|
|
--passl:-lcrypto \
|
|
|
|
--passL:-static \
|
2022-04-25 04:57:35 +00:00
|
|
|
--passL:"-flto=full" \
|
2022-04-25 04:57:55 +00:00
|
|
|
--passL:"-fuse-ld=lld" \
|
2022-04-25 05:45:44 +00:00
|
|
|
--gc:arc \
|
2022-04-25 06:12:45 +00:00
|
|
|
--panics:on \
|
2022-04-25 05:02:14 +00:00
|
|
|
-d:danger \
|
2022-04-25 04:37:06 +00:00
|
|
|
--opt:speed \
|
2022-04-11 07:14:51 +00:00
|
|
|
--accept
|
2022-04-11 06:56:39 +00:00
|
|
|
|
2022-04-25 06:13:54 +00:00
|
|
|
RUN strip -s /app/nim_censor_bot && \
|
|
|
|
strip -R .comment -R .note -R .note.ABI-tag /app/nim_censor_bot
|
|
|
|
|
2022-04-11 06:56:39 +00:00
|
|
|
# Our binary lives in this image
|
|
|
|
FROM gcr.io/distroless/base:latest
|
|
|
|
|
2022-04-11 07:14:51 +00:00
|
|
|
COPY --from=builder /app/nim_censor_bot /
|
|
|
|
|
|
|
|
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"]
|