This repository has been archived by the owner on May 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 576
Auto SSL creation and renewal #220
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
73718d6
added nginx config and letsencrypt config to run on supervisor
ade53ad
changed base image to stretch from alpine for nginx and installed cer…
76fa17b
added new env variables for SSL generation
64a6115
installed cron and updated supervisor config
4822081
updated the scripts to generate SSL from letsencrypt
1d9f595
updated Dockerfile and entrypoint.sh configurations
d607164
updated the Readme file on how to enable automatic generation of SSL
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,11 +1,23 @@ | ||
FROM nginx:mainline-alpine | ||
FROM nginx | ||
|
||
# install cron, supervisor and certbot | ||
RUN echo "deb http://ftp.debian.org/debian stretch-backports main" | tee -a /etc/apt/sources.list | ||
RUN apt-get update | ||
RUN apt-get install -qy cron supervisor python-certbot-nginx -t stretch-backports | ||
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. Is it possible to use a separate container instead of supervisor? 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. Do we need an extra container? |
||
|
||
# Remove default configuration and add our custom Nginx configuration files | ||
RUN rm /etc/nginx/conf.d/default.conf | ||
COPY ./mattermost /etc/nginx/sites-available/ | ||
COPY ./mattermost-ssl /etc/nginx/sites-available/ | ||
COPY ./security.conf /etc/nginx/conf.d/ | ||
|
||
# Add and setup entrypoint | ||
COPY entrypoint.sh / | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
# Add entrypoint script and letsencrypt script | ||
COPY entrypoint.sh letsencrypt.sh /usr/bin/ | ||
|
||
RUN chmod +x /usr/bin/entrypoint.sh /usr/bin/letsencrypt.sh | ||
|
||
# Supervisor config | ||
COPY entrypoint.conf /etc/supervisor/conf.d/ | ||
|
||
# Run Supervisor | ||
CMD ["supervisord", "-n"] |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[program:entrypoint] | ||
command=/usr/bin/entrypoint.sh | ||
autostart=true | ||
autorestart=unexpected | ||
exitcodes=0 | ||
stdout_logfile=/dev/stdout | ||
stderr_logfile=/dev/stderr |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
if [ ${LETSENCRYPT_SSL_GENERATION} ]; then | ||
echo "Running certificate generation from Letsencrypt." | ||
certbot -m ${EMAIL} -d ${DOMAIN_NAME} --agree-tos -n --nginx | ||
|
||
# try to run renew certificate every day | ||
echo "@midnight * * * * certbot renew" | crontab | ||
|
||
#run cron | ||
cron | ||
else | ||
echo "Not running certificate generation from Letsencrypt." | ||
fi |
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
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.
Any chance make it work with Alpine image?
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.
I can try to make work on alpine. Let me take a look on that.