Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
feat: nginx & php image
Browse files Browse the repository at this point in the history
  • Loading branch information
AH-dark committed Sep 22, 2024
1 parent 18b0ecc commit 3100a62
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
matrix:
context:
- all-in-one
- nginx
- php

steps:
- name: Checkout repository
Expand Down
45 changes: 45 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: WordPress

networks:
wordpress:
driver: bridge

volumes:
db_data: {}
wordpress_data: {}

services:
db:
image: mariadb:lts
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
- wordpress

nginx:
build:
context: nginx
depends_on:
- php
ports:
- "8080:80"
networks:
- wordpress
volumes:
- wordpress_data:/var/www/html/wp-content

php:
build:
context: php
depends_on:
- db
networks:
- wordpress
volumes:
- wordpress_data:/var/www/html/wp-content
21 changes: 21 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARG NGINX_VERSION=1.26.2
FROM nginx:${NGINX_VERSION}-alpine

# Install nginx
RUN mkdir -p /etc/nginx/snippets
COPY fastcgi-php.conf /etc/nginx/snippets/fastcgi-php.conf
COPY default.conf /etc/nginx/conf.d/default.conf

WORKDIR /var/www/html

# Download WordPress
ARG WORDPRESS_VERSION=latest
RUN curl -o /tmp/wordpress.tar.gz -fSL "https://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz"
RUN tar -xzf /tmp/wordpress.tar.gz -C /var/www/html --strip-components=1
RUN rm -f /tmp/wordpress.tar.gz
RUN chmod -R 755 /var/www/html
RUN chown -R nginx:nginx /var/www/html

EXPOSE 80

ENTRYPOINT ["nginx", "-g", "daemon off;"]
50 changes: 50 additions & 0 deletions nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
upstream php {
server php:9000;
}

server {
listen 80;
server_name localhost;
root /var/www/html;

index index.php index.html index.htm;

# Access log
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}

location /healthcheck {
return 200 'healthy';
}

# PHP-FPM configuration
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

# Deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
4 changes: 4 additions & 0 deletions nginx/fastcgi-php.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
28 changes: 28 additions & 0 deletions php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ARG PHP_VERSION=8.0
FROM php:${PHP_VERSION}-fpm

# Install PHP extensions
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
ARG PHP_EXTENSIONS="gd opcache zip pdo_mysql mysqli redis xdebug imagick exif mbstring zip"
RUN install-php-extensions ${PHP_EXTENSIONS}

RUN echo "opcache.enable=1" >> /usr/local/etc/php/conf.d/opcache.ini
RUN echo "opcache.enable_cli=1" >> /usr/local/etc/php/conf.d/opcache.ini
RUN echo "opcache.memory_consumption=256" >> /usr/local/etc/php/conf.d/opcache.ini
RUN echo "memory_limit=2048M" >> /usr/local/etc/php/conf.d/performance.ini
RUN echo "upload_max_filesize=100M" >> /usr/local/etc/php/conf.d/performance.ini
RUN echo "post_max_size=100M" >> /usr/local/etc/php/conf.d/performance.ini

# Download WordPress
ARG WORDPRESS_VERSION=latest
RUN curl -o /tmp/wordpress.tar.gz -fSL "https://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz"
RUN tar -xzf /tmp/wordpress.tar.gz -C /var/www/html --strip-components=1
RUN rm -f /tmp/wordpress.tar.gz
RUN chmod -R 755 /var/www/html
RUN chown -R www-data:www-data /var/www/html

EXPOSE 9000

WORKDIR /var/www/html

ENTRYPOINT ["php-fpm", "-F"]

0 comments on commit 3100a62

Please sign in to comment.