Last active
June 22, 2018 01:49
-
-
Save niisan-tokyo/42f5051c1358205a94f58a1ea8563cbd to your computer and use it in GitHub Desktop.
Docker handson code snipet
This file contains 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
<?php | |
$sum = 0; | |
for ($i = 1; $i < 10; $i++) { | |
$sum += $i; | |
} | |
echo $sum; |
This file contains 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
FROM php:alpine | |
MAINTAINER Niikura Rtyota <ryota.niikura@nijibox.co.jp> | |
RUN apk update && apk add unzip bzip2-dev | |
RUN docker-php-ext-install mysqli pdo_mysql | |
RUN curl -sS https://getcomposer.org/installer | php; mv composer.phar /usr/local/bin/composer ; mkdir /var/dev | |
RUN docker-php-ext-install bz2 | |
RUN curl -L -o /usr/bin/phpmd http://static.phpmd.org/php/latest/phpmd.phar && chmod +x /usr/bin/phpmd | |
RUN mkdir /var/www | |
WORKDIR /var/www | |
CMD ["sh"] |
This file contains 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
FROM httpd:alpine | |
COPY ./public/ /usr/local/apache2/htdocs/ |
This file contains 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
version: '3' | |
services: | |
db: | |
image: mysql:5.7 | |
environment: | |
- MYSQL_DATABASE=homestead | |
- MYSQL_USER=homestead | |
- MYSQL_PASSWORD=secret | |
- MYSQL_ROOT_PASSWORD=root | |
volumes: | |
- mysql:/var/lib/mysql | |
phpmyadmin: | |
image: phpmyadmin/phpmyadmin | |
environment: | |
- PMA_HOST=db | |
- PMA_USER=root | |
- PMA_PASSWORD=root | |
ports: | |
- "3333:80" | |
depends_on: | |
- db | |
workspace: | |
image: niisan/php | |
volumes: | |
- ./src:/var/www | |
ports: | |
- "8888:8888" | |
volumes: | |
mysql: | |
driver: "local" |
This file contains 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
<?php | |
$client = new mysqli('db', 'homestead', 'secret', 'homestead'); | |
$sql = "CREATE TABLE homestead.test_table (`id` int, `name` varchar(256))"; | |
$res = $client->query($sql); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment