Skip to content

Instantly share code, notes, and snippets.

@acro5piano
Last active December 6, 2017 15:32
Show Gist options
  • Save acro5piano/7b330ce17a69c9e8aadb9c228fcd5408 to your computer and use it in GitHub Desktop.
Save acro5piano/7b330ce17a69c9e8aadb9c228fcd5408 to your computer and use it in GitHub Desktop.
Docker Composeで手軽に開発環境を構築 (PHP+MySQL+Elasticsearch+Memcached) ref: https://qiita.com/acro5piano/items/1d907f81afd0fb3a199e
web:
container_name: some-web
elasticsearch:
image: "elasticsearch:1.3"
memcached:
image: memcached
FROM mysql:5.6
COPY my.cnf /etc/mysql
git clone https://github.com/acro5piano/docker-lamp-elasticsearch.git
cd docker-lamp-elasticsearch
docker-compose up
.
|-- db
| |-- init.d
| | `-- setup.sql
| |-- Dockerfile
| `-- my.cnf
|-- src
| `-- yourgreatapp
| `-- index.php
|-- web
| |-- Dockerfile
| `-- httpd.conf
`-- docker-compose.yml
[mysqld]
default-storage-engine=InnoDB
character-set-server=utf8
GRANT ALL PRIVILEGES ON `yourgreatapp`.* TO 'yourgreatapptest'@'%';
Name Command State Ports
--------------------------------------------------------------------------------------------------------------
docker_db_1 docker-entrypoint.sh mysqld Up 0.0.0.0:33333->3306/tcp
docker_elasticsearch_1 /docker-entrypoint.sh elas ... Up 9200/tcp, 9300/tcp
docker_memcached_1 docker-entrypoint.sh memcached Up 11211/tcp
docker_web_1 /usr/sbin/apachectl -D FOR ... Up 0.0.0.0:3000->3000/tcp, 0.0.0.0:8000->80/tcp
elasticsearch:
image: "elasticsearch:1.3"
memcached:
image: memcached
Name Command State Ports
--------------------------------------------------------------------------------------------------------------
docker_db_1 docker-entrypoint.sh mysqld Up 0.0.0.0:33333->3306/tcp
docker_elasticsearch_1 /docker-entrypoint.sh elas ... Up 9200/tcp, 9300/tcp
docker_memcached_1 docker-entrypoint.sh memcached Up 11211/tcp
docker_web_1 /usr/sbin/apachectl -D FOR ... Up 0.0.0.0:3000->3000/tcp, 0.0.0.0:8000->80/tcp
alias dc='docker-compose'
web:
container_name: some-web
alias dc='docker-compose'
dc run web php /var/www/app/composer.phar update
web:
build: ./web
ports:
- "8000:80"
- "3000:3000"
links:
- db
- memcached
- elasticsearch
volumes:
- ./src/yourgreatapp:/var/www/yourgreatapp
db:
build: ./db
environment:
MYSQL_ROOT_PASSWORD: ROOT_PASSWORD
MYSQL_DATABASE: yourgreatapp
MYSQL_USER: yourgreatapptest
MYSQL_PASSWORD: yourgreatapptest
MYSQL_HOST: ""
mem_limit: 1000000000
volumes:
- ./db/init.d:/docker-entrypoint-initdb.d
ports:
- "33333:3306"
elasticsearch:
image: "elasticsearch:1.3"
memcached:
image: memcached
|-- src
| `-- yourgreatapp
| `-- index.php
`-- web
|-- init.d
| `-- setup.sh
|-- Dockerfile
`-- httpd.conf
FROM centos:6
RUN rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
RUN rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
RUN yum install -y httpd
RUN yum install --enablerepo=epel,remi-php55,remi -y \
php \
php-cli \
php-gd \
php-mbstring \
php-mcrypt \
php-mysqlnd \
php-pdo \
php-xml \
php-xdebug \
php-memcached
RUN sed -i -e "s|^;date.timezone =.*$|date.timezone = Asia/Tokyo|" /etc/php.ini
COPY httpd.conf /etc/httpd/conf.d/yourgreatapp.conf
EXPOSE 80
CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]
NameVirtualHost *:80
<VirtualHost *:80>
ServerName docker-compose-lamp.dev
DocumentRoot /var/www/yourgreatapp/public
<Directory /var/www/yourgreatapp/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
SetEnv FUEL_ENV development_docker
</VirtualHost>
|-- db
|-- init.d
| `-- setup.sql
|-- Dockerfile
`-- my.cnf
FROM mysql:5.6
COPY my.cnf /etc/mysql
|-- db
|-- init.d
| `-- setup.sql
|-- Dockerfile
`-- my.cnf
GRANT ALL PRIVILEGES ON `yourgreatapp`.* TO 'yourgreatapptest'@'%';
FROM mysql:5.6
COPY my.cnf /etc/mysql
NameVirtualHost *:80
<VirtualHost *:80>
ServerName docker-compose-lamp.dev
DocumentRoot /var/www/yourgreatapp/public
<Directory /var/www/yourgreatapp/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
SetEnv FUEL_ENV development_docker
</VirtualHost>
<?php phpinfo();
[mysqld]
default-storage-engine=InnoDB
character-set-server=utf8
GRANT ALL PRIVILEGES ON `yourgreatapp`.* TO 'yourgreatapp'@'%';
|-- src
| `-- yourgreatapp
| `-- index.php
`-- web
|-- init.d
| `-- setup.sh
|-- Dockerfile
`-- httpd.conf
hogehoge/fugafuga.git
|-- public/index.php
|-- docker-compose.yml
`-- docker
|-- web
| `-- Dockerfile
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment