captainVersion: 4
services:
    $$cap_appname-postgres:
        image: postgres:$$cap_postgres_version
        volumes:
            - $$cap_appname-postgres-data:/var/lib/postgresql/data
        restart: always
        environment:
            POSTGRES_USER: sentry
            POSTGRES_PASSWORD: $$cap_pg_pass
            POSTGRES_DB: sentry
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname-redis:
        volumes:
            - $$cap_appname-redis-data:/data
        restart: always
        caproverExtra:
            dockerfileLines:
                - FROM redis:$$cap_redis_version
                - CMD exec redis-server
            notExposeAsWebApp: 'true'
    $$cap_appname-cron:
        depends_on:
            - $$cap_appname
        restart: always
        environment:
            SENTRY_SECRET_KEY: $$cap_sentry_secret
            SENTRY_REDIS_HOST: srv-captain--$$cap_appname-redis
        caproverExtra:
            dockerfileLines:
                - FROM sentry:$$cap_sentry_version
                - RUN groupadd -r $$cap_appname-cron && useradd -r -g $$cap_appname-cron $$cap_appname-cron
                - USER $$cap_appname-cron
                - CMD sentry run cron
            notExposeAsWebApp: 'true'
    $$cap_appname-worker:
        depends_on:
            - $$cap_appname-cron
        restart: always
        environment:
            SENTRY_SECRET_KEY: $$cap_sentry_secret
            SENTRY_REDIS_HOST: srv-captain--$$cap_appname-redis
            SENTRY_REDIS_PORT: '6379'
            SENTRY_POSTGRES_HOST: srv-captain--$$cap_appname-postgres
            SENTRY_DB_NAME: sentry
            SENTRY_DB_USER: sentry
            SENTRY_DB_PASSWORD: $$cap_pg_pass
        caproverExtra:
            dockerfileLines:
                - FROM sentry:$$cap_sentry_version
                - RUN groupadd -r $$cap_appname-worker && useradd -r -g $$cap_appname-worker $$cap_appname-worker
                - USER $$cap_appname-worker
                - CMD sentry run worker
            notExposeAsWebApp: 'true'
    $$cap_appname:
        depends_on:
            - $$cap_appname-postgres
            - $$cap_appname-redis
        volumes:
            - $$cap_appname-data:/var/lib/sentry/files
        restart: always
        environment:
            CAP_SENTRY_VERSION: $$cap_sentry_version
            CAP_SENTRY_SUPERUSER_EMAIL: $$cap_sentry_superuser_email
            CAP_SENTRY_SUPERUSER_PASSWORD: $$cap_sentry_superuser_password
            SENTRY_POSTGRES_HOST: srv-captain--$$cap_appname-postgres
            SENTRY_REDIS_HOST: srv-captain--$$cap_appname-redis
            SENTRY_REDIS_PORT: '6379'
            SENTRY_DB_NAME: sentry
            SENTRY_DB_USER: sentry
            SENTRY_DB_PASSWORD: $$cap_pg_pass
            SENTRY_SECRET_KEY: $$cap_sentry_secret
            SENTRY_MAILGUN_API_KEY: $$cap_mailgun_apikey
            SENTRY_SERVER_EMAIL: $$cap_sentry_server_mail
            SENTRY_EMAIL_HOST: $$cap_sentry_email_host
            SENTRY_EMAIL_PORT: $$cap_sentry_email_port
            SENTRY_EMAIL_USER: $$cap_sentry_email_user
            SENTRY_EMAIL_PASSWORD: $$cap_sentry_email_password
            SENTRY_EMAIL_USE_TLS: $$cap_sentry_email_use_tls
        caproverExtra:
            containerHttpPort: '9000'
            dockerfileLines:
                - FROM sentry:$$cap_sentry_version
                - "RUN echo 'auth.allow-registration: false' > /etc/sentry/config.yml"
                - "RUN echo 'beacon.anonymous: true' >> /etc/sentry/config.yml"
                - 'RUN echo ''mail.from: ""'' >> /etc/sentry/config.yml'
                - 'RUN echo ''mail.host: ""'' >> /etc/sentry/config.yml'
                - 'RUN echo ''mail.password: ""'' >> /etc/sentry/config.yml'
                - "RUN echo 'mail.port: 465' >> /etc/sentry/config.yml"
                - "RUN echo 'mail.use-tls: true' >> /etc/sentry/config.yml"
                - 'RUN echo ''mail.username: ""'' >> /etc/sentry/config.yml'
                - 'RUN echo ''system.admin-email: ""'' >> /etc/sentry/config.yml'
                - 'RUN echo ''system.url-prefix: "http://$$cap_appname.$$cap_root_domain"'' >> /etc/sentry/config.yml'
                - RUN echo '#!/bin/bash' >> ./init.sh
                - RUN echo 'echo Starting configuration. The App will restart multiple times.' >> ./init.sh
                - "RUN echo 'echo 1 of 4 : running upgrade' >> ./init.sh"
                - RUN echo 'sentry upgrade --noinput --traceback --no-repair' >> ./init.sh
                - "RUN echo 'echo 2 of 4 : set sentry:version-configured' >> ./init.sh"
                - RUN echo 'sentry config set sentry:version-configured ${CAP_SENTRY_VERSION}' >> ./init.sh
                - "RUN echo 'echo 3 of 4 : creating user' >> ./init.sh"
                - RUN echo 'sentry createuser --email=${CAP_SENTRY_SUPERUSER_EMAIL} --password=${CAP_SENTRY_SUPERUSER_PASSWORD} --superuser --no-input' >> ./init.sh
                - RUN echo 'echo Configuration completed!' >> ./init.sh
                - "RUN echo 'echo 4 of 4 : starting application' >> ./init.sh"
                - RUN echo 'sentry run web' >> ./init.sh
                - RUN chmod +x init.sh
                - RUN groupadd -r $$cap_appname-sentry && useradd -r -g $$cap_appname-sentry $$cap_appname-sentry
                - USER $$cap_appname-sentry
                - CMD ["./init.sh"]
