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 .gitignore
example/ example/
arch.txt
buildx.sh
readme.md 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 apk add --upgrade --no-cache nginx gettext inotify-tools \
RUN mv /etc/nginx /etc/nginx.tmpl && mv /etc/nginx /etc/nginx.tmpl \
RUN touch /etc/envsubst.conf && touch /etc/envsubst.conf
COPY start-nginx.sh /usr/local/bin/ 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. A simple docker image for configuring nginx with environment variables.
## Usage ## 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 The configuration files can contain environment variables compatible
with `envsubst`, list these variables in a file `/etc/envsubst.conf`. with `envsubst`, list these variables in a file `/etc/envsubst.conf`.
Additionally, the server gets reloaded when a update to one of the Additionally, the server gets reloaded when a update to one of the
@ -15,7 +15,7 @@ referenced certificates happens.
cd example cd example
docker run --rm -it \ docker run --rm -it \
-e DOMAIN_NAME=localhost \ -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/nginx.conf:/etc/nginx.tmpl/nginx.conf" \
-v "$PWD/envsubst.conf:/etc/envsubst.conf" \ -v "$PWD/envsubst.conf:/etc/envsubst.conf" \
-v "$PWD/cert:/cert" \ -v "$PWD/cert:/cert" \
@ -24,4 +24,4 @@ docker run --rm -it \
## Source ## 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="" pids=""
@ -36,16 +36,10 @@ run_nginx() {
} }
run_inotifywait() { run_inotifywait() {
while :; do while find "$dstdir" -type f -exec \
wait_files="$(find "$dstdir" -type f -exec \ sed -En '/ssl_certificate/ s/^\s*ssl_certificate(_key)? (.*);.*$/\2/p' {} \; | sort | uniq | \
sed -En '/ssl_certificate/ s/^\s*ssl_certificate(_key)? (.*);.*$/\2/p' {} \; | sort -u)" inotifywait --fromfile=-; do
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
} }