LoginSignup
6

More than 5 years have passed since last update.

GROWI を dockerでサクッと試す

Last updated at Posted at 2019-02-16

image.png

前提条件

  1. ec2 (Amazon Linux 2)を使用
  2. docker-compose はインストール済み
  3. letsencryptを使ってSSLで接続する

letsencrypt + nginx-proxy の設定

$ mkdir -p ~/docker/nginx-proxy
$ cd ~/docker/nginx-proxy
$ vim docker-compose.yml
version: '3'

services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    restart: on-failure
    labels:
      - com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=jwilder/nginx-proxy
    ports:
      - 80:80
      - 443:443
    volumes:
      - proxy:/etc/nginx/vhost.d
      - proxy:/usr/share/nginx/html
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./certs:/etc/nginx/certs:ro
    network_mode: bridge

  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    restart: on-failure
    depends_on:
      - nginx-proxy
    volumes:
      - proxy:/etc/nginx/vhost.d
      - proxy:/usr/share/nginx/html
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./certs:/etc/nginx/certs:rw
    network_mode: bridge

volumes:
  proxy:

nginx-proxyの起動

$ docker-compose up -d

install growi-docker-compose

$ cd ~/docker
$ git clone https://github.com/weseek/growi-docker-compose.git growi
$ cd growi

docker-compose.yml を編集する

  • コメントを参考に修正をします
version: '3'

services:
  app:
    restart: on-failure # [追加]
    network_mode: bridge # [追加]
    build:
      context: .
      dockerfile: ./Dockerfile
    ports:
      - 3000:3000 # [変更]
    links:
      - mongo:mongo
      - elasticsearch:elasticsearch
    depends_on:
      - mongo
      - elasticsearch
    environment:
      - VIRTUAL_HOST=growi.example.com # [追加] SSLで利用したいFQDN
      - LETSENCRYPT_HOST=growi.example.com # [追加] SSLで利用したいFQDN
      - LETSENCRYPT_EMAIL=info@example.com # [追加] letsencryptに登録するE-Mail
      - MONGO_URI=mongodb://mongo:27017/growi
      - ELASTICSEARCH_URI=http://elasticsearch:9200/growi
      - PASSWORD_SEED=change # [変更] ランダムな64文字に置き換える!!
      - FILE_UPLOAD=local
    command: "dockerize
              -wait tcp://mongo:27017
              -wait tcp://elasticsearch:9200
              -timeout 60s
              npm run server:prod"
    volumes:
      - growi_data:/data

  mongo:
    restart: on-failure # [追加]
    network_mode: bridge # [追加]
    image: mongo:3.4
    volumes:
      - mongo_configdb:/data/configdb
      - mongo_db:/data/db

  elasticsearch:
    restart: on-failure # [追加]
    network_mode: bridge # [追加]
    image: elasticsearch:5.3-alpine
    environment:
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"  # increase amount if you have enough memory
    command:
      - sh
      - -c
      - "./bin/elasticsearch-plugin list | grep -q analysis-kuromoji || ./bin/elasticsearch-plugin install analysis-kuromoji;
        ./bin/elasticsearch-plugin list | grep -q analysis-icu || ./bin/elasticsearch-plugin install analysis-icu;
        /docker-entrypoint.sh elasticsearch"
    volumes:
      - es_data:/usr/share/elasticsearch/data
      - es_plugins:/usr/share/elasticsearch/plugins
      - ./esconfig:/usr/share/elasticsearch/config

volumes:
  growi_data:
  mongo_configdb:
  mongo_db:
  es_data:
  es_plugins:

growi-docker-compose の立ち上げ

$ docker-compose build
$ docker-compose up -d

最後に

これでしばらくすると、ブラウザで https://${LETSENCRYPT_HOST}/ にアクセスすると growiのログインページが表示されます。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6