This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from nierdz/improve-docker
Improve docker
- Loading branch information
Showing
3 changed files
with
60 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,23 @@ | ||
#!/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 | ||
if [ -z "$DOMAIN" ]; then | ||
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 | ||
|
||
if [[ ! -f "/root/.acme.sh/${DOMAIN}/${DOMAIN}.cer" ]] || ! openssl x509 -checkend 0 -in "/root/.acme.sh/${DOMAIN}/${DOMAIN}.cer"; then | ||
# 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 | ||
fi | ||
fi | ||
|
||
# Start server | ||
pushd /webminerpool | ||
exec /usr/bin/mono server.exe |