Skip to content

Commit

Permalink
feat: add wordpress nginx (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
joerivanveen authored May 30, 2024
1 parent 426738a commit 81ceaa2
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build-wordpress-nginx.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions images/wordpress-nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM nginx:1-alpine

# Copy nginx config
COPY ./etc/nginx/templates/* /etc/nginx/templates/
45 changes: 45 additions & 0 deletions images/wordpress-nginx/etc/nginx/templates/default.conf.template
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 81ceaa2

Please sign in to comment.