captainVersion: 4
services:
    $$cap_appname-db:
        image: 'mariadb:$$cap_mariadb_version'
        environment:
            MYSQL_ROOT_PASSWORD: $$cap_mariadb_root_passwd
        volumes:
            - '$$cap_appname-db-data:/var/lib/mysql'
        networks:
            - seatable-net
        caproverExtra:
            notExposeAsWebApp: 'true'

    $$cap_appname-memcached:
        image: 'memcached:$$cap_memcached_version'
        entrypoint: memcached -m 256
        networks:
            - seatable-net
        caproverExtra:
            notExposeAsWebApp: 'true'

    $$cap_appname-redis:
        image: 'redis:$$cap_redis_version'
        networks:
            - seatable-net
        caproverExtra:
            notExposeAsWebApp: 'true'

    $$cap_appname:
        volumes:
            - '$$cap_appname-data:/shared'
        environment:
            DB_HOST: srv-captain--$$cap_appname-db
            DB_ROOT_PASSWD: $$cap_mariadb_root_passwd
            SEATABLE_SERVER_LETSENCRYPT: 'False'
            SEATABLE_SERVER_HOSTNAME: $$cap_appname.$$cap_root_domain
            TIME_ZONE: $$cap_timezone
        depends_on:
            - $$cap_appname-db
            - $$cap_appname-memcached
            - $$cap_appname-redis
        networks:
            - seatable-net
        caproverExtra:
            dockerfileLines:
                - FROM seatable/seatable:$$cap_seatable_version
                - EXPOSE 80
                - RUN apt-get -y install expect
                - RUN mkdir -p /shared
                - RUN /etc/my_init.d/01_init.sh
                - ENTRYPOINT /shared/seatable/scripts/seatable.sh init && /shared/seatable/scripts/seatable.sh init-sql && /shared/seatable/scripts/seatable.sh start && /sbin/my_init -- /templates/enterpoint.sh

caproverOneClickApp:
    variables:
        - id: $$cap_seatable_version
          label: SeaTable Version
          defaultValue: 1.8.0
          description: 'Check out their docker page for the valid tags https://hub.docker.com/r/seatable/seatable/tags?page=1&ordering=last_updated'
        - id: $$cap_memcached_version
          label: Memcached Version
          defaultValue: 1.5.6
        - id: $$cap_redis_version
          label: Redis Version
          defaultValue: 5.0.7
        - id: $$cap_mariadb_version
          label: MariaDB Version
          defaultValue: 10.5
        - id: $$cap_mariadb_root_passwd
          label: MariaDB Root Password
          defaultValue: $$cap_gen_random_hex(16)
        - id: $$cap_timezone
          label: Time zone
          defaultValue: Etc/UTC
          description: List of tz database time zones https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

    instructions:
        start: >-
            Simple like Excel, powerful like a database
            SeaTable is the new flexible way for teams to work on tasks, projects or ideas. 
            It looks like Excel, but it has so much more to offer.
            For more info visit https://seatable.io/

            Requirements: SeaTable DE requires 4 cores and 8GB RAM
        end: |-
            SeaTable has been successfully deployed!

            --------------------------------------------

            Before you proceed, please create admin user
            docker exec -it $(docker ps --filter name='srv-captain--$$cap_appname.1' -q) /shared/seatable/scripts/seatable.sh superuser

            --------------------------------------------

            App is available as http://$$cap_appname.$$cap_root_domain
    displayName: SeaTable
    isOfficial: false
    description: >-
        SeaTable is the new flexible way for teams to work on tasks, projects or ideas.
    documentation: >-
        This docker-compose is taken from
        https://manual.seatable.io/docker/Developer-Edition/Deploy%20SeaTable-DE%20with%20Docker/
