-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nginx): add auto-reloading (#64)
- Loading branch information
1 parent
1f00d6b
commit 8637597
Showing
6 changed files
with
49 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,18 +2,24 @@ FROM nginx:1.18-alpine | |
|
||
MAINTAINER Damien Retzinger <[email protected]> | ||
|
||
RUN apk update && apk add openssl | ||
RUN apk update && apk add --no-cache inotify-tools openssl | ||
RUN mkdir /etc/nginx/certs \ | ||
&& echo -e "\n\n\n\n\n\n\n" | openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/certs/nginx.key -out /etc/nginx/certs/nginx.crt | ||
|
||
COPY ./conf/nginx.conf /etc/nginx/ | ||
COPY ./conf/default.conf.template /etc/nginx/templates/ | ||
|
||
COPY scripts/entrypoint.sh /docker-entrypoint.d/ | ||
COPY scripts/nginxReloader.sh /root/scripts/ | ||
|
||
RUN chmod +x /docker-entrypoint.d/entrypoint.sh | ||
RUN chmod +x /root/scripts/nginxReloader.sh | ||
|
||
ENV MAGENTO2_UPSTREAM=localhost | ||
ENV MAGENTO2_UPSTREAM_PORT=9000 | ||
ENV NGINX_PORT=8000 | ||
ENV NGINX_TLS_PORT=8443 | ||
|
||
EXPOSE 8443 | ||
|
||
WORKDIR /var/www/html | ||
WORKDIR /var/www/html |
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,4 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
sh -c "/root/scripts/nginxReloader.sh &" |
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 | ||
|
||
while true | ||
do | ||
inotifywait --include="(nginx\.conf\.sample|nginx\.conf)" -e create -e modify -e delete -e move /var/www/html/ | ||
nginx -t | ||
if [ $? -eq 0 ] | ||
then | ||
echo "Detected Nginx Configuration Change" | ||
echo "Executing: nginx -s reload" | ||
nginx -s reload | ||
fi | ||
done |
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 |
---|---|---|
|
@@ -2,13 +2,19 @@ FROM nginx:1.19-alpine | |
|
||
MAINTAINER Damien Retzinger <[email protected]> | ||
|
||
RUN apk update && apk add openssl | ||
RUN apk update && apk add --no-cache inotify-tools openssl | ||
RUN mkdir /etc/nginx/certs \ | ||
&& echo -e "\n\n\n\n\n\n\n" | openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/certs/nginx.key -out /etc/nginx/certs/nginx.crt | ||
|
||
COPY ./conf/nginx.conf /etc/nginx/ | ||
COPY ./conf/default.conf.template /etc/nginx/templates/ | ||
|
||
COPY scripts/entrypoint.sh /docker-entrypoint.d/ | ||
COPY scripts/nginxReloader.sh /root/scripts/ | ||
|
||
RUN chmod +x /docker-entrypoint.d/entrypoint.sh | ||
RUN chmod +x /root/scripts/nginxReloader.sh | ||
|
||
ENV MAGENTO2_UPSTREAM=localhost | ||
ENV MAGENTO2_UPSTREAM_PORT=9000 | ||
ENV NGINX_PORT=8000 | ||
|
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,4 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
sh -c "/root/scripts/nginxReloader.sh &" |
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 | ||
|
||
while true | ||
do | ||
inotifywait --include="(nginx\.conf\.sample|nginx\.conf)" -e create -e modify -e delete -e move /var/www/html/ | ||
nginx -t | ||
if [ $? -eq 0 ] | ||
then | ||
echo "Detected Nginx Configuration Change" | ||
echo "Executing: nginx -s reload" | ||
nginx -s reload | ||
fi | ||
done |