Compare commits

..

No commits in common. "master" and "51322fc6c495a2428883e8ecdb580bb5598e6687" have entirely different histories.

6 changed files with 15 additions and 103 deletions

View file

@ -1,3 +1,5 @@
.gitignore
example/
arch.txt
buildx.sh
readme.md

3
.gitignore vendored
View file

@ -1 +1,2 @@
arch.txt
buildx.sh

View file

@ -1,8 +1,8 @@
FROM nginx:alpine-perl
FROM alpine:latest
RUN apk add --upgrade --no-cache bash gettext inotify-tools
RUN mv /etc/nginx /etc/nginx.tmpl
RUN touch /etc/envsubst.conf
RUN apk add --upgrade --no-cache nginx gettext inotify-tools \
&& mv /etc/nginx /etc/nginx.tmpl \
&& touch /etc/envsubst.conf
COPY start-nginx.sh /usr/local/bin/

View file

@ -1,85 +0,0 @@
---
resources:
- name: source
type: git
source:
uri: https://gitea.redxef.at/redxef/nginx-envsubst
branch: master
fetch_tags: true
- name: upstream-image
type: registry-image
check_every: 6h
source:
repository: nginx
tag: alpine
- name: image
type: oci-image
source:
repository: redxef/nginx-envsubst
tag: latest
username: ((docker.username))
password: ((docker.password))
resource_types:
- name: oci-image
type: registry-image
source:
repository: redxef/concourse-oci-resource
tag: latest
jobs:
- name: build-push
plan:
- get: source
trigger: true
- get: upstream-image
trigger: true
- task: compute-docker-tags
config:
platform: linux
image_resource:
type: registry-image
source:
repository: alpine/git
inputs:
- name: source
path: .
outputs:
- name: docker-tags
run:
path: sh
args:
- -c
- |
#!/usr/bin/env sh
git rev-parse --short HEAD > docker-tags/tags.txt
git show-ref --tags | \
sed -n "/$(git rev-parse HEAD)/ s|$(git rev-parse HEAD).refs/tags/||gp" \
>> docker-tags/tags.txt
- task: build
privileged: true
config:
platform: linux
image_resource:
type: registry-image
source:
repository: redxef/concourse-buildkit
inputs:
- name: source
path: .
- name: docker-tags
outputs:
- name: build-output
params:
dest: build-output/image.tar
platform: aarch64,arm,i386,ppc64le,s390x,x86_64
run:
path: build
- put: image
inputs:
- build-output
- docker-tags
params:
image: build-output/image.tar
additional_tags: docker-tags/tags.txt

View file

@ -3,7 +3,7 @@
A simple docker image for configuring nginx with environment variables.
## Usage
Mount you whole nginx configuration into `/etc/nginx.tmpl/`.
Mount you whole nginx configuration into /etc/nginx.tmpl.
The configuration files can contain environment variables compatible
with `envsubst`, list these variables in a file `/etc/envsubst.conf`.
Additionally, the server gets reloaded when a update to one of the
@ -15,7 +15,7 @@ referenced certificates happens.
cd example
docker run --rm -it \
-e DOMAIN_NAME=localhost \
-p 80:80 -p 443:443 \
-p 80:80 -p 443:443
-v "$PWD/nginx.conf:/etc/nginx.tmpl/nginx.conf" \
-v "$PWD/envsubst.conf:/etc/envsubst.conf" \
-v "$PWD/cert:/cert" \
@ -24,4 +24,4 @@ docker run --rm -it \
## Source
[gitea.redxef.at/redxef/nginx-envsubst](https://gitea.redxef.at/redxef/nginx-envsubst)
(gitea.redxef.at/redxef/nginx-envsubst)[https://gitea.redxef.at/redxef/nginx-envsubst]

View file

@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
pids=""
@ -36,16 +36,10 @@ run_nginx() {
}
run_inotifywait() {
while :; do
wait_files="$(find "$dstdir" -type f -exec \
sed -En '/ssl_certificate/ s/^\s*ssl_certificate(_key)? (.*);.*$/\2/p' {} \; | sort -u)"
wait_directories="$(echo "$wait_files" | xargs -n 1 dirname | sort -u)"
echo "monitoring the following files:"
echo "$wait_files"
matched_files="$(echo "$wait_directories" | inotifywait --fromfile=- -e close_write -e modify -e create)"
if [[ -n "$(comm -12 <(sort -u <<< "$matched_files") <(echo "$wait_files"))" ]]; then
while find "$dstdir" -type f -exec \
sed -En '/ssl_certificate/ s/^\s*ssl_certificate(_key)? (.*);.*$/\2/p' {} \; | sort | uniq | \
inotifywait --fromfile=-; do
nginx -s reload
fi
done
}