first commit
Some checks failed
Deploy LAMP / Deploy LAMP (push) Failing after 32s

This commit is contained in:
Antoni Nuñez Romeu
2026-04-13 17:13:52 +02:00
commit ddda631033
9 changed files with 249 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
name: Deploy LAMP
run-name: ${{ gitea.actor }} is deploying to PROD servers.
on: [ push, fork, pull ]
jobs:
Deploy LAMP:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: SSH to remote server
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
cd /docker/lamp/
git pull
docker compose up -d --build
- run: echo "🍏 This job's status is ${{ job.status }}."

91
README.md Normal file
View File

@@ -0,0 +1,91 @@
# Lightweight LAMP Stack with Docker
This repository contains a lightweight LAMP (Linux, Apache, MySQL, PHP) stack using Docker containers.
## Features
- **Apache 2.4** (Alpine-based) - Web server with support for virtual hosts
- **PHP 8.4** (FPM Alpine-based) - Latest PHP version
- **MySQL 8.0** - Relational database
- **Adminer** - Lightweight database management tool (alternative to phpMyAdmin)
- **Virtual Host Support** - Easy to add new virtual hosts
- **Optimized Images** - Using Alpine Linux for minimal footprint
## Directory Structure
```
Docker-Lamp/
├── apache/ # Apache configuration and Dockerfile
├── php/ # PHP configuration and Dockerfile
├── mysql/ # MySQL configuration and Dockerfile
├── adminer/ # Adminer configuration and Dockerfile
├── html/ # Web root directory (mounted to containers)
├── docker-compose.yml # Docker Compose configuration
└── README.md # This file
```
## Quick Start
1. Clone this repository
2. Navigate to the project directory
3. Start the stack:
```bash
docker-compose up -d
```
4. Access the services:
- Web server: http://localhost:32000
- Adminer (MySQL GUI): http://localhost:32001
- PHP Info page: http://localhost:32000/index.php
## Configuration
### Apache Virtual Hosts
To add a new virtual host:
1. Create a new `.conf` file in `apache/vhosts/`
2. Configure your virtual host settings
3. Restart Apache: `docker-compose restart apache`
Example virtual host configuration is provided in `apache/vhosts/example.conf`
### Environment Variables
MySQL credentials are configured in `docker-compose.yml`:
- Database: `lamp_db`
- Username: `lamp_user`
- Password: `lamp_password`
- Root Password: `root_password`
Adminer uses these same credentials by default.
## Customization
### Changing PHP Version
Modify the PHP Dockerfile to use a different PHP version tag.
### Adding PHP Extensions
Edit the PHP Dockerfile to install additional extensions using `docker-php-ext-install`.
### Persistent Data
MySQL data is persisted in a Docker volume named `mysql-data`.
## Stopping the Stack
```bash
docker-compose down
```
To remove volumes as well:
```bash
docker-compose down -v
```
## Notes
- All images are based on Alpine Linux for minimal size
- Apache is configured to allow `.htaccess` overrides
- PHP-FPM communicates with Apache via the shared volume
- Adminer provides a clean, lightweight interface for database management

10
adminer/Dockerfile Normal file
View File

@@ -0,0 +1,10 @@
FROM adminer:latest
# Set environment variables for Adminer
ENV ADMINER_DEFAULT_SERVER=mysql \
ADMINER_DEFAULT_USERNAME=lamp_user \
ADMINER_DEFAULT_PASSWORD=lamp_password \
ADMINER_DEFAULT_DB=lamp_db
# Expose port 8080 for Adminer
EXPOSE 8080

21
apache/Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
FROM httpd:2.4-alpine
# Copy custom httpd.conf if needed (optional)
# COPY httpd.conf /usr/local/apache2/conf/httpd.conf
# Enable Apache modules (rewrite, etc.) if needed
RUN sed -i 's/^#\(LoadModule rewrite_module\)/\1/' /usr/local/apache2/conf/httpd.conf && \
sed -i 's/^#\(LoadModule deflate_module\)/\1/' /usr/local/apache2/conf/httpd.conf
# Set document root
ENV APACHE_DOCUMENT_ROOT=/var/www/html
RUN sed -ri -e 's!/usr/local/apache2/htdocs!${APACHE_DOCUMENT_ROOT}!g' /usr/local/apache2/conf/httpd.conf
# Expose port 80
EXPOSE 80
# Copy virtual host configuration (will be mounted via docker-compose)
# COPY vhosts/ /etc/apache2/sites-enabled/
# Start Apache in foreground
CMD ["httpd-foreground"]

View File

@@ -0,0 +1,12 @@
<VirtualHost *:80>
ServerName example.local
DocumentRoot /var/www/html/example
<Directory /var/www/html/example>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/example_error.log
CustomLog ${APACHE_LOG_DIR}/example_access.log combined
</VirtualHost>

49
docker-compose.yml Normal file
View File

@@ -0,0 +1,49 @@
version: '3.8'
services:
apache:
build: ./apache
ports:
- "32000:80"
volumes:
- ./html:/var/www/html
- ./apache/vhosts:/etc/apache2/sites-enabled
depends_on:
- php
networks:
- lamp-network
php:
build: ./php
volumes:
- ./html:/var/www/html
networks:
- lamp-network
mysql:
build: ./mysql
environment:
MYSQL_DATABASE: lamp_db
MYSQL_USER: lamp_user
MYSQL_PASSWORD: lamp_password
MYSQL_ROOT_PASSWORD: root_password
volumes:
- mysql-data:/var/lib/mysql
networks:
- lamp-network
adminer:
build: ./adminer
ports:
- "32001:8080"
depends_on:
- mysql
networks:
- lamp-network
volumes:
mysql-data:
networks:
lamp-network:
driver: bridge

3
html/index.php Normal file
View File

@@ -0,0 +1,3 @@
<?php
phpinfo();
?>

13
mysql/Dockerfile Normal file
View File

@@ -0,0 +1,13 @@
FROM mysql:8.0
# Set environment variables for MySQL
ENV MYSQL_DATABASE=lamp_db \
MYSQL_USER=lamp_user \
MYSQL_PASSWORD=lamp_password \
MYSQL_ROOT_PASSWORD=root_password
# Copy initialization scripts (if any)
# COPY init.sql /docker-entrypoint-initdb.d/
# Expose MySQL port
EXPOSE 3306

28
php/Dockerfile Normal file
View File

@@ -0,0 +1,28 @@
FROM php:8.4-fpm-alpine
# Install system dependencies
RUN apk add --no-cache \
libzip-dev \
zip \
unzip \
git \
curl \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
oniguruma-dev \
xml-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nicon) gd zip pdo_mysql mysqli exif pcntl bcmath opcache
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /var/www/html
# Expose port 9000 for PHP-FPM
EXPOSE 9000
# Start PHP-FPM
CMD ["php-fpm"]