caproverOneClickApp:
    variables:
        - id: $$cap_postgres_version
          label: Postgres Version Tag
          defaultValue: '9.6'
          description: Check out their Docker page for the valid tags https://hub.docker.com/r/library/postgres/tags/
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_redis_version
          label: Redis Version Tag
          description: Check out their Docker page for the valid tags https://hub.docker.com/r/library/redis/tags/
          defaultValue: 3.2-alpine
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_sentry_version
          label: Sentry Version Tag
          description: Check out their Docker page for the valid tags https://hub.docker.com/_/sentry/
          defaultValue: 9.1.0
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_pg_pass
          label: Postgres Password
          description: 'Password strength minimal requeriments: Should contain at least one digit, one lower case, one upper case, one special character and at least 12 from the mentioned characters.'
          validRegex: /^(?=.*[A-Z])(?=.*[/!?@±#§$€%^&*()\\-_=+{}~+´ºª`^"';:,<.>\|\]\[])(?=.*[0-9])(?=.*[a-z]).{12,}$/
        - id: $$cap_sentry_secret
          label: Sentry Secret
          description: 'A secret key used for cryptographic functions within Sentry. This key should be unique and consistent across all running instances. Password strength minimal requeriments: Should contain at least one digit, one lower case, one special character and at least 50 from the mentioned characters. You can generate a new secret key doing something like: docker run --rm sentry config generate-secret-key'
          validRegex: /^(?=.*[/!?@±#§$€%^&*()\\-_=+{}~+´ºª`^"';:,<.>\|\]\[])(?=.*[0-9])(?=.*[a-z]).{50,}$/
        - id: $$cap_sentry_superuser_email
          label: Sentry Superuser Email
          validRegex: /.{1,}/
        - id: $$cap_sentry_superuser_password
          label: Sentry Superuser Password
          description: 'Password strength minimal requeriments: Should contain at least one digit, one lower case, one upper case, one special character and at least 12 from the mentioned characters.'
          validRegex: /^(?=.*[A-Z])(?=.*[/!?@±#§$€%^&*()\\-_=+{}~+´ºª`^"';:,<.>\|\]\[])(?=.*[0-9])(?=.*[a-z]).{12,}$/
        - id: $$cap_sentry_server_mail
          label: Sentry Server Email (optional)
          description: 'The email address used for From: in outbound emails.'
          defaultValue: root@localhost
          validRegex: /.{1,}/
        - id: $$cap_sentry_email_host
          label: SMTP email host (optional)
        - id: $$cap_sentry_email_port
          label: SMTP email port (optional)
          defaultValue: 465
        - id: $$cap_sentry_email_user
          label: SMTP email user (optional)
        - id: $$cap_sentry_email_password
          label: SMTP email password (optional)
        - id: $$cap_sentry_email_use_tls
          label: SMTP use tls (optional)
          defaultValue: true
        - id: $$cap_mailgun_apikey
          label: Mailgun Api key (optional)
          description: If you're using Mailgun for inbound mail, set your API key and configure a route to forward to /api/hooks/mailgun/inbound/
    instructions:
        start: >-
            Open-source error tracking that helps developers monitor and fix crashes in real time.

            Information about this container:
            https://hub.docker.com/_/sentry/ 

            Documentation:
            https://docs.sentry.io/server/

            Minimum Hardware Requirements: At least 3GB Ram

            Not filling this requirement may cause some errors during the initial configuration when running the database migrations.

            Enter your Sentry Configuration parameters and click on next. The initial installation will take about 5 minutes for the process to finish.
        end: >
            Sentry is deployed and available as srv-captain--$$cap_appname:9000. 

            IMPORTANT: It will take up to 10 minutes for Sentry to be ready. Before that, you might see 502 error page.
    displayName: ''
    isOfficial: true
    description: Open-source error tracking with full stacktraces & asynchronous context
    documentation: Taken from https://hub.docker.com/_/sentry/ and https://docs.sentry.io/server/
