caprover / one-click-apps

Community Maintained One Click Apps (https://github.com/caprover/caprover)
Apache License 2.0
557 stars 546 forks source link

App Suggestion: Zammad #491

Closed terehov closed 3 years ago

terehov commented 3 years ago

Please tell us what app you'd like to see on CapRover as a one-click app. Zammad is a web-based, open source user support/ticketing solution.

Do you know if there is any official Docker image for the app? Docker compose: https://hub.docker.com/r/zammad/zammad-docker-compose

I am trying to get it working, and all services seem to be deployed successfully, however it remains at 502. I believe the reason is that the containers are being renamed in CapRover and that's why the communication in between doesn't happen. Any hint would be highly appreciated.

Here are all possible ENVs based on their docs: https://docs.zammad.org/en/latest/install/docker-compose/environment.html

And this is the captain-definition file I've got so far:


captainVersion: 4
caproverOneClickApp:
    instructions:
        start: >-
            Zammad is a web-based, open source user support/ticketing solution.
        end: >
            Zammad is deployed and available. 
             IMPORTANT: It will take up to 5 minutes for Zammad to be ready. Before that, you might see a 502 error page.
    displayName: Zammad
    isOfficial: true
    description: Zammad is a web-based, open source user support/ticketing solution.
    documentation: Taken from https://hub.docker.com/r/zammad/zammad-docker-compose.
    variables:
        - id: $$cap_zammad_version
          label: Zammad Version
          defaultValue: '4.1.0-94'
          description: Check out their docker page for the valid tags https://hub.docker.com/r/zammad/zammad-docker-compose/tags
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_pg_user
          label: PostgreSQL user
          defaultValue: postgresuser
          validRegex: /^([a-zA-Z0-9])+$/
        - id: $$cap_pg_pass
          label: PostgreSQL password
          description: 'PostgreSQL password'
          validRegex: /.{1,}/

services:

  $$cap_appname-backup:
    command: ["zammad-backup"]
    depends_on:
      - $$cap_appname-railsserver
    entrypoint: /usr/local/bin/backup.sh
    environment:
      - BACKUP_SLEEP=86400
      - HOLD_DAYS=10
      - POSTGRESQL_USER=$$cap_db_user
      - POSTGRESQL_PASSWORD=$$cap_db_pass
    image: zammad/zammad-docker-compose:zammad-postgresql-$$cap_zammad_version
    links:
      - $$cap_appname-postgresql
    restart: always
    volumes:
      - $$cap_appname-backup:/var/tmp/zammad
      - $$cap_appname-data:/opt/zammad

  $$cap_appname-elasticsearch:
    environment:
      - discovery.type=single-node
      - ELASTICSEARCH_ENABLED=false
    image: zammad/zammad-docker-compose:zammad-elasticsearch-$$cap_zammad_version
    restart: always
    volumes:
      - $$cap_appname-elasticsearch-data:/usr/share/elasticsearch/data

  $$cap_appname-init:
    command: ["zammad-init"]
    depends_on:
      - $$cap_appname-postgresql
    environment:
      - POSTGRESQL_USER=$$cap_pg_user
      - POSTGRESQL_PASS=$$cap_pg_pass
      - AUTOWIZARD_JSON=""

    image: zammad/zammad-docker-compose:zammad-$$cap_zammad_version
    links:
      - $$cap_appname-elasticsearch
      - $$cap_appname-postgresql
    restart: always
    volumes:
      - $$cap_appname-data:/opt/zammad

  $$cap_appname-memcached:
    command: memcached -m 256M
    image: memcached:1.6.9-alpine
    restart: always

  $$cap_appname-nginx:
    command: ["zammad-nginx"]
    expose:
      - "8080"
    depends_on:
      - $$cap_appname-railsserver
    environment:
        - ZAMMAD_RAILSSERVER_HOST=srv-captain--$$cap_appname-railsserver
        - ZAMMAD_WEBSOCKET_HOST=srv-captain--$$cap_appname-websocket
    image: zammad/zammad-docker-compose:zammad-$$cap_zammad_version
    links:
      - $$cap_appname-railsserver
      - $$cap_appname-websocket
    restart: always
    volumes:
      - $$cap_appname-data:/opt/zammad

  $$cap_appname-postgresql:
    environment:
      - POSTGRESQL_HOST=srv-captain--$$cap_appname-postgresql
      - POSTGRES_USER=$$cap_pg_user
      - POSTGRES_PASSWORD=$$cap_pg_pass
    image: zammad/zammad-docker-compose:zammad-postgresql-$$cap_zammad_version
    restart: always
    volumes:
      - $$cap_appname-postgresql-data:/var/lib/postgresql/data

  $$cap_appname-railsserver:
    command: ["zammad-railsserver"]
    depends_on:
      - $$cap_appname-memcached
      - $$cap_appname-postgresql
    image: zammad/zammad-docker-compose:zammad-$$cap_zammad_version
    links:
      - $$cap_appname-elasticsearch
      - $$cap_appname-memcached
      - $$cap_appname-postgresql
    restart: always
    volumes:
      - $$cap_appname-data:/opt/zammad

  $$cap_appname-scheduler:
    command: ["zammad-scheduler"]
    depends_on:
      - $$cap_appname-memcached
      - $$cap_appname-railsserver
    image: zammad/zammad-docker-compose:zammad-$$cap_zammad_version
    links:
      - $$cap_appname-elasticsearch
      - $$cap_appname-memcached
      - $$cap_appname-postgresql
    restart: always
    volumes:
      - $$cap_appname-data:/opt/zammad

  $$cap_appname-websocket:
    command: ["zammad-websocket"]
    depends_on:
      - $$cap_appname-memcached
      - $$cap_appname-railsserver
    image: zammad/zammad-docker-compose:zammad-$$cap_zammad_version
    links:
      - $$cap_appname-postgresql
      - $$cap_appname-memcached
    restart: always
    volumes:
      - $$cap_appname-data:/opt/zammad

volumes:
  $$cap_appname-elasticsearch-data:
    driver: local
  $$cap_appname-postgresql-data:
    driver: local
  $$cap_appname-backup:
    driver: local
  $$cap_appname-data:
    driver: local
githubsaturn commented 3 years ago

Yes, there are a bunch of env vars with default values that need to be overridden, see here: https://github.com/zammad/zammad-docker-compose/blob/db7ca4b92d2cd3ee23d250c7dcbabbfd408dbf2f/containers/zammad/docker-entrypoint.sh#L5-L31

For example all ELASTICSEARCH_HOST env vars must be set to $$cap_appname-elasticsearch.

Another point is that command is not currently supported in CapRover one click apps. Look at redis definition for a workaround.

terehov commented 3 years ago

Thank you @githubsaturn: Are you sure it's $$cap_appname-elasticsearch? I would guess it should be srv-captain--$$cap_appname-elasticsearch. And by "workaround" you mean running dockerfileLines. I tried to adapt your hints, and it feels like I moved a bit forward. Not quite there yet though. Do you have any more ideas?

captainVersion: 4
caproverOneClickApp:
    instructions:
        start: >-
            Zammad is a web-based, open source user support/ticketing solution.
        end: >
            Zammad is deployed and available. 
             IMPORTANT: It will take up to 5 minutes for Zammad to be ready. Before that, you might see a 502 error page.
    displayName: Zammad
    isOfficial: true
    description: Zammad is a web-based, open source user support/ticketing solution.
    documentation: Taken from https://hub.docker.com/r/zammad/zammad-docker-compose.
    variables:
        - id: $$cap_zammad_VERSION
          label: Zammad Version
          defaultValue: '4.1.0-94'
          description: Check out their docker page for the valid tags https://hub.docker.com/r/zammad/zammad-docker-compose/tags
          validRegex: /^([^\s^\/])+$/

        - id: $$cap_zammad_ELASTICSEARCH_ENABLED
          label: ELASTICSEARCH_ENABLED
          defaultValue: 'true'
          description: Setting this variable to false will allow you to run your Zammad without Elasticsearch. Please note that we strongly advise against doing so.
          validRegex: /^(true|false)$/
        - id: $$cap_zammad_ELASTICSEARCH_HOST
          label: ELASTICSEARCH_HOST
          defaultValue: 'srv-captain--$$cap_appname-elasticsearch'
          description: Provide a host name or address to your external Elasticsearch cluster.
          validRegex: /^([a-zA-Z0-9\-\.\_])+$/
        - id: $$cap_zammad_ELASTICSEARCH_PORT
          label: ELASTICSEARCH_PORT
          defaultValue: '9200'
          description: Provide a different port for Elasticsearch if needed.
          validRegex: /^([0-9])+$/

        - id: $$cap_zammad_MEMCACHED_HOST
          label: MEMCACHED_HOST
          defaultValue: 'srv-captain--$$cap_appname-memcached'
          description: Provide your own Memcached instance if you already have one existing.
          validRegex: /^([a-zA-Z0-9\-\.\_])+$/
        - id: $$cap_zammad_MEMCACHED_PORT
          label: MEMCACHED_PORT
          defaultValue: '11211'
          description: Memcacheds default port.
          validRegex: /^([0-9])+$/

        - id: $$cap_zammad_POSTGRESQL_HOST
          label: POSTGRESQL_HOST
          defaultValue: 'srv-captain--$$cap_appname-postgresql'
          description: Host name of your PostgreSQL server. Use your own if you already have one.
          validRegex: /^([a-zA-Z0-9\-\.\_])+$/
        - id: $$cap_zammad_POSTGRESQL_PORT
          label: POSTGRESQL_PORT
          defaultValue: '5432'
          description: Adjust the Port of your PostgreSQL server.
          validRegex: /^([0-9])+$/
        - id: $$cap_zammad_POSTGRESQL_USER
          label: POSTGRESQL_USER
          defaultValue: postgresuser
          validRegex: /^([a-zA-Z0-9\-\.\_])+$/
        - id: $$cap_zammad_POSTGRESQL_PASS
          label: POSTGRESQL_PASS
          defaultValue: $$cap_gen_random_hex(10)
          description: 'The password of Zammads database user.'
          validRegex: /.{1,}/
        - id: $$cap_zammad_POSTGRESQL_DB
          label: POSTGRESQL_DB
          defaultValue: zammad_production
          validRegex: /^([a-zA-Z0-9\-\.\_])+$/
        - id: $$cap_zammad_POSTGRESQL_CREATEDB
          label: POSTGRESQL_DB_CREATE
          defaultValue: 'true'
          description: By default we will create the required database.
          validRegex: /^(true|false)$/

        - id: $$cap_zammad_RAILS_TRUSTED_PROXIES
          label: RAILS_TRUSTED_PROXIES
          description: By default Zammad trusts localhost proxies only. ⚠ Only change this option if you know what you’re doing! ⚠
          defaultValue: "['127.0.0.1', '::1']"
        - id: $$cap_zammad_ZAMMAD_RAILSSERVER_HOST
          label: ZAMMAD_RAILSSERVER_HOST
          defaultValue: 'srv-captain--$$cap_appname-railsserver'
          description: Host name of the rails server container.
          validRegex: /^([a-zA-Z0-9\-\.\_])+$/
        - id: $$cap_zammad_ZAMMAD_RAILSSERVER_PORT
          label: ZAMMAD_RAILSSERVER_PORT
          defaultValue: '3000'
          description: Port of Zammads rails server.
          validRegex: /^([0-9])+$/

        - id: $$cap_zammad_ZAMMAD_WEBSOCKET_HOST
          label: ZAMMAD_WEBSOCKET_HOST
          defaultValue: 'srv-captain--$$cap_appname-websocket'
          description: Host name of Zammads websocket server.
          validRegex: /^([a-zA-Z0-9\-\.\_])+$/
        - id: $$cap_zammad_ZAMMAD_WEBSOCKET_PORT
          label: ZAMMAD_WEBSOCKET_PORT
          defaultValue: '6042'
          description: Port of Zammads websocket server.
          validRegex: /^([0-9])+$/

services:

  $$cap_appname-backup:
    restart: always
    depends_on:
      - $$cap_appname-railsserver
    entrypoint: /usr/local/bin/backup.sh
    environment:
      BACKUP_SLEEP: 86400
      HOLD_DAYS: 10
      POSTGRESQL_HOST: $$cap_zammad_POSTGRESQL_HOST
      POSTGRESQL_PORT: $$cap_zammad_POSTGRESQL_PORT
      POSTGRESQL_USER: $$cap_zammad_POSTGRESQL_USER
      POSTGRESQL_PASS: $$cap_zammad_POSTGRESQL_PASS
      POSTGRESQL_DB: $$cap_zammad_POSTGRESQL_DB
    links:
      - $$cap_appname-postgresql
    volumes:
      - $$cap_appname-backup:/var/tmp/zammad
      - $$cap_appname-data:/opt/zammad
    caproverExtra:
      notExposeAsWebApp: true
      dockerfileLines:
          - FROM zammad/zammad-docker-compose:zammad-postgresql-$$cap_zammad_VERSION
          - CMD exec ./zammad-backup.sh

  $$cap_appname-elasticsearch:
    restart: always
    image: zammad/zammad-docker-compose:zammad-elasticsearch-$$cap_zammad_VERSION
    environment:
      discovery.type: single-node
    volumes:
      - $$cap_appname-elasticsearch-data:/usr/share/elasticsearch/data
    caproverExtra:
      notExposeAsWebApp: true

  $$cap_appname-init:
    restart: always
    depends_on:
      - $$cap_appname-postgresql
    environment:
      AUTOWIZARD_JSON: ''
      ELASTICSEARCH_ENABLED: $$cap_zammad_ELASTICSEARCH_ENABLED
      ELASTICSEARCH_HOST: $$cap_zammad_ELASTICSEARCH_HOST
      ELASTICSEARCH_PORT: $$cap_zammad_ELASTICSEARCH_PORT
      ELASTICSEARCH_SCHEMA: http
      ELASTICSEARCH_NAMESPACE: zammad
      ELASTICSEARCH_REINDEX: true
      ELASTICSEARCH_SSL_VERIFY: true
      MEMCACHED_HOST: $$cap_zammad_MEMCACHED_HOST
      MEMCACHED_PORT: $$cap_zammad_MEMCACHED_PORT
      NGINX_PORT: 8080
      NGINX_SERVER_NAME: _
      NGINX_SERVER_SCHEME: \$scheme
      POSTGRESQL_HOST: $$cap_zammad_POSTGRESQL_HOST
      POSTGRESQL_PORT: $$cap_zammad_POSTGRESQL_PORT
      POSTGRESQL_USER: $$cap_zammad_POSTGRESQL_USER
      POSTGRESQL_PASS: $$cap_zammad_POSTGRESQL_PASS
      POSTGRESQL_DB: $$cap_zammad_POSTGRESQL_DB
      POSTGRESQL_DB_CREATE: $$cap_zammad_POSTGRESQL_CREATEDB
      RAILS_TRUSTED_PROXIES: $$cap_zammad_RAILS_TRUSTED_PROXIES
      RSYNC_ADDITIONAL_PARAMS: --no-perms --no-owner
      ZAMMAD_RAILSSERVER_HOST: $$cap_zammad_ZAMMAD_RAILSSERVER_HOST
      ZAMMAD_RAILSSERVER_PORT: $$cap_zammad_ZAMMAD_RAILSSERVER_PORT
      ZAMMAD_WEBSOCKET_HOST: $$cap_zammad_ZAMMAD_WEBSOCKET_HOST
      ZAMMAD_WEBSOCKET_PORT: $$cap_zammad_ZAMMAD_WEBSOCKET_PORT
    links:
      - $$cap_appname-elasticsearch
      - $$cap_appname-postgresql
    volumes:
      - $$cap_appname-data:/opt/zammad
    caproverExtra:
      notExposeAsWebApp: true
      dockerfileLines:
          - FROM zammad/zammad-docker-compose:zammad-$$cap_zammad_VERSION
          - CMD exec zammad-init

  $$cap_appname-memcached:
    restart: always
    caproverExtra:
      notExposeAsWebApp: true
      dockerfileLines:
          - FROM memcached:1.6.9-alpine
          - CMD exec memcached -m 256M

  $$cap_appname-nginx:
    expose:
      - "8080"
    containerHttpPort: 8080
    depends_on:
      - $$cap_appname-railsserver
    links:
      - $$cap_appname-railsserver
      - $$cap_appname-websocket
    restart: always
    volumes:
      - $$cap_appname-data:/opt/zammad
    caproverExtra:
      notExposeAsWebApp: false
      dockerfileLines:
          - FROM zammad/zammad-docker-compose:zammad-$$cap_zammad_VERSION
          - CMD exec zammad-nginx

  $$cap_appname-postgresql:
    environment:
      POSTGRES_PORT: $$cap_zammad_POSTGRESQL_PORT
      POSTGRES_USER: $$cap_zammad_POSTGRESQL_USER
      POSTGRES_PASSWORD: $$cap_zammad_POSTGRESQL_PASS
    image: zammad/zammad-docker-compose:zammad-postgresql-$$cap_zammad_VERSION
    restart: always
    volumes:
      - $$cap_appname-postgresql-data:/var/lib/postgresql/data
    caproverExtra:
      notExposeAsWebApp: true

  $$cap_appname-railsserver:
    depends_on:
      - $$cap_appname-memcached
      - $$cap_appname-postgresql
    links:
      - $$cap_appname-elasticsearch
      - $$cap_appname-memcached
      - $$cap_appname-postgresql
    restart: always
    volumes:
      - $$cap_appname-data:/opt/zammad
    caproverExtra:
      notExposeAsWebApp: true
      dockerfileLines:
        - FROM zammad/zammad-docker-compose:zammad-$$cap_zammad_VERSION
        - CMD exec zammad-railsserver

  $$cap_appname-scheduler:
    depends_on:
      - $$cap_appname-memcached
      - $$cap_appname-railsserver 
    links:
      - $$cap_appname-elasticsearch
      - $$cap_appname-memcached
      - $$cap_appname-postgresql
    restart: always
    volumes:
      - $$cap_appname-data:/opt/zammad
    caproverExtra:
      notExposeAsWebApp: true
      dockerfileLines:
        - FROM zammad/zammad-docker-compose:zammad-$$cap_zammad_VERSION
        - CMD exec zammad-scheduler

  $$cap_appname-websocket:
    depends_on:
      - $$cap_appname-memcached
      - $$cap_appname-railsserver
    links:
      - $$cap_appname-postgresql
      - $$cap_appname-memcached
    restart: always
    volumes:
      - $$cap_appname-data:/opt/zammad
    caproverExtra:
      notExposeAsWebApp: false
      dockerfileLines:
          - FROM zammad/zammad-docker-compose:zammad-$$cap_zammad_VERSION
          - CMD exec zammad-websocket

volumes:
  $$cap_appname-elasticsearch-data:
    driver: local
  $$cap_appname-postgresql-data:
    driver: local
  $$cap_appname-backup:
    driver: local
  $$cap_appname-data:
    driver: local
githubsaturn commented 3 years ago

This a tad complex for me to debug without knowing what is wrong.

Anything specific about this? What is the issue that you're currently facing?

terehov commented 3 years ago

Thank you for your reply. Well, the problem remains the same.

I did (based on the Redis repo):

caproverExtra:
      dockerfileLines:
          - FROM zammad/zammad-docker-compose:zammad-postgresql-$$cap_zammad_VERSION
          - CMD exec ./zammad-backup.sh

However, it doesn't seem to start the container. I checked other one-click repos as well as the docs, but couldn't find much about it. Any idea here?

Thanks!

githubsaturn commented 3 years ago

Question 1: You are correct.

Question 2: Try this:

          - FROM zammad/zammad-docker-compose:zammad-postgresql-$$cap_zammad_VERSION
          - CMD ./zammad-backup.sh

exec shouldn't be needed.

VeselaHouba commented 3 years ago

I think you are mixing entrypoint and cmd here. As @mgruner mentioned in https://github.com/zammad/zammad-docker-compose/issues/236 - the "zammad-backup" is not command name, but parameter passed to entrypoint /usr/local/bin/backup.sh So you should be able to do something like:

          - FROM zammad/zammad-docker-compose:zammad-postgresql-$$cap_zammad_VERSION
          - ENTRYPOINT /usr/local/bin/backup.sh
          - CMD zammad-backup
VeselaHouba commented 3 years ago

First working result I've removed all hostname references from variables. It can be re-added as needed, just wanted to make the template as simple as possible for debugging. The CMD is not actually passed to container as normal docker would do, but CapRover wraps it with /bin/sh -c which breaks the entrypoint-command system Zammad is using in their containers. Worked around with

        - FROM zammad/zammad-docker-compose:zammad-$$cap_zammad_VERSION
        - ENTRYPOINT []
        - CMD /docker-entrypoint.sh zammad-<function>

What is currently broken: The init container is created over and over. The restart should be set to on-failure, but according to https://github.com/caprover/one-click-apps the restart directive is ignored. This prevents nginx from starting up (container is waiting for /var/lib/docker/volumes/captain--<app_name>-data/_data/tmp/zammad.ready). You can manually delete init app after init phase is finished and create the file manually. There is probably some elegant way to fix this :)

I've also removed directives like links which are also ignored according to docu, changed expose to port, added few variables where needed etc. This definitely needs more time for testing and probably fixing.

Anyway my template is following:

captainVersion: 4
caproverOneClickApp:
    instructions:
        start: >-
            Zammad is a web-based, open source user support/ticketing solution.
        end: >
            Zammad is deployed and available.
             IMPORTANT: It will take up to 5 minutes for Zammad to be ready. Before that, you might see a 502 error page.
    displayName: Zammad
    isOfficial: true
    description: Zammad is a web-based, open source user support/ticketing solution.
    documentation: Taken from https://hub.docker.com/r/zammad/zammad-docker-compose.
    variables:
        - id: $$cap_zammad_VERSION
          label: Zammad Version
          defaultValue: '4.1.0-94'
          description: Check out their docker page for the valid tags https://hub.docker.com/r/zammad/zammad-docker-compose/tags
          validRegex: /^([^\s^\/])+$/

        - id: $$cap_zammad_ELASTICSEARCH_ENABLED
          label: ELASTICSEARCH_ENABLED
          defaultValue: 'true'
          description: Setting this variable to false will allow you to run your Zammad without Elasticsearch. Please note that we strongly advise against doing so.
          validRegex: /^(true|false)$/

        - id: $$cap_zammad_POSTGRESQL_USER
          label: POSTGRESQL_USER
          defaultValue: postgresuser
          validRegex: /^([a-zA-Z0-9\-\.\_])+$/

        - id: $$cap_zammad_POSTGRESQL_PASS
          label: POSTGRESQL_PASS
          defaultValue: $$cap_gen_random_hex(10)
          description: 'The password of Zammads database user.'
          validRegex: /.{1,}/

        - id: $$cap_zammad_POSTGRESQL_DB
          label: POSTGRESQL_DB
          defaultValue: zammad_production
          validRegex: /^([a-zA-Z0-9\-\.\_])+$/

        - id: $$cap_zammad_POSTGRESQL_CREATEDB
          label: POSTGRESQL_DB_CREATE
          defaultValue: 'true'
          description: By default we will create the required database.
          validRegex: /^(true|false)$/

        - id: $$cap_zammad_RAILS_TRUSTED_PROXIES
          label: RAILS_TRUSTED_PROXIES
          description: By default Zammad trusts localhost proxies only. ⚠ Only change this option if you know what you’re doing! ⚠
          defaultValue: "['127.0.0.1', '::1']"

services:

  $$cap_appname-backup:
    restart: always
    depends_on:
      - $$cap_appname-railsserver
    environment:
      BACKUP_SLEEP: 86400
      HOLD_DAYS: 10
      POSTGRESQL_HOST: srv-captain--$$cap_appname-postgresql
      POSTGRESQL_PORT: 5432
      POSTGRESQL_USER: $$cap_zammad_POSTGRESQL_USER
      POSTGRESQL_PASSWORD: $$cap_zammad_POSTGRESQL_PASS
      POSTGRESQL_DB: $$cap_zammad_POSTGRESQL_DB
      ZAMMAD_RAILSSERVER_HOST: srv-captain--$$cap_appname-railsserver
      ZAMMAD_RAILSSERVER_PORT: 3000
    volumes:
      - $$cap_appname-backup:/var/tmp/zammad
      - $$cap_appname-data:/opt/zammad
    caproverExtra:
      notExposeAsWebApp: true
      dockerfileLines:
          - FROM zammad/zammad-docker-compose:zammad-postgresql-$$cap_zammad_VERSION
          - ENTRYPOINT []
          - CMD /usr/local/bin/backup.sh zammad-backup

  $$cap_appname-elasticsearch:
    restart: always
    image: zammad/zammad-docker-compose:zammad-elasticsearch-$$cap_zammad_VERSION
    environment:
      discovery.type: single-node
    volumes:
      - $$cap_appname-elasticsearch-data:/usr/share/elasticsearch/data
    caproverExtra:
      notExposeAsWebApp: true

  $$cap_appname-init:
    restart: on-failure
    depends_on:
      - $$cap_appname-postgresql
    environment:
      AUTOWIZARD_JSON: ''
      ELASTICSEARCH_ENABLED: $$cap_zammad_ELASTICSEARCH_ENABLED
      ELASTICSEARCH_HOST: srv-captain--$$cap_appname-elasticsearch
      ELASTICSEARCH_PORT: 9200
      ELASTICSEARCH_SCHEMA: http
      ELASTICSEARCH_NAMESPACE: zammad
      ELASTICSEARCH_REINDEX: true
      ELASTICSEARCH_SSL_VERIFY: true
      MEMCACHED_HOST: srv-captain--$$cap_appname-memcached
      MEMCACHED_PORT: 11211
      NGINX_PORT: 8080
      NGINX_SERVER_NAME: _
      NGINX_SERVER_SCHEME: \$scheme
      POSTGRESQL_HOST: srv-captain--$$cap_appname-postgresql
      POSTGRESQL_PORT: 5432
      POSTGRESQL_USER: $$cap_zammad_POSTGRESQL_USER
      POSTGRESQL_PASS: $$cap_zammad_POSTGRESQL_PASS
      POSTGRESQL_DB: $$cap_zammad_POSTGRESQL_DB
      POSTGRESQL_DB_CREATE: $$cap_zammad_POSTGRESQL_CREATEDB
      RAILS_TRUSTED_PROXIES: $$cap_zammad_RAILS_TRUSTED_PROXIES
      RSYNC_ADDITIONAL_PARAMS: --no-perms --no-owner
      ZAMMAD_RAILSSERVER_HOST: srv-captain--$$cap_appname-railsserver
      ZAMMAD_RAILSSERVER_PORT: 3000
      ZAMMAD_WEBSOCKET_HOST: srv-captain--$$cap_appname-websocket
      ZAMMAD_WEBSOCKET_PORT: 6042
    volumes:
      - $$cap_appname-data:/opt/zammad
    caproverExtra:
      notExposeAsWebApp: true
      dockerfileLines:
        - FROM zammad/zammad-docker-compose:zammad-$$cap_zammad_VERSION
        - ENTRYPOINT []
        - CMD /docker-entrypoint.sh zammad-init

  $$cap_appname-memcached:
    restart: always
    caproverExtra:
      notExposeAsWebApp: true
      dockerfileLines:
        - FROM memcached:1.6.10-alpine
        - CMD memcached -m 256M

  $$cap_appname-nginx:
    ports:
      - "8080:8080"
    depends_on:
      - $$cap_appname-railsserver
    environment:
      ZAMMAD_RAILSSERVER_HOST: srv-captain--$$cap_appname-railsserver
      ZAMMAD_RAILSSERVER_PORT: 3000
      ZAMMAD_WEBSOCKET_HOST: srv-captain--$$cap_appname-websocket
      ZAMMAD_WEBSOCKET_PORT: 6042
    restart: always
    volumes:
      - $$cap_appname-data:/opt/zammad
    caproverExtra:
      notExposeAsWebApp: false
      containerHttpPort: 8080
      dockerfileLines:
        - FROM zammad/zammad-docker-compose:zammad-$$cap_zammad_VERSION
        - ENTRYPOINT []
        - CMD /docker-entrypoint.sh zammad-nginx

  $$cap_appname-postgresql:
    environment:
      POSTGRES_PORT: 5432
      POSTGRES_USER: $$cap_zammad_POSTGRESQL_USER
      POSTGRES_PASSWORD: $$cap_zammad_POSTGRESQL_PASS
    image: zammad/zammad-docker-compose:zammad-postgresql-$$cap_zammad_VERSION
    restart: always
    volumes:
      - $$cap_appname-postgresql-data:/var/lib/postgresql/data
    caproverExtra:
      notExposeAsWebApp: true

  $$cap_appname-railsserver:
    depends_on:
      - $$cap_appname-memcached
      - $$cap_appname-postgresql
    environment:
      ZAMMAD_RAILSSERVER_PORT: 3000
    restart: always
    volumes:
      - $$cap_appname-data:/opt/zammad
    caproverExtra:
      notExposeAsWebApp: true
      dockerfileLines:
        - FROM zammad/zammad-docker-compose:zammad-$$cap_zammad_VERSION
        - ENTRYPOINT []
        - CMD /docker-entrypoint.sh zammad-railsserver

  $$cap_appname-scheduler:
    depends_on:
      - $$cap_appname-memcached
      - $$cap_appname-railsserver
    restart: always
    volumes:
      - $$cap_appname-data:/opt/zammad
    caproverExtra:
      notExposeAsWebApp: true
      dockerfileLines:
        - FROM zammad/zammad-docker-compose:zammad-$$cap_zammad_VERSION
        - ENTRYPOINT []
        - CMD /docker-entrypoint.sh zammad-scheduler

  $$cap_appname-websocket:
    depends_on:
      - $$cap_appname-memcached
      - $$cap_appname-railsserver
    environment:
      ZAMMAD_WEBSOCKET_PORT: 6042
    restart: always
    volumes:
      - $$cap_appname-data:/opt/zammad
    caproverExtra:
      notExposeAsWebApp: false
      dockerfileLines:
        - FROM zammad/zammad-docker-compose:zammad-$$cap_zammad_VERSION
        - ENTRYPOINT []
        - CMD /docker-entrypoint.sh zammad-websocket

volumes:
  $$cap_appname-elasticsearch-data:
    driver: local
  $$cap_appname-postgresql-data:
    driver: local
  $$cap_appname-backup:
    driver: local
  $$cap_appname-data:
    driver: local
VeselaHouba commented 3 years ago

Not perfect, but works

- CMD /docker-entrypoint.sh zammad-init && tail -f /dev/null

Also updated default version to

defaultValue: '5.0.1-5'

which matches current state of https://github.com/zammad/zammad-docker-compose/blob/master/.env I'll send PR soon.

VeselaHouba commented 3 years ago

also someone could find this useful for dropping testing instances :)

