Sign inSign up

juanprogramm/simple-damp

By juanprogramm

Updated over 1 year ago

Sets up a complete PHP development environment with Apache, MySQL, phpMyAdmin, and Composer.

Image
Languages & frameworks
Web servers
Databases & storage
0

233

juanprogramm/simple-damp repository overview

Simple DAMP (Docker Apache MySQL PHP)

This Docker container sets up a development environment using Apache, MySQL, and PHP (DAMP). It is ideal for quickly and easily setting up PHP-based web applications with MySQL database support.

Technologies Used

  • Debian
  • PHP 8.2 with Apache
  • MySQL 8 for database
  • Composer for managing PHP dependencies

Usage Instructions

Docker Compose
Copy this docker compose in the root of your project.

networks:
  simple-damp-network:
    driver: bridge

volumes:
  mysql_data:

services:
  # server
  webserver:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: simple-damp
    restart: always
    deploy:
      resources:
        limits:
          cpus: "1.5"
          memory: 1500M
        reservations:
          cpus: "0.5"
          memory: 512M
    ports:
      - "8080:80"
      # - "443:443" # Uncomment for SSL
    volumes:
      - ./www:/var/www/html # Your .php files here. Map local /www/ to docker's /var/www/html
    networks:
      - simple-damp-network
    depends_on:
      db:
        condition: service_healthy
    environment:
      - DB_HOST=db
      - APACHE_RUN_USER=www-data
      - APACHE_RUN_GROUP=www-data
      - PHP_MEMORY_LIMIT=256M
    command: >
      sh -c "a2enmod rewrite"

  # database 
  db:
    image: mysql:8
    container_name: simple-damp-db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root #-u root -p -> root
      MYSQL_DATABASE: simpledamp 
      MYSQL_USER: user #-u root -p -> password
      MYSQL_PASSWORD: password
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - simple-damp-network
    healthcheck:
      test: [ "CMD", "mysqladmin", "ping", "-h", "localhost", "-u$${MYSQL_USER}", "-p$${MYSQL_PASSWORD}" ]
      interval: 5s
      timeout: 10s
      retries: 5
  
  # phpMyAdmin
  phpmyadmin:
    image: phpmyadmin
    container_name: phpmyadmin
    restart: always
    ports:
      - "8081:80"
    environment:
      UPLOAD_LIMIT: 128M
    networks:
      - simple-damp-network

Dockerfile
Copy this Dockerfile in the root of your project.
ARG release=8.2
ARG type=apache

FROM php:${release}-${type} AS server-builder

WORKDIR /var/www/html

ENV APACHE_RUN_USER=www-data
ENV APACHE_RUN_GROUP=www-data

##### START METADATA #####

##### END METADATA #####

#####  START DOCKER SETTINGS  #####

# Update, upgrade the system
RUN apt-get update && apt-get upgrade -y    \
    #Install additional packages
    && apt-get install -y   \
        unzip   \
        libonig-dev \
        libxml2-dev \
        libzip-dev  \
        libicu-dev  \
        libgd-dev   \
        libpng-dev \
        curl \
        git \
        zip \
    # Remove apt cache
    && rm -rf /var/lib/apt/lists/*  \
    # Install necessary development libraries and tools
    && docker-php-ext-install   \
        mysqli  \
        pdo_mysql   \
        #opcache \
        #mbstring    \
        #xml \
        #zip \
        #intl    \
        #gd  \
        #exif    \
        #pcntl   \
        #bcmath  \
        #soap    \
    # Install Composer
    && curl -sS https://getcomposer.org/installer | php \
    && mv composer.phar /usr/local/bin/composer \
    # Enable Apache modules
    && a2enmod rewrite expires headers

# Copy local files from www to /var/www/html
# COPY /www/ /var/www/html


RUN  a2enconf servername tuning    \
    && chown -R www-data:www-data /var/www/html \
    && find /var/www/html -type d -exec chmod 755 {} \; \
    && find /var/www/html -type f -exec chmod 644 {} \; \
    && service apache2 restart

# Expose only HTTP by default
EXPOSE 80

CMD ["apache2-foreground"]
#####  END DOCKER SETTINGS  #####

Requirements

  • Docker and
  • Docker Compose installed.

Project on GitHub

🔗 Ver el código fuente

Documentación

📖 Leer la documentación

Tag summary

Content type

Image

Digest

sha256:cef440bd9

Size

235.9 MB

Last updated

over 1 year ago

docker pull juanprogramm/simple-damp