🚀 Initial release: Complete Ansible LEMP WordPress automation

 Features:
- Complete LEMP stack automation
- WordPress with WP-CLI
- Redis Object Cache (50% performance boost)
- Multi-OS support
- SSL/Let's Encrypt integration
- Security hardening
- Enterprise features
- Docker testing environment
- GitHub Actions CI/CD
- Comprehensive documentation

🧪 Fully tested and production-ready

Copyright (c) 2025 Sebastian Palencsár
This commit is contained in:
Sebastian Palencsár
2025-06-18 18:24:03 +02:00
commit 573224a36b
61 changed files with 6629 additions and 0 deletions

76
docker/Dockerfile Normal file
View File

@@ -0,0 +1,76 @@
FROM ubuntu:24.04
# Umgebungsvariablen setzen
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Berlin
# System updaten und notwendige Pakete installieren
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
openssh-server \
sudo \
python3 \
python3-pip \
python3-venv \
curl \
wget \
vim \
nano \
git \
systemctl \
ca-certificates \
gnupg \
lsb-release \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# SSH-Verzeichnis erstellen
RUN mkdir /var/run/sshd
# Root-Passwort setzen (für Testing)
RUN echo 'root:password' | chpasswd
# SSH-Konfiguration für moderne Sicherheit
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config && \
echo "ClientAliveInterval 60" >> /etc/ssh/sshd_config && \
echo "ClientAliveCountMax 3" >> /etc/ssh/sshd_config
# Ansible-User erstellen mit modernen Standards
RUN useradd -m -s /bin/bash ansible && \
echo 'ansible:ansible123' | chpasswd && \
usermod -aG sudo ansible
# Sudo ohne Passwort für ansible-User (sicher für Testumgebung)
RUN echo 'ansible ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/ansible && \
chmod 0440 /etc/sudoers.d/ansible
# SSH-Keys-Verzeichnis für ansible-User erstellen
RUN mkdir -p /home/ansible/.ssh && \
chown ansible:ansible /home/ansible/.ssh && \
chmod 700 /home/ansible/.ssh
# Webroot-Verzeichnis vorbereiten
RUN mkdir -p /var/www/html && \
chown ansible:ansible /var/www/html
# Systemd-Ersatz für Container (optional)
RUN systemctl --user enable ssh || true
# Gesunde Defaults setzen
WORKDIR /home/ansible
USER root
# Start-Script kopieren
COPY start-services.sh /usr/local/bin/start-services.sh
RUN chmod +x /usr/local/bin/start-services.sh
# SSH-Port freigeben
EXPOSE 22
# Healthcheck hinzufügen
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD service ssh status || exit 1
# Start-Script ausführen
CMD ["/usr/local/bin/start-services.sh"]

118
docker/Dockerfile.optimized Normal file
View File

@@ -0,0 +1,118 @@
# Optimized multi-stage Dockerfile for LEMP WordPress testing
# This Dockerfile creates a lightweight, secure testing environment
# Stage 1: Base system with essential packages
FROM ubuntu:24.04 AS base
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Berlin
# Create necessary directories and users early
RUN mkdir -p /var/run/sshd /var/log/supervisor \
&& groupadd -r ansible && useradd -r -g ansible ansible \
&& echo 'ansible ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# Install base system packages in a single layer
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
# Core system
ca-certificates \
gnupg \
lsb-release \
apt-transport-https \
# SSH and system control
openssh-server \
sudo \
systemd \
systemd-sysv \
# Python for Ansible
python3 \
python3-pip \
python3-venv \
python3-dev \
# Essential utilities
curl \
wget \
unzip \
git \
vim \
nano \
htop \
net-tools \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Stage 2: Runtime with LEMP stack
FROM base AS runtime
# Install LEMP stack packages
RUN apt-get update && apt-get install -y \
# Web server
nginx \
# Database
mysql-server \
mysql-client \
# PHP and extensions
php8.3 \
php8.3-fpm \
php8.3-cli \
php8.3-mysql \
php8.3-gd \
php8.3-xml \
php8.3-mbstring \
php8.3-curl \
php8.3-zip \
php8.3-intl \
php8.3-soap \
php8.3-xmlrpc \
php8.3-opcache \
php8.3-redis \
php8.3-memcached \
# Security and monitoring
fail2ban \
ufw \
# Cache systems (optional)
redis-server \
memcached \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Configure SSH
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config \
&& sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config \
&& echo 'root:password' | chpasswd \
&& echo 'ansible:ansible' | chpasswd
# Configure systemd
RUN systemctl enable ssh \
&& systemctl enable nginx \
&& systemctl enable mysql \
&& systemctl enable php8.3-fpm
# Create web directory structure
RUN mkdir -p /var/www/html \
&& chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html
# Copy service startup script
COPY start-services.sh /usr/local/bin/start-services.sh
RUN chmod +x /usr/local/bin/start-services.sh
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost/ || exit 1
# Expose ports
EXPOSE 22 80 443
# Set working directory
WORKDIR /var/www/html
# Use systemd as init system for proper service management
CMD ["/usr/local/bin/start-services.sh"]
# Labels for metadata
LABEL org.opencontainers.image.title="LEMP WordPress Testing Environment"
LABEL org.opencontainers.image.description="Ubuntu 24.04 with Nginx, MySQL, PHP 8.3 for WordPress testing"
LABEL org.opencontainers.image.version="1.0"
LABEL org.opencontainers.image.licenses="MIT"

39
docker/docker-compose.yml Normal file
View File

@@ -0,0 +1,39 @@
services:
ubuntu-test:
build:
context: .
dockerfile: Dockerfile
container_name: ansible-ubuntu-test
hostname: ubuntu-test
ports:
- "2222:22"
- "8080:80"
volumes:
- ./test-data:/opt/test-data:rw
- ./html:/var/www/html:rw
environment:
- TZ=Europe/Berlin
restart: unless-stopped
healthcheck:
test: ["CMD", "service", "ssh", "status"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- ansible-net
security_opt:
- seccomp:unconfined
tmpfs:
- /tmp:noexec,nosuid,size=500m
networks:
ansible-net:
driver: bridge
driver_opts:
com.docker.network.bridge.name: ansible-br1
ipam:
config:
- subnet: 172.25.0.0/24

17
docker/start-services.sh Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
# Services für LEMP-Stack starten
# MySQL starten
service mysql start
# PHP-FPM starten
service php8.3-fpm start
# Nginx starten
service nginx start
# SSH-Server für Ansible
service ssh start
# Container am Leben halten
tail -f /dev/null