Compare commits

..

23 commits

Author SHA1 Message Date
81f17b5027
Check upstream image every 6h. 2024-03-16 10:50:04 +01:00
e8e2761cff
Improve startup command inotifywait. 2024-01-26 00:27:04 +01:00
a1f8d62549
Also sort result of inotifywait. 2023-08-19 02:56:15 +02:00
50393ac177
Change inotifywait function to properly detect file changes. 2023-08-19 02:43:59 +02:00
7333c7bcf5
Remove echo to not break command. 2023-08-19 02:01:48 +02:00
197cd684c0
List monitored files. 2023-08-19 01:51:29 +02:00
553dfaced3
Only restart upon close_wrie or modify. 2023-02-24 01:39:16 +01:00
6c798da8ae
Add username/password to docker image resource. 2022-11-21 15:49:57 +01:00
31aad6ef5f
Fix resource type repository name. 2022-11-21 15:45:06 +01:00
5f9aa6d38c
Update pipeline. 2022-11-21 15:44:09 +01:00
5b011a361b
Fix pipeline upstream image resource. 2022-05-04 00:07:07 +02:00
035c4929df
Switch to nginx with perl. 2022-03-13 21:21:41 +01:00
a3dc2a0b02
Fix upstream image for pipeline trigger. 2022-03-09 17:46:06 +01:00
59fd6632aa
Use git tags when pulling. 2022-03-09 17:37:07 +01:00
5fc0c79bbd
Map git tags to docker tags. 2022-03-09 17:23:52 +01:00
7864738448
Add missing backslash in command example. 2022-03-09 17:11:38 +01:00
5e942b159a
Remove old pipeline. 2022-03-09 17:09:20 +01:00
60f1f7cec1
Change baseimg to nginx:alpine. 2022-03-09 17:06:31 +01:00
588832db7c
Fix alpine version. 2022-03-09 17:02:11 +01:00
e81344cac9
Test which command fails. 2022-03-09 16:54:57 +01:00
30f0005a2b
CI for multiarch. 2022-03-09 16:49:43 +01:00
57efdef852
Improve readme. 2022-03-09 03:04:45 +01:00
4e60d62373
Fix braces in link. 2022-03-07 18:04:44 +01:00
6 changed files with 103 additions and 15 deletions

View file

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

3
.gitignore vendored
View file

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

View file

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

85
ci/pipeline.yml Normal file
View 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

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 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
} }