Skip to content

Instantly share code, notes, and snippets.

@wakproductions
Created March 5, 2021 14:43
Show Gist options
  • Save wakproductions/bf1bc9ec7d5aefbcbdf48f76b4fbecfc to your computer and use it in GitHub Desktop.
Save wakproductions/bf1bc9ec7d5aefbcbdf48f76b4fbecfc to your computer and use it in GitHub Desktop.
Dockerfile and docker-compose for PHP server
version: '3'
services:
backend:
build: ./
command: ['httpd-foreground']
depends_on:
- db
entrypoint: ['./scripts/docker-entry.sh']
environment:
PHP_EXTENSION_XDEBUG: 1
XDEBUG_HOST: ${XDEBUG_HOST}
links:
- db
networks:
- mywebsite
ports:
- '8010:80'
# stdin_open: true
# tty: true
volumes:
- ./:/Websites/www.mywebsite.com/
- ./docker/www/phptest.php:/Websites/www.mywebsite.com/www/phptest.php
- ./docker/Configuration/hFramework.conf:/Websites/www.mywebsite.com/Configuration/hFramework.conf
- ./docker/Configuration/my.mywebsite.com.json:/Websites/www.mywebsite.com/Configuration/my.mywebsite.com.json
- ./docker/Configuration/my.mywebsite.com.80.conf:/Websites/www.mywebsite.com/Configuration/my.mywebsite.com.80.conf
- ./docker/Configuration/www.mywebsite.com.json:/Websites/www.mywebsite.com/Configuration/www.mywebsite.com.json
db:
container_name: mywebsite_db
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
image: 'mysql:5.7'
networks:
- mywebsite
ports:
- 3306:3306
volumes:
- ./docker/my.cnf:/etc/mysql/my.cnf
- ./docker/mysql-dump:/mysql-dump
- mysql_data_57:/var/lib/mysql
networks:
mywebsite:
volumes:
mysql_data_57:
external: true
FROM httpd:2.4.23
# autoconf - needed for building debugger
# curl - useful tool for debugging in the container
# mysql-client - because we're using MySQL 5.7 on a different container
# libmysqlclient-dev - needed for mysql_config, option needed to get MYSQLI driver in compile
# gcc, make - need a C compiler to build PHP
# libxml2-dev - dependency for compiling PHP
RUN apt-get update && apt-get install -y \
autoconf \
mysql-client \
libmysqlclient-dev \
gcc \
libxml2-dev \
make \
curl \
vim
COPY ./docker/php-5.6.40.tar.gz /tmp
# Need to compile PHP to get needed extensions, namely MYSQLI driver and PHP module
RUN cd /tmp && tar -zxvf php-5.6.40.tar.gz
RUN cd /tmp/php-5.6.40 && \
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli=/usr/bin/mysql_config \
--enable-mbstring && \
make && make install
RUN cd /tmp && rm -rf php-5.6.40 && rm php-5.6.40.tar.gz
COPY ./docker/xdebug-2.5.5.tgz /tmp/xdebug-2.5.5.tgz
RUN cd /tmp && tar -zxvf xdebug-2.5.5.tgz
RUN cd /tmp/xdebug-2.5.5 && phpize && ./configure --enable-xdebug && make && make install
RUN cd /tmp && rm -rf xdebug-2.5.5 && rm xdebug-2.5.5.tgz
RUN mkdir -p /var/log/apache2 && touch /var/log/apache2/error.log
ENV APACHE_LOG_DIR /var/log/apache2
WORKDIR /Websites/www.mywebsite.com
COPY ./docker/docker-httpd-2.4.23.conf /usr/local/apache2/conf/httpd.conf
COPY ./Configuration/www.mywebsite.com.80.conf /usr/local/apache2/conf/www.mywebsite.com.80.conf
COPY ./docker/php.ini /usr/local/lib/php.ini
EXPOSE 80
CMD ['httpd-foreground']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment