-
-
Save Swiss-Mac-User/4e171b9eef8685643d33977b129714fe to your computer and use it in GitHub Desktop.
Apple Silicon comaptible containerized LAMPP stack on Docker (Apache, PHP, MySQL, PhpMyAdmin) using only docker-compose | Works on ARM architecture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COMPOSE_PROJECT_NAME=“myapp" | |
OS_PLATFORM="linux/x86_64" | |
HTTP_PORT=80 | |
HTTPS_PORT=443 | |
DOMAINNAME="localhost" # With hosts entry, adjust accordingly like "myapp.local" | |
APACHE_WEBROOT="/var/www" | |
PHP_Version=7.4 | |
MYSQL_TYPE="mariadb" # Use "mariadb" or "mysql" | |
MYSQL_VERSION="latest" | |
MYSQL_PORT=3306 | |
MYSQL_DATABASE="mydatabase" | |
MYSQL_USER="root" | |
MYSQL_PASSWORD="" | |
PHPMYADMIN_PORT=8080 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
apache-php: | |
platform: ${OS_PLATFORM} | |
image: php:${PHP_VERSION:-7.4}-apache | |
container_name: ${COMPOSE_PROJECT_NAME}-web | |
restart: unless-stopped | |
environment: | |
- APACHE_DOCUMENT_ROOT=${APACHE_WEBROOT:-/var/www} | |
hostname: webserver | |
domainname: ${DOMAINNAME} | |
ports: | |
- ${HTTP_PORT:-80}:80 | |
- ${HTTPS_PORT:-443}:443 | |
volumes: | |
#- ./Docker/ssl:/etc/apache2/ssl # Generate using: mkcert mysite.local localhost 127.0.0.1 ::1 | |
#- ./Docker/apache2/000-default.conf:/etc/apache2/sites-available/000-default.conf # Only if you need custom apache site config stuff | |
#- ./Docker/apache2/ssl-default.conf:/etc/apache2/sites-available/default-ssl.conf # Only if you need custom apache ssl-site config stuff | |
#- ./myapp-configs:${APACHE_WEBROOT:?err}/myapp-configs # Example: use this if you need a dir outside the public web-dir | |
- ./myapp:${APACHE_WEBROOT:?err}/html # Adjust './myapp' to the dir with your app's public web-files | |
entrypoint: ["/bin/sh","-c"] | |
command: | |
- | | |
echo "Mutex posixsem" >> /etc/apache2/apache2.conf | |
curl -sSLf \ | |
-o /usr/local/bin/install-php-extensions \ | |
https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \ | |
chmod +x /usr/local/bin/install-php-extensions && \ | |
install-php-extensions mysqli pdo_mysql gd xdebug | |
exec /usr/sbin/apache2ctl -D FOREGROUND | |
# To enable apache2 SSL (with certificate files), add the following BEFORE the last line 'exec...': | |
# a2enmod ssl | |
# a2ensite default-ssl | |
db: | |
platform: ${OS_PLATFORM} | |
image: ${MYSQL_TYPE}:${MYSQL_VERSION:-latest} | |
container_name: ${COMPOSE_PROJECT_NAME}-db | |
restart: unless-stopped | |
hostname: database | |
environment: | |
- ${MYSQL_TYPE}_ALLOW_EMPTY_ROOT_PASSWORD=yes | |
- ${MYSQL_TYPE}_ROOT_PASSWORD=${MYSQL_PASSWORD:-dbpass} | |
- ${MYSQL_TYPE}_DATABASE=${MYSQL_DATABASE} | |
- ${MYSQL_TYPE}_USER=${MYSQL_USER:-dbuser} | |
- ${MYSQL_TYPE}_PASSWORD=${MYSQL_PASSWORD:-root} | |
#- MYSQL_ROOT_HOST="%" # in some scenarios this revokes Host IP connection restrictions | |
ports: | |
- ${MYSQL_PORT:-3306}:3306 | |
healthcheck: | |
test: ${MYSQL_TYPE} ${MYSQL_DATABASE} --user=${MYSQL_USER} --password='${MYSQL_PASSWORD}' --silent --execute "SELECT 1;" | |
interval: 10s | |
timeout: 3s | |
retries: 5 | |
volumes: | |
- ./Docker/mysql57:/var/lib/mysql # Adjust './Docker/mysql57' to re-use your existing local DB files | |
# Only works with "mysql" DB-Type | |
#command: [mysqld, --default-authentication-plugin=mysql_native_password, --character-set-server=utf8mb4, --collation-server=utf8mb4_unicode_ci, --innodb_monitor_enable=all, --max-connections=1001] | |
db-manager: | |
image: phpmyadmin:latest | |
container_name: ${COMPOSE_PROJECT_NAME}-phpmyadmin | |
restart: unless-stopped | |
hostname: dbmanager | |
depends_on: | |
db: | |
condition: service_healthy | |
environment: | |
- PMA_ARBITRARY=1 | |
#- PMA_HOST=db # Not needed with PMA_ARBITRARY | |
#- MYSQL_USER={MYSQL_USER:-root} # (Not needed with PMA_ARBITRARY) phpMyAdmin connects using the MySQL credentials env | |
#- MYSQL_PASSWORD=${MYSQL_PASSWORD:-root} # (Not needed with PMA_ARBITRARY) phpMyAdmin connects using the MySQL credentials env | |
ports: | |
- ${PHPMYADMIN_PORT:-8080}:80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment