diff --git a/.github/nginx-check/Dockerfile.docker b/.github/nginx-check/Dockerfile.docker new file mode 100644 index 000000000..68776f088 --- /dev/null +++ b/.github/nginx-check/Dockerfile.docker @@ -0,0 +1,17 @@ +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!127.0.0.1!0.0.0.0!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"] diff --git a/.github/nginx-check/Dockerfile.production b/.github/nginx-check/Dockerfile.production new file mode 100644 index 000000000..cb91c2fc6 --- /dev/null +++ b/.github/nginx-check/Dockerfile.production @@ -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"] diff --git a/.github/workflows/server-config.yml b/.github/workflows/server-config.yml new file mode 100644 index 000000000..d1a89173c --- /dev/null +++ b/.github/workflows/server-config.yml @@ -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 .)