ただの覚書です。
docker-compose.yml
version: '3'
services:
#MySQL用コンテナ
mysql:
container_name: db
image: mariadb:10.4
volumes:
#./dataフォルダに作成してる
- ./data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=todo
- MYSQL_USER=todo
- MYSQL_PASSWORD=todo
ports:
- 3306:3306
#php用コンテナ
php:
container_name: php-apache
#./phpフォルダに作成してる
build: ./php
volumes:
#./sourceフォルダに作成
- ./source:/var/www/html
- .php/vhosts.conf:/etc/apache2/conf-enabled/vhosts.conf
ports:
- 8000:80
depends_on:
- mysql
Dockerfile
FROM php:8.1.12-apache
#php install
RUN apt update
RUN apt install -y wget git unzip libpq-dev
RUN apt install -y zlib1g-dev mariadb-client libzip-dev libonig-dev \
&& docker-php-ext-install zip pdo_mysql
#composerインストール
RUN curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer \
&& chmod +x /usr/local/bin/composer
#ワーキングディレクトリ(ここで動く)
WORKDIR /var/www/html
#基本的には変わらない↓
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_HOME /composer
ENV PATH $PATH:/composer/vendor/bin
# タイムゾーン設定
ENV TZ=Asia/Tokyo
vhosts.conf
NameVirturalHost *:80
<VirtualHost *:80>
ServerAdmin todo@localhost
ServerName localhost
DocumentRoot /var/www/html/public
<Directory "/var/www/html/public">
Options Indexes FollowSymLinks
DirectoryIndex index.php
AllowOverride All
Require all granted
Order allow,deny
Allow from all
</Directory>
</VirtualHost>