From d97bb049cdd3555c0aca20b9efc4139e9449374b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Met?= Date: Mon, 2 Jul 2018 15:59:27 +0200 Subject: [PATCH] dockerization --- Dockerfile | 27 +++++++++++++++++++++++++++ entrypoint.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 Dockerfile create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..49420c4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM mono:5.12.0.226 AS webminerpool-build + +ARG DONATION_LEVEL=0.03 + +COPY server /server +COPY hash_cn /hash_cn + +RUN sed -ri "s/^(.*DonationLevel = )[0-9]\.[0-9]{2}/\1${DONATION_LEVEL}/" /server/Server/DevDonation.cs && \ + apt-get -qq update && \ + apt-get -qq install build-essential && \ + cd /hash_cn/libhash && \ + make && \ + cd /server && \ + msbuild Server.sln /p:Configuration=Release_Server /p:Platform="any CPU" + +FROM mono:5.12.0.226 + +VOLUME ["/root"] + +RUN mkdir /webminerpool +COPY entrypoint.sh /entrypoint.sh +COPY --from=webminerpool-build /server/Server/bin/Release_Server/server.exe /webminerpool +COPY --from=webminerpool-build /server/Server/bin/Release_Server/pools.json /webminerpool +COPY --from=webminerpool-build /hash_cn/libhash/libhash.so /webminerpool +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["./entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..dece977 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# Check if $DOMAIN is set +if [ -z $DOMAIN ]; then + echo -e "You need to set \$DOMAIN variable at run time\n" + echo -e "For example: docker run -d -p 80:80 -p 443:443 -e DOMAIN=example.com\n" + exit 1 +else + # Install acme.sh + apt-get -qq update + apt-get install -qq \ + cron \ + openssl \ + curl \ + coreutils \ + socat \ + git + git clone https://github.com/Neilpang/acme.sh.git /root/acme.sh && \ + cd /root/acme.sh && \ + git checkout 2.7.8 && \ + /root/acme.sh/acme.sh --install + + # Generate SSL cert + /root/.acme.sh/acme.sh --issue --standalone -d ${DOMAIN} -d www.${DOMAIN} + + # Generate pfx + openssl pkcs12 -export -out /webminerpool/certificate.pfx -inkey /root/.acme.sh/${DOMAIN}/${DOMAIN}.key -in /root/.acme.sh/${DOMAIN}/${DOMAIN}.cer -certfile /root/.acme.sh/${DOMAIN}/fullchain.cer -passin pass:miner -passout pass:miner + + # Start server + pushd /webminerpool + exec /usr/bin/mono server.exe + +fi