name: wekan
version: '6.21'
base: core20
summary: Open Source kanban
description: |
   WeKan ® is an Open Source and collaborative kanban board application.

   Whether you’re maintaining a personal todo list, planning your holidays with some friends, or working in a team on your next revolutionary idea, Kanban boards are an unbeatable tool to keep your things organized. They give you a visual overview of the current state of your project, and make you productive by allowing you to focus on the few items that matter the most.
   Depending on target environment, some configuration settings might need to be adjusted.
   For full list of configuration options call:
   $ wekan.help

confinement: strict
grade: stable

architectures:
  - build-on: amd64
    run-on: amd64

  - build-on: arm64
    run-on: arm64

  - build-on: ppc64el
    run-on: ppc64el

  - build-on: s390x
    run-on: s390x

plugs:
  mongodb-plug:
    interface: content
    target: $SNAP_DATA/shared

hooks:
  configure:
    plugs:
      - network
      - network-bind

slots:
  mongodb-slot:
    interface: content
    write:
      - $SNAP_DATA/share

apps:
    wekan:
        command: wekan-control
        daemon: simple
        plugs: [network, network-bind, mount-observe, system-observe, bluetooth-control]
        restart-condition: on-failure

    mongodb:
        command: mongodb-control
        daemon: simple
        plugs: [network, network-bind, mount-observe, system-observe, bluetooth-control]
        restart-condition: on-failure

    caddy:
        command: caddy-control
        daemon: simple
        plugs: [network, network-bind]

    help:
        command: wekan-help

    database-backup:
        command: mongodb-backup
        plugs: [network, network-bind, mount-observe, system-observe, bluetooth-control]

    database-list-backups:
        command: ls -al $SNAP_COMMON/db-backups/

    database-restore:
        command: mongodb-restore
        plugs: [network, network-bind, mount-observe, system-observe, bluetooth-control]

parts:
    mongodb:
        plugin: dump
        source:
          - on amd64: https://repo.mongodb.org/apt/ubuntu/dists/focal/mongodb-org/4.4/multiverse/binary-amd64/mongodb-org-server_4.4.13_amd64.deb
          - on arm64: https://repo.mongodb.org/apt/ubuntu/dists/focal/mongodb-org/4.4/multiverse/binary-arm64/mongodb-org-server_4.4.13_arm64.deb
          - on ppc64el: https://repo.mongodb.org/apt/ubuntu/dists/focal/mongodb-org/4.4/multiverse/binary-ppc64el/mongodb-org-server_4.4.13_ppc64el.deb
          - on s390x: https://repo.mongodb.org/apt/ubuntu/dists/focal/mongodb-org/4.4/multiverse/binary-s390x/mongodb-org-server_4.4.13_s390x.deb
        stage-packages:
            - libssl1.1
            - libcurl3-dev
            - libcurl4-openssl-dev
        filesets:
            mongo:
                - usr
                - bin
                - lib
        stage:
            - $mongo
        prime:
            - $mongo

    wekan:
        #plugin: npm
        plugin: dump
        source:
        # Fixed URLs to some allowed GitHub releases URL.
        # Non-GitHub build server file urls are not allowed at 2022-03-02 and later.
          - on amd64: https://github.com/wekan/wekan/releases/download/v6.20/wekan-6.20-amd64.zip
          - on arm64: https://github.com/wekan/wekan/releases/download/v6.20/wekan-6.20-arm64.zip
          - on ppc64el: https://github.com/wekan/wekan/releases/download/v6.20/wekan-6.20-ppc64el.zip
          - on s390x: https://github.com/wekan/wekan/releases/download/v6.20/wekan-6.20-s390x.zip
#        npm-node-version: 14.19.1
#        node-packages:
#            - node-gyp
#            - node-pre-gyp
#            - fibers
#        build-packages:
#          - npm
#            - build-essential
#            - ca-certificates
#            - apt-utils
#            - python
#            - python3
#            - g++
#            - capnproto
#            - curl
#            - execstack
#            - nodejs
#            - npm
#          - p7zip-full
#        stage-packages:
#            - libfontconfig1
        override-build: |
          cp -r bundle/* $SNAPCRAFT_PART_INSTALL/
          cp bundle/.node_version.txt $SNAPCRAFT_PART_INSTALL/
          rm -f $SNAPCRAFT_PART_INSTALL/lib/node_modules/wekan
          snapcraftctl build
        organize:
            README: README.wekan
        prime:
            - -lib/node_modules/node-pre-gyp/node_modules/tar/lib/.unpack.js.swp
            - -lib/node_modules/weka*

    helpers:
        source: snap-src
        plugin: dump

    caddy:
        plugin: dump
        ## Caddy v1 is not developed anymore. TODO: Sometime migrate to Caddy v2.
        ## https://caddy.community/t/caddyfile-v1-adapter/9129
        ## https://github.com/caddyserver/caddy/tree/v1
        #source: https://caddyserver.com/download/linux/amd64?license=personal&telemetry=off
        #source-type: tar
        # Using last working binary that was downloaded from above URL to Wekan Snap,
        # and .txt files from https://github.com/caddyserver/caddy/tree/v1/dist
        source: https://wekan.github.io/caddy-v1-linux-amd64.7z
        source-type: 7z
        organize:
          caddy: bin/caddy
          CHANGES.txt: CADDY_CHANGES.txt
          EULA.txt: CADDY_EULA.txt
          LICENSES.txt: CADDY_LICENSES.txt
          README.txt: CADDY_README.txt
        stage:
          - -init

    caddy2:
        plugin: dump
        source:
        # Fixed URLs to some allowed GitHub releases URL.
        # Non-GitHub build server file urls are not allowed at 2022-03-02 and later.
          - on amd64: https://github.com/wekan/wekan/releases/download/v6.20/caddy-v2-amd64.zip
          - on arm64: https://github.com/wekan/wekan/releases/download/v6.20/caddy-v2-arm64.zip
          - on ppc64el: https://github.com/wekan/wekan/releases/download/v6.20/caddy-v2-ppc64el.zip
          - on s390x: https://github.com/wekan/wekan/releases/download/v6.20/caddy-v2-s390x.zip
        source-type: zip
        organize:
          caddy: bin/caddy
          CHANGES.txt: CADDY_CHANGES.txt
          EULA.txt: CADDY_EULA.txt
          LICENSES.txt: CADDY_LICENSES.txt
          README.txt: CADDY_README.txt
        stage:
          - -init