#!/usr/bin/env bash
APPNAME="zammad-03"

function drop {
  app="${1}"
  volumes="${2}"
  echo "Deleting ${app}"
  JSON='{ "appName": "'"${app}"'", "volumes":['"${volumes}"'] }'
  caprover api \
    --caproverName captain-01 \
    -m POST \
    -t /user/apps/appDefinitions/delete \
    -d "${JSON}"
}

drop "${APPNAME}-init" ''
drop "${APPNAME}-websocket" ''
drop "${APPNAME}-scheduler" ''
drop "${APPNAME}-railsserver" ''
drop "${APPNAME}-nginx" ''
drop "${APPNAME}-memcached" ''
drop "${APPNAME}-postgresql" '"'"${APPNAME}"'-postgresql-data"'
drop "${APPNAME}-elasticsearch" '"'"${APPNAME}"'-elasticsearch-data"'
# volume zammad-data is used by multiple services -> wait until teardown
sleep 30
drop "${APPNAME}-backup" '"'"${APPNAME}"'-data","'"${APPNAME}"'-backup"'
terehov commented 2 years ago

Thank you so much @andrekutianski !

I have installed and it works fine... until I log out and try to log back in. This is where I keep running into "CSRF token verification failed!" Apparently, it's connected to NGINX_SERVER_SCHEME: \$scheme.

Did you happen to run into a similar problem? How did you solve it?

deletosh commented 2 years ago

For future seachers, here's the fix:

Login to to your CapRover console

  1. Go into the zammad-init > App Configs container, change the NGINX_SERVER_SCHEME environment variables to "https", click Save & Update

  2. Go to the zammad-nginx, click Save & Update

  3. Go to the zammad-railsserver, click Save & Update

After a few minutes, it should be resolved.

cc @terehov

MeetChaudhari commented 2 months ago

Hello Guys, I am facing a issue, i have zammad up and running on my caprover instance for last 6 months , now i want to update it to latest version of zammad , without loosing the data, i am not able to figure out how can i do it , can anybody help ?, please.