Compare commits
23 commits
51322fc6c4
...
master
Author | SHA1 | Date | |
---|---|---|---|
81f17b5027 | |||
e8e2761cff | |||
a1f8d62549 | |||
50393ac177 | |||
7333c7bcf5 | |||
197cd684c0 | |||
553dfaced3 | |||
6c798da8ae | |||
31aad6ef5f | |||
5f9aa6d38c | |||
5b011a361b | |||
035c4929df | |||
a3dc2a0b02 | |||
59fd6632aa | |||
5fc0c79bbd | |||
7864738448 | |||
5e942b159a | |||
60f1f7cec1 | |||
588832db7c | |||
e81344cac9 | |||
30f0005a2b | |||
57efdef852 | |||
4e60d62373 |
6 changed files with 103 additions and 15 deletions
|
@ -1,5 +1,3 @@
|
|||
.gitignore
|
||||
example/
|
||||
arch.txt
|
||||
buildx.sh
|
||||
readme.md
|
||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1 @@
|
|||
arch.txt
|
||||
buildx.sh
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
FROM alpine:latest
|
||||
FROM nginx:alpine-perl
|
||||
|
||||
RUN apk add --upgrade --no-cache nginx gettext inotify-tools \
|
||||
&& mv /etc/nginx /etc/nginx.tmpl \
|
||||
&& touch /etc/envsubst.conf
|
||||
RUN apk add --upgrade --no-cache bash gettext inotify-tools
|
||||
RUN mv /etc/nginx /etc/nginx.tmpl
|
||||
RUN touch /etc/envsubst.conf
|
||||
|
||||
COPY start-nginx.sh /usr/local/bin/
|
||||
|
||||
|
|
85
ci/pipeline.yml
Normal file
85
ci/pipeline.yml
Normal file
|
@ -0,0 +1,85 @@
|
|||
---
|
||||
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
|
||||
|
|
@ -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)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/usr/bin/env bash
|
||||
|
||||
pids=""
|
||||
|
||||
|
@ -36,10 +36,16 @@ run_nginx() {
|
|||
}
|
||||
|
||||
run_inotifywait() {
|
||||
while find "$dstdir" -type f -exec \
|
||||
sed -En '/ssl_certificate/ s/^\s*ssl_certificate(_key)? (.*);.*$/\2/p' {} \; | sort | uniq | \
|
||||
inotifywait --fromfile=-; do
|
||||
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
|
||||
nginx -s reload
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue