2018年2月19日月曜日

DockerでEasy!Appointments、MySQLがインストールされたコンテナ(Alpine 3.7)を構築する

Easy!Appointmentsでスケジュールを管理する事ができます。
以下の手順で、Easy!AppointmentsとMySQLのコンテナを構築・実行します。

○構築方法
1. Easy!Appointmentsイメージの作成(Dockerfileがあるフォルダで実行)
docker build -t easyappointments .

Dockerfile(※192.168.55.129は適宜変更します)
FROM alpine:3.7
WORKDIR /
RUN  apk update \
  && apk add --no-cache apache2 php7-apache2 php7-mysqli php7-pdo php7-session php7-mbstring php7-mcrypt php7-ctype php7-json php7-xml php7-simplexml php7-zip openssl openrc unzip \
  && rm -rf /var/cache/apk/* \
  && mkdir -p /opt/easyappointments
WORKDIR /opt/easyappointments
RUN wget https://github.com/alextselegidis/easyappointments/releases/download/1.2.1/easyappointments_1.2.1.zip \
  && unzip easyappointments_1.2.1.zip \
  && rm -f easyappointments_1.2.1.zip \
  && sed -i -e "s#http://url-to-easyappointments-directory#http://192.168.55.129/easyappointments/#" /opt/easyappointments/config.php \
  && sed -i -e "s#DB_HOST.*= '';#DB_HOST       = 'db';#" /opt/easyappointments/config.php \
  && sed -i -e "s#DB_NAME.*= '';#DB_NAME       = 'easyappointments';#" /opt/easyappointments/config.php \
  && sed -i -e "s#DB_USERNAME.*= '';#DB_USERNAME   = 'root';#" /opt/easyappointments/config.php \
  && sed -i -e "s#DB_PASSWORD.*= '';#DB_PASSWORD   = 'easyappointments';#" /opt/easyappointments/config.php \
  && chown -R apache:apache /opt/easyappointments \
  && mkdir -p /run/apache2 \
  && ln -s /opt/easyappointments /var/www/localhost/htdocs
EXPOSE 80
VOLUME /opt/easyappointments
CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]

2. Easy!AppointmentsとMySQLコンテナの構築・実行(docker-compose.ymlがあるフォルダで実行)
docker-compose up -d

docker-compose.yml
version: "2"
services:
  easyappointments:
    image: easyappointments
    container_name: "easyappointments"
    volumes:
      - "easyappointments-data:/opt/easyappointments"
    ports:
      - "80:80"
    depends_on:
      - db
  db:
    image: mysql:5.7
    command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    container_name: "easyappointments-db"
    volumes:
      - "db-data:/var/lib/mysql"
    environment:
        MYSQL_DATABASE: easyappointments
        MYSQL_ROOT_PASSWORD: easyappointments
volumes:
  db-data:
    driver: local
  easyappointments-data:
    driver: local

3. ブラウザからhttp:///easyappointments/にアクセス
管理者情報や会社情報を入力します。


○Easy!Appointmentsの画面


○その他
・Easy!AppointmentsとMySQLコンテナの停止・削除(docker-compose.ymlがあるフォルダで実行)
docker-compose down

・永続化ボリュームの一覧表示
docker volume ls


○関連情報
・Easy!Appointmentsに関する他の記事はこちらを参照してください。

0 件のコメント:

コメントを投稿