Add nginx config validation workflow

This commit is contained in:
Felipe Knorr Kuhn 2026-07-04 13:05:19 +09:00
parent 01207ceb7b
commit 59f9272446
No known key found for this signature in database
GPG key ID: 79619B52BB097C1A
3 changed files with 61 additions and 0 deletions

16
.github/nginx-check/Dockerfile.docker vendored Normal file
View file

@ -0,0 +1,16 @@
FROM nginx:1.30.1-alpine
# Validate the config set loaded by the mempool/frontend docker image.
# Build context: repo root
COPY nginx.conf http-basic.conf /etc/nginx/
COPY nginx-mempool.conf /etc/nginx/conf.d/
# Replay the transforms applied by docker/init.sh (with the default values
# docker/frontend/entrypoint.sh substitutes at container start)
RUN sed -i \
-e "s!127.0.0.1:80!0.0.0.0:8080!g" \
-e "s!user nobody;!!g" \
-e "s!/etc/nginx/nginx-mempool.conf!/etc/nginx/conf.d/nginx-mempool.conf!g" \
/etc/nginx/nginx.conf
CMD ["nginx", "-t"]

View file

@ -0,0 +1,13 @@
FROM nginx:1.30.1-alpine
# Stage the config the way production/install does: the repo is available at
# ${NGINX_ETC_FOLDER}/mempool and production/nginx/nginx.conf becomes the main
# config, with __NGINX_USER__ and __NGINX_ETC_FOLDER__ substituted.
# Build context: production/
COPY nginx /etc/nginx/mempool/production/nginx
RUN cp /etc/nginx/mempool/production/nginx/nginx.conf /etc/nginx/nginx.conf && \
sed -i "s!__NGINX_USER__!nginx!" /etc/nginx/nginx.conf && \
sed -i "s!__NGINX_ETC_FOLDER__!/etc/nginx!" /etc/nginx/nginx.conf
CMD ["nginx", "-t"]

32
.github/workflows/server-config.yml vendored Normal file
View file

@ -0,0 +1,32 @@
name: Validate server config
on:
pull_request:
types: [opened, synchronize]
paths:
- "nginx.conf"
- "http-basic.conf"
- "nginx-mempool.conf"
- "production/nginx/**"
- ".github/nginx-check/**"
- ".github/workflows/server-config.yml"
permissions:
contents: read
jobs:
check_config:
runs-on: "ubuntu-latest"
name: Validate nginx config
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- name: Validate the production nginx config
run: |
docker run --rm $(docker build -q -f .github/nginx-check/Dockerfile.production production)
- name: Validate the docker frontend nginx config
run: |
docker run --rm $(docker build -q -f .github/nginx-check/Dockerfile.docker .)