Init commit.
This commit is contained in:
commit
f0b8ac6301
3 changed files with 47 additions and 0 deletions
1
environment_variables.txt
Normal file
1
environment_variables.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
${DOMAIN_NAME}
|
12
nginx.Dockerfile
Normal file
12
nginx.Dockerfile
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# FROM nginx:alpine
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
RUN apk update && apk upgrade && apk add nginx gettext && \
|
||||||
|
rm -r /etc/nginx
|
||||||
|
|
||||||
|
COPY start-nginx.sh /usr/local/bin/
|
||||||
|
COPY environemnt_variables.txt /
|
||||||
|
|
||||||
|
USER root
|
||||||
|
ENTRYPOINT ["/bin/sh", "-c"]
|
||||||
|
CMD ["start-nginx.sh"]
|
34
start-nginx.sh
Executable file
34
start-nginx.sh
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
enable_server() {
|
||||||
|
for name in "$@"; do
|
||||||
|
src_dir="/etc/nginx/sites-available"
|
||||||
|
dst_dir="/etc/nginx/sites-enabled"
|
||||||
|
mkdir -p "$dst_dir"
|
||||||
|
envsubst '${DOMAIN_NAME}' < "$src_dir/$name.conf" > "$dst_dir/$name.conf"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
enable_ssh_server() {
|
||||||
|
for name in "$@"; do
|
||||||
|
src_dir="/etc/nginx/ssh-available"
|
||||||
|
dst_dir="/etc/nginx/ssh-enabled"
|
||||||
|
mkdir -p "$dst_dir"
|
||||||
|
envsubst '${DOMAIN_NAME}' < "$src_dir/$name.conf" > "$dst_dir/$name.conf"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
sub_env_vars="$(cat /environment_variables.txt)"
|
||||||
|
|
||||||
|
echo "Enabling servers"
|
||||||
|
(
|
||||||
|
pushd "/etc/nginx/sites-available" || exit $?
|
||||||
|
for f in *.conf; do
|
||||||
|
envsubst "$sub_env_vars" < "$f" > "../sites-enabled/$f"
|
||||||
|
done
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "Starting nginx"
|
||||||
|
exec nginx -g 'daemon off;' -c /etc/nginx/nginx.conf
|
Loading…
Reference in a new issue