diff --git a/.github/workflows/build-wordpress-nginx.yml b/.github/workflows/build-wordpress-nginx.yml new file mode 100644 index 0000000..250e0fb --- /dev/null +++ b/.github/workflows/build-wordpress-nginx.yml @@ -0,0 +1,37 @@ +name: 'Build wordpress images' + +on: + push: + branches: + - main + + paths: + - images/nginx/**/* + + workflow_dispatch: + +permissions: + contents: read + packages: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + +jobs: + build: + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v3 + + - uses: ./.github/actions/login-ghcr + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - uses: ./.github/actions/build-push + with: + registry: ghcr.io + cache-mode: 'min' + context: images/wordpress-nginx + image: myparcelnl/wordpress-nginx diff --git a/images/wordpress-nginx/Dockerfile b/images/wordpress-nginx/Dockerfile new file mode 100644 index 0000000..24eef79 --- /dev/null +++ b/images/wordpress-nginx/Dockerfile @@ -0,0 +1,4 @@ +FROM nginx:1-alpine + +# Copy nginx config +COPY ./etc/nginx/templates/* /etc/nginx/templates/ diff --git a/images/wordpress-nginx/etc/nginx/templates/default.conf.template b/images/wordpress-nginx/etc/nginx/templates/default.conf.template new file mode 100644 index 0000000..8c63603 --- /dev/null +++ b/images/wordpress-nginx/etc/nginx/templates/default.conf.template @@ -0,0 +1,45 @@ +server { + set $site_url "${BASE_URL}"; + set $root_dir "${ROOT_DIR}"; + + server_name $site_url; + root $root_dir; + + index index.php; + + location = /favicon.ico { + log_not_found off; + access_log off; + } + + location = /robots.txt { + allow all; + log_not_found off; + access_log off; + } + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + fastcgi_pass ${PHP_FPM_HOST}:${PHP_FPM_PORT}; + include fastcgi_params; + fastcgi_intercept_errors on; + #The following parameter can be also included in fastcgi_params file + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } + + location ~ \.(js|mjs|cjs)$ { + default_type application/x-javascript; + } + + location /wp-json/ { + try_files $uri $uri/ /index.php$is_args$args; + } + + location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { + expires max; + log_not_found off; + } +}