このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
|
ソフトウェア:docker:docker-compose.yml_dockerfile_作成例:centos8_mysql8.0 [2019/10/30 11:36] humolife [コマンドの実行] |
ソフトウェア:docker:docker-compose.yml_dockerfile_作成例:centos8_mysql8.0 [2020/11/10 16:34] (現在) humolife [コマンドの実行] |
||
|---|---|---|---|
| 行 1: | 行 1: | ||
| ====== CentOS8 + MySQL8.0 の Docker Compose 作成例 ====== | ====== CentOS8 + MySQL8.0 の Docker Compose 作成例 ====== | ||
| - | Laravel を載せる用の CentOS8 の app コンテナを作り、MySQL8.0 の db コンテナを作成する例。 | + | Laravel を載せる用の CentOS8 の app コンテナと、MySQL8.0 の db コンテナを作成する例。 |
| ===== ディレクトリ構成 ===== | ===== ディレクトリ構成 ===== | ||
| < | < | ||
| 行 6: | 行 6: | ||
| ├ docker | ├ docker | ||
| │ ├ app | │ ├ app | ||
| - | │ │ ├ htdocs | + | │ │ ├ conf |
| - | │ │ │ └ .htaccess | + | │ │ │ ├ html.conf |
| + | │ │ │ └ php74.ini | ||
| + | │ │ ├ conf.d | ||
| + | │ │ │ └ charset.cnf | ||
| │ │ └ Dockerfile | │ │ └ Dockerfile | ||
| │ ├ db | │ ├ db | ||
| │ │ ├ conf.d | │ │ ├ conf.d | ||
| - | │ │ │ └ my.cnf | + | │ │ │ └ charset.cnf |
| │ │ └ Dockerfile | │ │ └ Dockerfile | ||
| │ └ docker-compose.yml | │ └ docker-compose.yml | ||
| 行 22: | 行 25: | ||
| services: | services: | ||
| db: | db: | ||
| - | container_name: | + | container_name: |
| build: ./db/ | build: ./db/ | ||
| - | image: | + | image: |
| environment: | environment: | ||
| MYSQL_ROOT_PASSWORD: | MYSQL_ROOT_PASSWORD: | ||
| 行 34: | 行 37: | ||
| - 3306:3306 | - 3306:3306 | ||
| app: | app: | ||
| - | container_name: | + | container_name: |
| build: ./app/ | build: ./app/ | ||
| - | image: | + | image: |
| ports: | ports: | ||
| - 8080:80 | - 8080:80 | ||
| - | links: | ||
| - | - db: | ||
| volumes: | volumes: | ||
| - ../ | - ../ | ||
| 行 53: | 行 54: | ||
| ===== docker/ | ===== docker/ | ||
| < | < | ||
| - | FROM centos:latest | + | FROM centos:8 |
| - | RUN dnf -y update && dnf -y install httpd | + | RUN export LC_ALL=C && \ |
| + | | ||
| + | | ||
| + | dnf -y install epel-release && \ | ||
| + | dnf -y install https:// | ||
| + | dnf -y install http:// | ||
| + | dnf module -y install php: | ||
| + | dnf -y install php-pdo php-json php-xml php-mysqlnd php-gd php-mbstring && \ | ||
| + | dnf -y install @mysql:8.0 && \ | ||
| + | dnf -y install ibus-kkc && \ | ||
| + | dnf -y install langpacks-ja && \ | ||
| + | curl -sL https:// | ||
| + | dnf -y install nodejs | ||
| - | RUN dnf -y install epel-release | + | ENV LANG ja_JP.UTF-8 |
| - | RUN dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm | + | COPY ./conf/html.conf / |
| + | COPY ./conf/php74.ini / | ||
| + | COPY ./ | ||
| - | RUN rpm -ivh http://ftp.riken.jp/Linux/remi/enterprise/remi-release-8.rpm | + | RUN export LANG=ja_JP.utf8 && \ |
| - | + | chmod 644 /etc/httpd/conf.d/html.conf && \ | |
| - | RUN dnf module install -y php:remi-7.3 | + | mkdir /var/log/php && \ |
| - | RUN dnf install | + | chown apache: |
| - | + | | |
| - | COPY ./ | + | ln -s / |
| - | + | ||
| - | RUN ln -s / | + | |
| - | + | ||
| - | # MySQL | + | |
| - | RUN dnf -y localinstall https:// | + | |
| - | + | ||
| - | RUN dnf -y install mysql-server | + | |
| - | + | ||
| - | # cron | + | |
| - | RUN dnf -y install crontabs | + | |
| # httpd | # httpd | ||
| 行 82: | 行 87: | ||
| </ | </ | ||
| - | ===== docker/app/htdocs/.htaccess | + | ===== docker/app/conf/html.conf ===== |
| < | < | ||
| - | RewriteEngine On | + | < |
| - | RewriteRule ^(.*)$ pj/$1 [QSA,L] | + | |
| + | AllowOverride All | ||
| + | Require all granted | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ===== docker/ | ||
| + | 対応バージョンの php.ini をどこかからコピーしてきて、設定したい内容に書き換えて設置 | ||
| + | |||
| + | ===== docker/app/ | ||
| + | < | ||
| + | [mysqld] | ||
| + | character-set-server = utf8mb4 | ||
| + | collation-server = utf8mb4_bin | ||
| + | init-connect=' | ||
| + | |||
| + | [client] | ||
| + | loose-default-character-set = utf8mb4 | ||
| </ | </ | ||
| ===== docker/ | ===== docker/ | ||
| < | < | ||
| - | FROM mysql:latest | + | FROM mysql:8.0 |
| - | COPY ./conf.d /etc/mysql/conf.d | + | |
| + | RUN apt-get update && \ | ||
| + | apt-get -y install locales-all && \ | ||
| + | export LC_ALL=ja_JP.UTF-8 | ||
| + | |||
| + | ENV LANG ja_JP.UTF-8 | ||
| + | |||
| + | COPY ./conf.d/ | ||
| </ | </ | ||
| - | ===== docker/ | + | ===== docker/ |
| < | < | ||
| [mysqld] | [mysqld] | ||
| - | # Character code setting / collation order setting | + | character-set-server |
| - | character_set_server=utf8mb4 | + | collation-server = utf8mb4_bin |
| - | collation-server=utf8mb4_bin | + | init-connect=' |
| - | default_authentication_plugin= mysql_native_password | + | [client] |
| - | + | loose-default-character-set = utf8mb4 | |
| - | [mysql] | + | |
| - | default-character-set=utf8mb4 | + | |
| </ | </ | ||
| 行 131: | 行 158: | ||
| # app コンテナに入り作業をする | # app コンテナに入り作業をする | ||
| - | docker container exec -it laravel_app_sample | + | docker container exec -it project_name_app |
| # マウントした production に移動 | # マウントした production に移動 | ||
| 行 140: | 行 167: | ||
| # db コンテナの DB に接続できるか確認 | # db コンテナの DB に接続できるか確認 | ||
| - | mysql -h laravel_db_sample | + | mysql -h project_name_db |
| </ | </ | ||
| + | これでローカルで Laravel を動かすための環境が整いました。\\ | ||
| + | 次は Laravel のインストールを行います。\\ | ||
| + | ⇒ [[プログラム言語: | ||