Skip to content

Commit

Permalink
docker container stub
Browse files Browse the repository at this point in the history
  • Loading branch information
jasperf committed Dec 26, 2024
1 parent d4c630f commit e61f97b
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 0 deletions.
22 changes: 22 additions & 0 deletions container/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
DB_NAME=app
DB_USER=app
DB_PASSWORD=test
DB_HOST=db

# Optional variables
# DB_HOST=localhost
# DB_PREFIX=wp_

WP_ENV=development
WP_HOME=http://localhost:8080
WP_SITEURL=${WP_HOME}/wp

# Generate your keys here: https://roots.io/salts.html
AUTH_KEY='generateme'
SECURE_AUTH_KEY='generateme'
LOGGED_IN_KEY='generateme'
NONCE_KEY='generateme'
AUTH_SALT='generateme'
SECURE_AUTH_SALT='generateme'
LOGGED_IN_SALT='generateme'
NONCE_SALT='generateme'
2 changes: 2 additions & 0 deletions container/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
db/data/
tmp/
103 changes: 103 additions & 0 deletions container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
FROM php:8.3.13-fpm-bookworm

# Permissions fix (important)
# (see https://github.com/docker/docker/issues/2259)
RUN usermod -u 1000 www-data

# PHP extensions for WordPress
RUN \
# Recommended extensions
# curl
# already built in and enabled
# dom
# already built in and enabled
# exif
# build and install using built-in docker script
docker-php-ext-configure exif && \
docker-php-ext-install -j$(nproc) exif && \
# fileinfo
# already built in and enabled
# hash
# already built in and enabled
# json
# already built in and enabled
# mbstring
# already built in and enabled
# mysqli
# build and install using built-in docker script
docker-php-ext-configure mysqli && \
docker-php-ext-install -j$(nproc) mysqli && \
# sodium
# already built in and enabled
# openssl
# already built in and enabled
# pcre
# already built in and enabled
# imagick (+GhostScript for PDF support)
# install build dependencies
apt-get update && \
apt-get install -y \
libmagickwand-dev \
ghostscript \
--no-install-recommends && \
# build and install using workaround
# @see https://github.com/Imagick/imagick/issues/358#issuecomment-768586107
mkdir -p /usr/src/php/ext/imagick && \
curl -fsSL https://github.com/Imagick/imagick/archive/06116aa24b76edaf6b1693198f79e6c295eda8a9.tar.gz | tar xvz -C "/usr/src/php/ext/imagick" --strip 1 && \
docker-php-ext-install imagick && \
# xml
# already built in and enabled
# zip
# install build dependencies
apt-get update && \
apt-get install -y \
libzip-dev \
--no-install-recommends && \
# build and install using built-in docker script
docker-php-ext-install -j$(nproc) zip && \
docker-php-ext-enable zip && \
# fallback extensions
# filter
# already built in and enabled
# gd
# install build dependencies
apt-get update && \
apt-get install -y \
libjpeg-dev \
libpng-dev \
libzip-dev \
libfreetype6-dev \
--no-install-recommends && \
# build and install using built-in docker script
docker-php-ext-configure gd \
--with-freetype --with-jpeg && \
docker-php-ext-install -j$(nproc) gd && \
# iconv
# already built in and enabled
# mcrypt
# install build dependencies
apt-get update && \
apt-get install -y \
libmcrypt-dev \
--no-install-recommends && \
# build and install using PECL (version 1.0.4)
pecl install -o -f mcrypt-1.0.4 && \
docker-php-ext-enable mcrypt && \
# simplexml
# already built in and enabled
# xmlreader
# already built in and enabled
# zlib
# already built in and enabled
# Trellis additional/differing extensions
# opcache
# build and install using built-in docker script
docker-php-ext-configure opcache && \
docker-php-ext-install -j$(nproc) opcache && \
# Extra clean ups
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# For Bedrock
WORKDIR /srv/www/web

6 changes: 6 additions & 0 deletions container/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Docker Container Option

Setup to use on Raspberry Pi or Linux Environment with Docker available where Limactl is not needed

1. Copy the `.env` in this directory into the `site/` directory.
2. Enter the `container` directory and up the Docker Compose setup (`docker-compose up -d`).
33 changes: 33 additions & 0 deletions container/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3.7'

services:

php:
build:
context: ../container
dockerfile: Dockerfile
volumes:
- ../site:/srv/www
- /tmp:/tmp

nginx:
image: nginx:1.19.2
volumes:
- ../site:/srv/www
- ./nginx/config/app.conf:/etc/nginx/conf.d/default.conf
ports:
- "8080:80"

db:
image: mariadb:10.5
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: app
MYSQL_USER: app
MYSQL_PASSWORD: test
ports:
- "3307:3306"
volumes:
- ./db/data:/var/lib/mysql


31 changes: 31 additions & 0 deletions container/nginx/config/app.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
server {
listen 80 default_server;

root /srv/www/web;
index index.php index.html index.htm;

location ~ ^/assets/(img|js|css|fonts)/(.*)$ {
try_files $uri $uri/ /wp-content/themes/roots/assets/$1/$2;
}

location ~ ^/plugins/(.*)$ {
try_files $uri $uri/ /wp-content/plugins/$1;
}

location ~ \.php$ {
try_files $uri =404;

#fastcgi_pass unix:/srv/run/php5-fpm.sock;
fastcgi_pass php:9000;

fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
}

0 comments on commit e61f97b

Please sign in to comment.