Compare commits

...

14 commits

3 changed files with 40 additions and 15 deletions

View file

@ -1,6 +1,6 @@
FROM nginx:alpine FROM nginx:alpine-perl
RUN apk add --upgrade --no-cache gettext inotify-tools RUN apk add --upgrade --no-cache bash gettext inotify-tools
RUN mv /etc/nginx /etc/nginx.tmpl RUN mv /etc/nginx /etc/nginx.tmpl
RUN touch /etc/envsubst.conf RUN touch /etc/envsubst.conf

View file

@ -5,10 +5,27 @@ resources:
source: source:
uri: https://gitea.redxef.at/redxef/nginx-envsubst uri: https://gitea.redxef.at/redxef/nginx-envsubst
branch: master branch: master
fetch_tags: true
- name: upstream-image - name: upstream-image
type: registry-image type: registry-image
check_every: 6h
source: source:
repository: alpine 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: jobs:
- name: build-push - name: build-push
@ -51,16 +68,18 @@ jobs:
- name: source - name: source
path: . path: .
- name: docker-tags - name: docker-tags
outputs:
- name: build-output
params: params:
username: ((docker.username)) dest: build-output/image.tar
password: ((docker.password))
repository: docker.io/redxef/nginx-envsubst
tag: latest
additional_tags: docker-tags/tags.txt
push: true
platform: aarch64,arm,i386,ppc64le,s390x,x86_64 platform: aarch64,arm,i386,ppc64le,s390x,x86_64
context: .
manual: false
run: run:
path: build path: build
- put: image
inputs:
- build-output
- docker-tags
params:
image: build-output/image.tar
additional_tags: docker-tags/tags.txt

View file

@ -1,4 +1,4 @@
#!/usr/bin/env sh #!/usr/bin/env bash
pids="" pids=""
@ -36,10 +36,16 @@ run_nginx() {
} }
run_inotifywait() { run_inotifywait() {
while find "$dstdir" -type f -exec \ while :; do
sed -En '/ssl_certificate/ s/^\s*ssl_certificate(_key)? (.*);.*$/\2/p' {} \; | sort | uniq | \ wait_files="$(find "$dstdir" -type f -exec \
inotifywait --fromfile=-; do 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
nginx -s reload nginx -s reload
fi
done done
} }