Created
November 5, 2023 06:54
-
-
Save jonpontet/a3ee70bf194ff797fd807b53a28c8b78 to your computer and use it in GitHub Desktop.
My WordPress Docker stack
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
# docker-compose.yml | |
# Defines our containers and the images that they use. | |
version: '3.3' | |
services: | |
db: | |
container_name: ${DOCKER_DB_CONTAINER} | |
image: mariadb:10.6 | |
command: [ | |
'--character-set-server=utf8mb4', | |
'--collation-server=utf8mb4_unicode_ci' | |
] | |
volumes: | |
- db:/var/lib/mysql | |
restart: always | |
environment: | |
MYSQL_ROOT_PASSWORD: password | |
MYSQL_USER: ${WP_DB_USER} | |
MYSQL_PASSWORD: ${WP_DB_PASSWORD} | |
MYSQL_DATABASE: ${WP_DB_NAME} | |
ports: | |
- "3306:3306" | |
networks: | |
- web | |
web: | |
container_name: ${DOCKER_WEB_CONTAINER} | |
depends_on: | |
- db | |
image: [image name] | |
env_file: | |
- .env | |
ports: | |
- "8080:80" | |
- "8443:443" | |
hostname: [localhost name] | |
networks: | |
web: | |
aliases: | |
- [localhost name] | |
restart: always | |
volumes: | |
- ./:${SERVER_PATH} | |
- ./conf/php/php.ini:/usr/local/etc/php/php.ini | |
- ./conf/apache/000-default.conf:/etc/apache2/sites-available/000-default.conf | |
wp-cli: | |
container_name: ${DOCKER_WP_CLI_CONTAINER} | |
depends_on: | |
- web | |
image: wordpress:cli-php8.2 | |
user: 1000:1000 | |
command: tail -f /dev/null | |
volumes: | |
- ./:${SERVER_PATH} | |
environment: | |
WORDPRESS_DB_HOST: ${WP_DB_HOST} | |
WORDPRESS_DB_USER: ${WP_DB_USER} | |
WORDPRESS_DB_PASSWORD: ${WP_DB_PASSWORD} | |
WORDPRESS_DB_NAME: ${WP_DB_NAME} | |
networks: | |
- web | |
volumes: | |
db: | |
networks: | |
web: |
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
# Dockerfile | |
# Defines an image. | |
# Rebuild this image: docker build -t [image name]:latest . | |
FROM php:8.2-apache | |
# Install packages. | |
RUN apt-get update && apt-get install -y \ | |
vim \ | |
unzip \ | |
libcurl4 \ | |
libcurl4-openssl-dev \ | |
git \ | |
libzip-dev \ | |
zlib1g-dev | |
RUN pecl install igbinary | |
# Install PHP extensions. | |
RUN docker-php-ext-install mysqli \ | |
&& docker-php-ext-install opcache \ | |
&& docker-php-ext-install curl \ | |
&& docker-php-ext-install exif \ | |
&& docker-php-ext-install zip | |
# Enable PHP extensions | |
RUN docker-php-ext-enable igbinary | |
# Install composer 2.2. | |
RUN curl https://getcomposer.org/installer > composer-setup.php && php composer-setup.php --2.2 | |
RUN chmod a+x composer.phar && mv composer.phar /usr/local/bin/composer | |
# Enable SSL for Apache. | |
COPY ./conf/apache/pontetlabs.localdev.pem /etc/ssl/certs/ | |
COPY ./conf/apache/pontetlabs.localdev-key.pem /etc/ssl/private/ | |
RUN ln -s /etc/apache2/mods-available/ssl.load /etc/apache2/mods-enabled/ssl.load | |
# Enable mod_rewrite for Apache. | |
RUN a2enmod rewrite | |
# Enable xDebug. | |
# https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html#configuring-xdebug-docker | |
RUN pecl install xdebug \ | |
&& docker-php-ext-enable xdebug \ | |
&& echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ | |
&& echo "xdebug.client_host = host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini | |
# Necessary? | |
#RUN ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts | |
# Turn off git strict host checking to avoid clone failures. | |
RUN export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment