From 26a8a7a273cb3b236760cd779ab1c9493ad7e425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Tue, 5 Dec 2023 17:49:25 +0100 Subject: [PATCH] initial commit --- .env | 24 ++++ .gitignore | 3 + Dockerfile | 29 +++++ README.md | 14 +++ docker-compose.yml | 107 ++++++++++++++++++ .../usr/local/etc/php/conf.d/xdebug.ini | 11 ++ nginx.conf | 88 ++++++++++++++ 7 files changed, 276 insertions(+) create mode 100644 .env create mode 100644 .gitignore create mode 100755 Dockerfile create mode 100644 README.md create mode 100755 docker-compose.yml create mode 100755 files-to-copy/usr/local/etc/php/conf.d/xdebug.ini create mode 100755 nginx.conf diff --git a/.env b/.env new file mode 100644 index 0000000..66c2164 --- /dev/null +++ b/.env @@ -0,0 +1,24 @@ +# Database settings +POSTGRES_USER=mobilizon +POSTGRES_PASSWORD=mobilizon +POSTGRES_DB=mobilizon + +# Instance configuration +MOBILIZON_INSTANCE_REGISTRATIONS_OPEN=false +MOBILIZON_INSTANCE_NAME=Local Mobilizon +MOBILIZON_INSTANCE_HOST=mz.lan +MOBILIZON_INSTANCE_PORT=4000 + +MOBILIZON_INSTANCE_SECRET_KEY_BASE=W9jnkrXAe/o50ujqRJ+EnsWLFOZ5ED3sQaB5U9qRhfzJdwC05JhNaOsjaswKE2N29co= +MOBILIZON_INSTANCE_SECRET_KEY=x3hhpP7XdlWpC/YjX3e/C0cu3sIfYVVLq0BS46HGxit9CD1juHMHMxbx/BfTcW6/Sro= + +MOBILIZON_INSTANCE_EMAIL=noreply@mz.lan +MOBILIZON_REPLY_EMAIL=contact@mz.lan + +# Email settings +MOBILIZON_SMTP_SERVER=localhost +MOBILIZON_SMTP_PORT=25 +MOBILIZON_SMTP_HOSTNAME=localhost +MOBILIZON_SMTP_USERNAME=noreply@mz.lan +MOBILIZON_SMTP_PASSWORD=password +MOBILIZON_SMTP_SSL=false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..06ebab7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +certs +public +wordpress diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..fa35b63 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM wordpress + +# Install packages under Debian +RUN apt-get update && \ + apt-get -y install git + +# Install XDebug from source as described here: +# https://xdebug.org/docs/install +# Available branches of XDebug could be seen here: +# https://github.com/xdebug/xdebug/branches +RUN cd /tmp && \ + git clone https://github.com/xdebug/xdebug.git && \ + cd xdebug && \ + git checkout xdebug_3_2 && \ + phpize && \ + ./configure --enable-xdebug && \ + make && \ + make install && \ + rm -rf /tmp/xdebug + +# Copy xdebug.ini to /usr/local/etc/php/conf.d/ +COPY files-to-copy/ / + +# Since this Dockerfile extends the official Docker image `wordpress`, +# and since `wordpress`, in turn, extends the official Docker image `php`, +# the helper script docker-php-ext-enable (defined for image `php`) +# works here, and we can use it to enable xdebug: +RUN docker-php-ext-enable xdebug + diff --git a/README.md b/README.md new file mode 100644 index 0000000..4bcda7a --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ + +1. Install `mkcert` to handle locally trusted SSL certificates. + + +2. Generate a local certificate which is used for both WordPress and Mobilizon. +```bash +mkcert -install -cert-file certs/lan.pem -key-file certs/lan-key.pem wp.lan mz.lan +``` +3. Add the two dummy domains to your /etc/hosts file: +``` +127.0.0.1 wp.lan +127.0.0.1 mz.lan + +``` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100755 index 0000000..6b6800c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,107 @@ +version: "3.9" + +services: + nginx: + image: nginx:latest + hostname: wp.lan + ports: + - "80:80" + - "443:443" + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + - ./certs/:/etc/nginx/certs/:ro + restart: always + depends_on: + - wordpress + - mobilizon + + mobilizon: + image: framasoft/mobilizon:3.2.0 + env_file: + - .env + environment: + - MOBILIZON_INSTANCE_NAME + - MOBILIZON_INSTANCE_HOST + - MOBILIZON_INSTANCE_PORT + - MOBILIZON_INSTANCE_EMAIL + - MOBILIZON_REPLY_EMAIL + - MOBILIZON_ADMIN_EMAIL + - MOBILIZON_INSTANCE_REGISTRATIONS_OPEN + - MOBILIZON_DATABASE_USERNAME=${POSTGRES_USER} + - MOBILIZON_DATABASE_PASSWORD=${POSTGRES_PASSWORD} + - MOBILIZON_DATABASE_DBNAME=${POSTGRES_DB} + - MOBILIZON_DATABASE_HOST=mobilizon_db + - MOBILIZON_INSTANCE_SECRET_KEY_BASE + - MOBILIZON_INSTANCE_SECRET_KEY + - MOBILIZON_SMTP_SERVER + - MOBILIZON_SMTP_HOSTNAME + - MOBILIZON_SMTP_PORT + - MOBILIZON_SMTP_SSL + - MOBILIZON_SMTP_USERNAME + - MOBILIZON_SMTP_PASSWORD + - MOBILIZON_SMTP_TLS + volumes: + - ./public/uploads:/var/lib/mobilizon/uploads + # - ${PWD}/config.exs:/etc/mobilizon/config.exs:ro + expose: + - "4000" + + wordpress: + build: + context: . + dockerfile: Dockerfile + volumes: + - ./wordpress:/var/www/html + - /etc/ssl/certs:/etc/ssl/certs:ro + - /etc/ca-certificates/:/etc/ca-certificates/:ro + environment: + - DOCKER_DEV_DOMAIN=wp.lan + - WORDPRESS_DB_NAME=wordpress + - WORDPRESS_TABLE_PREFIX=wp_ + - WORDPRESS_DB_HOST=mariadb + - WORDPRESS_DB_USER=root + - WORDPRESS_DB_PASSWORD=password + - WORDPRESS_DEBUG=True + depends_on: + - mariadb + - phpmyadmin + restart: always + expose: + - "80" + - "9003" + extra_hosts: + # Needed for XDebug + - "host.docker.internal:host-gateway" + + mariadb: + image: mariadb:latest + volumes: + - wordpress_database_data:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD=password + - MYSQL_USER=root + - MYSQL_PASSWORD=password + - MYSQL_DATABASE=wordpress + restart: always + + mobilizon_db: + image: postgis/postgis:15-3.4 + volumes: + - mobilizon_database_data:/var/lib/postgresql/data + environment: + - POSTGRES_USER + - POSTGRES_PASSWORD + - POSTGRES_DB + + phpmyadmin: + depends_on: + - mariadb + image: phpmyadmin/phpmyadmin:latest + restart: always + environment: + PMA_HOST: mariadb + MYSQL_ROOT_PASSWORD: password + +volumes: + wordpress_database_data: + mobilizon_database_data: diff --git a/files-to-copy/usr/local/etc/php/conf.d/xdebug.ini b/files-to-copy/usr/local/etc/php/conf.d/xdebug.ini new file mode 100755 index 0000000..47bb486 --- /dev/null +++ b/files-to-copy/usr/local/etc/php/conf.d/xdebug.ini @@ -0,0 +1,11 @@ +# Parameters description could be found here: https://xdebug.org/docs/remote +# Also, for PhpStorm, configuration tips could be found here: https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html +zend_extension=xdebug.so +xdebug.mode=debug +# the default port for XDebug 3 is 9003, not 9000 +xdebug.client_port=9003 +# The line below is commented. This is the IP of your host machine, where your IDE is installed. +# We set this IP via XDEBUG_CONFIG environment variable in docker-compose.yml instead. +xdebug.client_host=host.docker.internal +xdebug.start_with_request = yes + diff --git a/nginx.conf b/nginx.conf new file mode 100755 index 0000000..6b21760 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,88 @@ +worker_processes auto; +events { + worker_connections 1024; +} + +http { + server { + listen 80; + server_name wp.lan; + return 301 https:/$host$request_uri; + } + + server { + listen 443 ssl; + http2 on; + server_name wp.lan; + + ssl_certificate /etc/nginx/certs/lan.pem; + ssl_certificate_key /etc/nginx/certs/lan-key.pem; + + index index.php; + + location / { + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass "http://wordpress"; + } + } + + server { + server_name mz.lan; + + listen 80; + listen [::]:80; + + return 301 https://$server_name$request_uri; + } + + server { + server_name mz.lan; + + listen 443 ssl http2; + listen [::]:443 ssl http2; + ssl_session_timeout 5m; + + # Uncomment once you get the certificates + ssl_trusted_certificate /etc/nginx/certs/lan.pem; + ssl_certificate /etc/nginx/certs/lan.pem; + ssl_certificate_key /etc/nginx/certs/lan-key.pem; + + # Add TLSv1.3 if it's supported by your system + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers 'EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA'; + ssl_prefer_server_ciphers on; + ssl_ecdh_curve prime256v1; + ssl_stapling on; + ssl_stapling_verify on; + add_header Strict-Transport-Security "max-age=31536000"; + + gzip on; + gzip_disable "msie6"; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 6; + gzip_buffers 16 8k; + gzip_http_version 1.1; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript application/activity+json application/atom+xml; + + # the nginx default is 1m, not enough for large media uploads + client_max_body_size 16m; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + # Just use the proxy for everything + location / { + expires off; + add_header Cache-Control "public, max-age=0, s-maxage=0, must-revalidate" always; + proxy_pass "http://mobilizon:4000"; + } + } +}