Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# set default line endings to auto
* text=auto
# files that end with .sh should have lf line endings
*.sh text eol=lf
# files that end with .conf should have lf line endings
*.conf text eol=lf

# dockerfile should have lf line endings
Dockerfile text eol=lf
22 changes: 4 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
#FROM wordpress:fpm
FROM wordpress:fpm-alpine
FROM wordpress:6.5.2-php8.1-fpm-alpine

# Pm ondemand to save RAM
RUN sed -i 's/pm = dynamic/pm = ondemand/g' /usr/local/etc/php-fpm.d/www.conf
COPY . /tmp
ENV WORDPRESS_PREPARE_DIR /usr/src/wordpress
RUN chmod 777 /tmp/install.sh && /bin/bash /tmp/install.sh

#RUN apt-get update && apt-get -y install curl unzip
RUN apk add --update curl unzip && rm -Rf /var/cache/apk/*

# Sqlite integration plugin
RUN curl -o /tmp/wpplugin.zip https://downloads.wordpress.org/plugin/sqlite-integration.1.8.1.zip
RUN unzip /tmp/wpplugin.zip -d /usr/src/wordpress/wp-content/plugins/
RUN rm /tmp/wpplugin.zip
# Setup
RUN cp /usr/src/wordpress/wp-content/plugins/sqlite-integration/db.php /usr/src/wordpress/wp-content

COPY config/wp-config.php /var/www/wp-config.php
RUN chown www-data:www-data /var/www/wp-config.php

VOLUME ["/var/www/db"]
55 changes: 55 additions & 0 deletions config/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
server {
listen 80;
listen [::]:80;
server_name $host;
index index.php index.html index.htm;
root /var/www/html;
server_tokens off;
client_max_body_size 75M;

# logging
access_log /var/log/nginx/wordpress.access.log;
error_log /var/log/nginx/wordpress.error.log;

# some security headers ( optional )
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always;

location / {
try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php$ {
try_files $uri = 404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}

location ~ /\.ht {
deny all;
}

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

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

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

location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
}
75 changes: 0 additions & 75 deletions config/wp-config.php

This file was deleted.

37 changes: 37 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
# exit on error
set -e

# insert line "exec nginx" before a line containing 'exec "$@"' in /usr/local/bin/docker-entrypoint.sh using sed
sed -i '/exec "$@"/i nginx' /usr/local/bin/docker-entrypoint.sh

echo "installing curl and nginx"
apk add --update curl
apk add nginx

echo "clear cache"
rm -Rf /var/cache/apk/*


echo "download Sqlite integration plugin"
curl -L -o /tmp/sqlite-database-integration.tar.gz "https://github.com/WordPress/sqlite-database-integration/archive/refs/tags/v2.1.9.tar.gz"

echo "untar Sqlite integration plugin"
tar zxvf /tmp/sqlite-database-integration.tar.gz -C /tmp/

#install
mkdir -p /usr/src/wordpress/wp-content/mu-plugins/sqlite-database-integration
cp -r /tmp/sqlite-database-integration-2.1.9/* /usr/src/wordpress/wp-content/mu-plugins/sqlite-database-integration/
mv "/usr/src/wordpress/wp-content/mu-plugins/sqlite-database-integration/db.copy" "/usr/src/wordpress/wp-content/db.php"
sed -i 's#{SQLITE_IMPLEMENTATION_FOLDER_PATH}#/var/www/html/wp-content/mu-plugins/sqlite-database-integration#' "/usr/src/wordpress/wp-content/db.php"
sed -i 's#{SQLITE_PLUGIN}#sqlite-database-integration/load.php#' "/usr/src/wordpress/wp-content/db.php"
mkdir "/usr/src/wordpress/wp-content/database"
touch "/usr/src/wordpress/wp-content/database/.ht.sqlite"
chmod 640 "/usr/src/wordpress/wp-content/database/.ht.sqlite"

echo "removing tar file"
rm /tmp/sqlite-database-integration.tar.gz

echo "setting up nginx"
cp /tmp/config/default.conf /etc/nginx/http.d/default.conf