Browse Source

multiple improvements to Dockerfile and entrypoint.sh

- $DOMAIN is no mandatory anymore
- acme.sh is installed inside container directly
- apply some docker best practices
pull/123/head
nierdz 2 years ago
parent
commit
d095176633
2 changed files with 26 additions and 25 deletions
  1. +15
    -2
      Dockerfile
  2. +11
    -23
      entrypoint.sh

+ 15
- 2
Dockerfile View File

@ -14,11 +14,24 @@ RUN sed -ri "s/^(.*DonationLevel = )[0-9]\.[0-9]{2}/\1${DONATION_LEVEL}/" /serve
cd /server && \
msbuild Server.sln /p:Configuration=Release_Server /p:Platform="any CPU"
VOLUME ["/root"]
FROM mono:5.16
RUN mkdir /webminerpool
# Install acme.sh
RUN apt-get -qq update && \
apt-get install -qq \
coreutils \
cron \
curl \
git \
openssl \
socat && \
rm -rf /var/lib/apt/lists/* && \
git clone https://github.com/Neilpang/acme.sh.git /root/acme.sh && \
cd /root/acme.sh && \
git checkout 2.7.9 && \
/root/acme.sh/acme.sh --install --home /root/.acme.sh
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

+ 11
- 23
entrypoint.sh View File

@ -1,33 +1,21 @@
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
# 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
echo -e "You did not set \$DOMAIN variable at run time. No certificate will be registered.\n"
echo -e "If you want to define it on command line here is an example:\n"
echo -e "docker run -d -p 80:80 -p 443:443 -e DOMAIN=example.com\n"
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
# Start server
pushd /webminerpool
exec /usr/bin/mono server.exe

Loading…
Cancel
Save