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

Commit 3100a62

Browse files
committed
feat: nginx & php image
1 parent 18b0ecc commit 3100a62

File tree

6 files changed

+150
-0
lines changed

6 files changed

+150
-0
lines changed

.github/workflows/docker-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
matrix:
2222
context:
2323
- all-in-one
24+
- nginx
25+
- php
2426

2527
steps:
2628
- name: Checkout repository

docker-compose.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: WordPress
2+
3+
networks:
4+
wordpress:
5+
driver: bridge
6+
7+
volumes:
8+
db_data: {}
9+
wordpress_data: {}
10+
11+
services:
12+
db:
13+
image: mariadb:lts
14+
volumes:
15+
- db_data:/var/lib/mysql
16+
restart: always
17+
environment:
18+
MYSQL_ROOT_PASSWORD: somewordpress
19+
MYSQL_DATABASE: wordpress
20+
MYSQL_USER: wordpress
21+
MYSQL_PASSWORD: wordpress
22+
networks:
23+
- wordpress
24+
25+
nginx:
26+
build:
27+
context: nginx
28+
depends_on:
29+
- php
30+
ports:
31+
- "8080:80"
32+
networks:
33+
- wordpress
34+
volumes:
35+
- wordpress_data:/var/www/html/wp-content
36+
37+
php:
38+
build:
39+
context: php
40+
depends_on:
41+
- db
42+
networks:
43+
- wordpress
44+
volumes:
45+
- wordpress_data:/var/www/html/wp-content

nginx/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ARG NGINX_VERSION=1.26.2
2+
FROM nginx:${NGINX_VERSION}-alpine
3+
4+
# Install nginx
5+
RUN mkdir -p /etc/nginx/snippets
6+
COPY fastcgi-php.conf /etc/nginx/snippets/fastcgi-php.conf
7+
COPY default.conf /etc/nginx/conf.d/default.conf
8+
9+
WORKDIR /var/www/html
10+
11+
# Download WordPress
12+
ARG WORDPRESS_VERSION=latest
13+
RUN curl -o /tmp/wordpress.tar.gz -fSL "https://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz"
14+
RUN tar -xzf /tmp/wordpress.tar.gz -C /var/www/html --strip-components=1
15+
RUN rm -f /tmp/wordpress.tar.gz
16+
RUN chmod -R 755 /var/www/html
17+
RUN chown -R nginx:nginx /var/www/html
18+
19+
EXPOSE 80
20+
21+
ENTRYPOINT ["nginx", "-g", "daemon off;"]

nginx/default.conf

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
upstream php {
2+
server php:9000;
3+
}
4+
5+
server {
6+
listen 80;
7+
server_name localhost;
8+
root /var/www/html;
9+
10+
index index.php index.html index.htm;
11+
12+
# Access log
13+
access_log /var/log/nginx/access.log;
14+
error_log /var/log/nginx/error.log;
15+
16+
location = /favicon.ico {
17+
log_not_found off;
18+
access_log off;
19+
}
20+
21+
location = /robots.txt {
22+
allow all;
23+
log_not_found off;
24+
access_log off;
25+
}
26+
27+
location / {
28+
# This is cool because no php is touched for static content.
29+
# include the "?$args" part so non-default permalinks doesn't break when using query string
30+
try_files $uri $uri/ /index.php?$args;
31+
}
32+
33+
location /healthcheck {
34+
return 200 'healthy';
35+
}
36+
37+
# PHP-FPM configuration
38+
location ~ \.php$ {
39+
include snippets/fastcgi-php.conf;
40+
fastcgi_pass php;
41+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
42+
include fastcgi_params;
43+
}
44+
45+
# Deny access to .htaccess files, if Apache's document root
46+
# concurs with nginx's one
47+
location ~ /\.ht {
48+
deny all;
49+
}
50+
}

nginx/fastcgi-php.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
2+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
3+
fastcgi_index index.php;
4+
include fastcgi_params;

php/Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
ARG PHP_VERSION=8.0
2+
FROM php:${PHP_VERSION}-fpm
3+
4+
# Install PHP extensions
5+
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
6+
ARG PHP_EXTENSIONS="gd opcache zip pdo_mysql mysqli redis xdebug imagick exif mbstring zip"
7+
RUN install-php-extensions ${PHP_EXTENSIONS}
8+
9+
RUN echo "opcache.enable=1" >> /usr/local/etc/php/conf.d/opcache.ini
10+
RUN echo "opcache.enable_cli=1" >> /usr/local/etc/php/conf.d/opcache.ini
11+
RUN echo "opcache.memory_consumption=256" >> /usr/local/etc/php/conf.d/opcache.ini
12+
RUN echo "memory_limit=2048M" >> /usr/local/etc/php/conf.d/performance.ini
13+
RUN echo "upload_max_filesize=100M" >> /usr/local/etc/php/conf.d/performance.ini
14+
RUN echo "post_max_size=100M" >> /usr/local/etc/php/conf.d/performance.ini
15+
16+
# Download WordPress
17+
ARG WORDPRESS_VERSION=latest
18+
RUN curl -o /tmp/wordpress.tar.gz -fSL "https://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz"
19+
RUN tar -xzf /tmp/wordpress.tar.gz -C /var/www/html --strip-components=1
20+
RUN rm -f /tmp/wordpress.tar.gz
21+
RUN chmod -R 755 /var/www/html
22+
RUN chown -R www-data:www-data /var/www/html
23+
24+
EXPOSE 9000
25+
26+
WORKDIR /var/www/html
27+
28+
ENTRYPOINT ["php-fpm", "-F"]

0 commit comments

Comments
 (0)