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
Improve docker #92
Merged
Merged
Improve docker #92
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would anyone want a cert on |
||
# 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please externalize version to
ENV
on next update and, ideally, pull from release tarball as opposed to using Git. Here's how you can pull release tarball:latest
version meta from NPM: https://git.habd.as/comfusion/after-dark/src/commit/de243545c422d4190e441ffe8293bbbf5dfb4d4e/bin/install#L34-L38wget
from GitHub without installinggit
: https://git.habd.as/jhabdas/react-native-webpack-starter-kit/src/commit/6a19524e987052bb1bc171bdcaaa8664d43c946b/Dockerfile#L21-L26A nice to have also is a multi-stage build where binary is compiled in mono then dropped into a
busybox
container or similar for a microcontainer end-result. Ideally the final binary would be moved into a scratch container but cron is necessary to keep the cert up-to-date (though I doubt this will always be the case).This should make the whole thing take up very small amounts of resources and more suitable for deployment on ARMv7 and other ARM-based architectures following a compile using mono.