Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
「オトナのDocker入門#LAMP環境を作ろう」のサンプル
version: '3.7'
services:
db:
image: mysql:8.0.17
restart: always
command: --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=sample
- TZ='Asia/Tokyo'
ports:
- 3306:3306
adminer:
image: adminer
restart: always
ports:
- 8080:8080
# Docker Volumeに置き換える
version: '3.7'
services:
db:
image: mysql:8.0.17
restart: always
command: --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=sample
- TZ='Asia/Tokyo'
ports:
- 3306:3306
volumes:
- data:/var/lib/mysql
adminer:
image: adminer
restart: always
ports:
- 8080:8080
volumes:
data:
# my.cnfを配置
version: '3.7'
services:
db:
image: mysql:8.0.17
restart: always
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=sample
- TZ='Asia/Tokyo'
ports:
- 3306:3306
volumes:
- ./docker/db/conf.d/my.cnf:/etc/mysql/conf.d/my.cnf
- data:/var/lib/mysql
adminer:
image: adminer
restart: always
ports:
- 8080:8080
volumes:
data:
# services:web:を追加
# Dockerfile.step1
version: '3.7'
services:
web:
build:
context: .
dockerfile: ./docker/web/Dockerfile
ports:
- 8000:80
volumes:
- .:/var/www/html
db:
image: mysql:8.0.17
restart: always
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=sample
- TZ='Asia/Tokyo'
ports:
- 3306:3306
volumes:
- ./docker/db/conf.d/my.cnf:/etc/mysql/conf.d/my.cnf
- data:/var/lib/mysql
adminer:
image: adminer
restart: always
ports:
- 8080:8080
volumes:
data:
FROM php:7.3.8-apache-stretch
EXPOSE 80
# パッケージを追加
FROM php:7.3.8-apache-stretch
# nodeとnpmのインストール
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
# composerのインストール
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# composerで必要なものとmysql、gd利用のためのパッケージ
RUN apt-get update \
&& apt-get install -y \
git \
gnupg \
unzip \
nodejs \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-install \
pdo_mysql \
mysqli \
mbstring \
&& docker-php-ext-install -j$(nproc) iconv \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& a2enmod \
rewrite
EXPOSE 80
FROM php:7.3.8-apache-stretch
# nodeとnpmのインストール
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
# composerのインストール
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# composerで必要なものとmysql、gd利用のためのパッケージ
RUN apt-get update \
&& apt-get install -y \
git \
gnupg \
unzip \
nodejs \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-install \
pdo_mysql \
mysqli \
mbstring \
&& docker-php-ext-install -j$(nproc) iconv \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& a2enmod \
rewrite
COPY ./docker/web/php/php.ini /usr/local/etc/php/
COPY ./docker/web/sites-enabled/*.conf /etc/apache2/sites-enabled/
WORKDIR /var/www/html
EXPOSE 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.