#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

version: '3'
services:
  node:
    # Uncomment the next line to use a non-root user for all processes. You can also
    # simply use the "remoteUser" property in devcontainer.json if you just want VS Code
    # and its sub-processes (terminals, tasks, debugging) to execute as the user. On Linux,
    # you may need to update USER_UID and USER_GID in .devcontainer/Dockerfile to match your
    # user if not 1000. See https://aka.ms/vscode-remote/containers/non-root for details.
    user: node

    build:
      context: .
      dockerfile: Dockerfile

    ports:
      - 3000:3000
      - 3001:3001 # for browser-sync

    volumes:
      - ..:/workspace/growi:delegated
      - node_modules:/workspace/growi/node_modules
      - ../../growi-docker-compose:/workspace/growi-docker-compose:delegated

    tty: true

  mongo:
    image: mongo:4.4
    restart: unless-stopped
    ports:
      - 27017:27017
    volumes:
      - /data/db

  # This container requires '../../growi-docker-compose' repository
  #   cloned from https://github.com/weseek/growi-docker-compose.git
  elasticsearch:
    build:
      context: ../../growi-docker-compose/elasticsearch
      dockerfile: ./Dockerfile
    restart: unless-stopped
    ports:
      - 9200:9200
    environment:
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - /usr/share/elasticsearch/data
      - ../../growi-docker-compose/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml

  elasticsearch-head:
    image: tobias74/elasticsearch-head:6
    restart: unless-stopped
    ports:
      - 9100:9100

  # This container requires '../../growi-docker-compose' repository
  #   cloned from https://github.com/weseek/growi-docker-compose.git
  hackmd:
    build:
      context: ../../growi-docker-compose/hackmd
    restart: unless-stopped
    environment:
      - GROWI_URI=http://localhost:3000
      # define 'storage' option value
      # see https://github.com/sequelize/cli/blob/7160d0/src/helpers/config-helper.js#L192
      - CMD_DB_URL=sqlite://dummyhost/hackmd/sqlite/codimd.db
      - CMD_CSP_ENABLE=false
    ports:
      - 3010:3000
    volumes:
      - /files/sqlite
volumes:
  node_modules:
