Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I managed to run Appwrite on the [balena ecosystem](https://www.balena.io/what-is-balena/) (balenaOS + balenaCloud) with some modifications. #1444

Closed
Oat2538 opened this issue Jul 28, 2021 · 3 comments

Comments

@Oat2538
Copy link

Oat2538 commented Jul 28, 2021

I managed to run Appwrite on the balena ecosystem (balenaOS + balenaCloud) with some modifications.
Here are my findings:

First things first

Checkout the ARM branch:

git clone https://github.com/appwrite/appwrite
cd appwrite
git checkout feat-465-add-arm-support

Fixing what's broken

Multiple issues arise when trying to balena deploy to balenaCloud:

Docker compose version 3 is unsupported

Simple fix, doesn't seem like Appwrite depends on any v3 features

# docker-compose.yml
@@ -4,7 +4,7 @@
 # We're exposing here sensetive ports and mounting code volumes for rapid development and debugging of the server stack.
 # For a production ready compose file please use: https://appwrite.io/docker-compose.yml

-version: '3'
+version: '2'

 services:
   traefik:

Bind mounts are disallowed

Current bind mounts are either the docker daemon or development mounts. All can be commented out, docker daemon can be mounted using a balena-specific service label io.balena.features.balena-socket:

docker-compose.yml diff
# docker-compose.yml
@@ -21,12 +21,13 @@ services:
       - --entrypoints.web.address=:80
       - --entrypoints.websecure.address=:443
       - --accesslog=true
+      - --providers.docker.endpoint=unix:https:///var/run/balena-engine.sock
     ports:
       - 80:80
       - 443:443
       - 9500:8080
     volumes:
-      - /var/run/docker.sock:/var/run/docker.sock
+      # - /var/run/docker.sock:/var/run/docker.sock
       - appwrite-config:/storage/config:ro
       - appwrite-certificates:/storage/certificates:ro
     depends_on:
@@ -34,44 +35,47 @@ services:
     networks:
       - gateway
       - appwrite
+    labels:
+      - io.balena.features.balena-socket=1

   appwrite:
     container_name: appwrite
     build:
       context: .
-      args:
-        - TESTING=true
-        - VERSION=dev
+      # args:
+      #   - TESTING=true
+      #   - VERSION=dev
     ports:
       - 9501:80
     networks:
       - appwrite
     labels:
+      - io.balena.features.balena-socket=1
       - traefik.enable=true
       - traefik.constraint-label-stack=appwrite
       - traefik.http.routers.appwrite.rule=PathPrefix(`/`)
       - traefik.http.routers.appwrite-secure.rule=PathPrefix(`/`)
       - traefik.http.routers.appwrite-secure.tls=true
     volumes:
-      - /var/run/docker.sock:/var/run/docker.sock
+      # - /var/run/docker.sock:/var/run/docker.sock
       - appwrite-uploads:/storage/uploads:rw
       - appwrite-cache:/storage/cache:rw
       - appwrite-config:/storage/config:rw
       - appwrite-certificates:/storage/certificates:rw
       - appwrite-functions:/storage/functions:rw
-      - ./phpunit.xml:/usr/src/code/phpunit.xml
-      - ./psalm.xml:/usr/src/code/psalm.xml
-      - ./tests:/usr/src/code/tests
-      - ./app:/usr/src/code/app
+      # - ./phpunit.xml:/usr/src/code/phpunit.xml
+      # - ./psalm.xml:/usr/src/code/psalm.xml
+      # - ./tests:/usr/src/code/tests
+      # - ./app:/usr/src/code/app
       # - ./vendor:/usr/src/code/vendor
-      - ./docs:/usr/src/code/docs
-      - ./public:/usr/src/code/public
-      - ./src:/usr/src/code/src
-      - ./debug:/tmp
+      # - ./docs:/usr/src/code/docs
+      # - ./public:/usr/src/code/public
+      # - ./src:/usr/src/code/src
+      # - ./debug:/tmp
     depends_on:
       - mariadb
       - redis
-      - clamav
+      # - clamav
       - influxdb
     environment:
       - _APP_ENV
@@ -119,9 +123,9 @@ services:
       context: .
     networks:
       - appwrite
-    volumes:
-      - ./app:/usr/src/code/app
-      - ./src:/usr/src/code/src
+    # volumes:
+      # - ./app:/usr/src/code/app
+      # - ./src:/usr/src/code/src
     depends_on:
       - redis
       - telegraf
@@ -141,9 +145,9 @@ services:
       context: .
     networks:
       - appwrite
-    volumes:
-      - ./app:/usr/src/code/app
-      - ./src:/usr/src/code/src
+    # volumes:
+      # - ./app:/usr/src/code/app
+      # - ./src:/usr/src/code/src
     depends_on:
       - redis
       - mariadb
@@ -166,9 +170,9 @@ services:
       context: .
     networks:
       - appwrite
-    volumes:
-      - ./app:/usr/src/code/app
-      - ./src:/usr/src/code/src
+    # volumes:
+      # - ./app:/usr/src/code/app
+      # - ./src:/usr/src/code/src
     depends_on:
       - redis
       - mariadb
@@ -193,9 +197,9 @@ services:
       context: .
     networks:
       - appwrite
-    volumes:
-      - ./app:/usr/src/code/app
-      - ./src:/usr/src/code/src
+    # volumes:
+      # - ./app:/usr/src/code/app
+      # - ./src:/usr/src/code/src
     depends_on:
       - redis
       - mariadb
@@ -224,8 +228,8 @@ services:
       - appwrite-cache:/storage/cache:rw
       - appwrite-functions:/storage/functions:rw
       - appwrite-certificates:/storage/certificates:rw
-      - ./app:/usr/src/code/app
-      - ./src:/usr/src/code/src
+      # - ./app:/usr/src/code/app
+      # - ./src:/usr/src/code/src
     depends_on:
       - redis
       - mariadb
@@ -251,8 +255,8 @@ services:
     volumes:
       - appwrite-config:/storage/config:rw
       - appwrite-certificates:/storage/certificates:rw
-      - ./app:/usr/src/code/app
-      - ./src:/usr/src/code/src
+      # - ./app:/usr/src/code/app
+      # - ./src:/usr/src/code/src
     depends_on:
       - redis
       - mariadb
@@ -277,15 +281,17 @@ services:
     networks:
       - appwrite
     volumes:
-      - /var/run/docker.sock:/var/run/docker.sock
+      # - /var/run/docker.sock:/var/run/docker.sock
       - appwrite-functions:/storage/functions:rw
-      - /tmp:/tmp:rw
-      - ./app:/usr/src/code/app
-      - ./src:/usr/src/code/src
-      - ./docker:/usr/src/code/docker
+      # - /tmp:/tmp:rw
+      # - ./app:/usr/src/code/app
+      # - ./src:/usr/src/code/src
+      # - ./docker:/usr/src/code/docker
     depends_on:
       - redis
       - mariadb
+    labels:
+      - io.balena.features.balena-socket=1
     environment:
       - _APP_ENV
       - _APP_REDIS_HOST
@@ -313,9 +319,9 @@ services:
       context: .
     networks:
       - appwrite
-    volumes:
-      - ./app:/usr/src/code/app
-      - ./src:/usr/src/code/src
+    # volumes:
+      # - ./app:/usr/src/code/app
+      # - ./src:/usr/src/code/src
     depends_on:
       - redis
       - maildev
@@ -341,9 +347,9 @@ services:
       context: .
     networks:
       - appwrite
-    volumes:
-      - ./app:/usr/src/code/app
-      - ./src:/usr/src/code/src
+    # volumes:
+      # - ./app:/usr/src/code/app
+      # - ./src:/usr/src/code/src
     depends_on:
       - redis
     environment:
@@ -364,9 +370,9 @@ services:
       context: .
     networks:
       - appwrite
-    volumes:
-      - ./app:/usr/src/code/app
-      - ./src:/usr/src/code/src
+    # volumes:
+      # - ./app:/usr/src/code/app
+      # - ./src:/usr/src/code/src
     depends_on:
       - redis
     environment:

Variable interpolation doesn't work

mariadb service uses variable interpolation, which doesn't work on balena. Instead, we will add those as seperate environment variables
Line 396:

      - MYSQL_DATABASE=${_APP_DB_SCHEMA}
      - MYSQL_USER=${_APP_DB_USER}
      - MYSQL_PASSWORD=${_APP_DB_PASS}

Disabling ClamAV

From @kodumbeats' tutorial:

# docker-compose.yml

-  clamav:
-    image: appwrite/clamav:1.2.0
-    container_name: appwrite-clamav
-    networks:
-      - appwrite
-    volumes:
-      - appwrite-uploads:/storage/uploads
+ # clamav:
+ #   image: appwrite/clamav:1.2.0
+ #   container_name: appwrite-clamav
+ #   networks:
+ #     - appwrite
+ #   volumes:
+ #      - appwrite-uploads:/storage/uploads

Resulting docker-compose.yml

docker-compose.yml
# WARNING!
# This is a development version of THE Appwrite docker-compose.yml file.
# Avoid using this file in your production environment.
# We're exposing here sensetive ports and mounting code volumes for rapid development and debugging of the server stack.
# For a production ready compose file please use: https://appwrite.io/docker-compose.yml

version: '2'

services:
  traefik:
    image: traefik:2.3
    container_name: appwrite-traefik
    command:
      - --log.level=DEBUG
      - --api.insecure=true
      - --providers.file.directory=/storage/config
      - --providers.file.watch=true
      - --providers.docker=true
      - --providers.docker.exposedByDefault=false
      - --providers.docker.constraints=Label(`traefik.constraint-label-stack`,`appwrite`)
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --accesslog=true
      - --providers.docker.endpoint=unix:https:///var/run/balena-engine.sock
    ports:
      - 80:80
      - 443:443
      - 9500:8080
    volumes:
      # - /var/run/docker.sock:/var/run/docker.sock
      - appwrite-config:/storage/config:ro
      - appwrite-certificates:/storage/certificates:ro
    depends_on:
      - appwrite
    networks:
      - gateway
      - appwrite
    labels:
      - io.balena.features.balena-socket=1
  
  appwrite:
    container_name: appwrite
    build:
      context: .
      # args:
      #   - TESTING=true
      #   - VERSION=dev
    ports: 
      - 9501:80
    networks:
      - appwrite
    labels:
      - io.balena.features.balena-socket=1
      - traefik.enable=true
      - traefik.constraint-label-stack=appwrite
      - traefik.http.routers.appwrite.rule=PathPrefix(`/`)
      - traefik.http.routers.appwrite-secure.rule=PathPrefix(`/`)
      - traefik.http.routers.appwrite-secure.tls=true
    volumes:
      # - /var/run/docker.sock:/var/run/docker.sock
      - appwrite-uploads:/storage/uploads:rw
      - appwrite-cache:/storage/cache:rw
      - appwrite-config:/storage/config:rw
      - appwrite-certificates:/storage/certificates:rw
      - appwrite-functions:/storage/functions:rw
      # - ./phpunit.xml:/usr/src/code/phpunit.xml
      # - ./psalm.xml:/usr/src/code/psalm.xml
      # - ./tests:/usr/src/code/tests
      # - ./app:/usr/src/code/app
      # - ./vendor:/usr/src/code/vendor
      # - ./docs:/usr/src/code/docs
      # - ./public:/usr/src/code/public
      # - ./src:/usr/src/code/src
      # - ./debug:/tmp
    depends_on:
      - mariadb
      - redis
      # - clamav
      - influxdb
    environment:
      - _APP_ENV
      - _APP_SYSTEM_EMAIL_NAME
      - _APP_SYSTEM_EMAIL_ADDRESS
      - _APP_SYSTEM_SECURITY_EMAIL_ADDRESS
      - _APP_SYSTEM_RESPONSE_FORMAT
      - _APP_OPTIONS_ABUSE
      - _APP_OPTIONS_FORCE_HTTPS
      - _APP_OPENSSL_KEY_V1
      - _APP_DOMAIN
      - _APP_DOMAIN_TARGET
      - _APP_REDIS_HOST
      - _APP_REDIS_PORT
      - _APP_REDIS_USER
      - _APP_REDIS_PASS
      - _APP_DB_HOST
      - _APP_DB_PORT
      - _APP_DB_SCHEMA
      - _APP_DB_USER
      - _APP_DB_PASS
      - _APP_STORAGE_ANTIVIRUS
      - _APP_STORAGE_ANTIVIRUS_HOST
      - _APP_STORAGE_ANTIVIRUS_PORT
      - _APP_SMTP_HOST
      - _APP_SMTP_PORT
      - _APP_SMTP_SECURE
      - _APP_SMTP_USERNAME
      - _APP_SMTP_PASSWORD
      - _APP_USAGE_STATS
      - _APP_INFLUXDB_HOST
      - _APP_INFLUXDB_PORT
      - _APP_STORAGE_LIMIT
      - _APP_FUNCTIONS_TIMEOUT
      - _APP_FUNCTIONS_CONTAINERS
      - _APP_FUNCTIONS_CPUS
      - _APP_FUNCTIONS_MEMORY
      - _APP_FUNCTIONS_MEMORY_SWAP
      - _APP_FUNCTIONS_ENVS

  appwrite-worker-usage:
    entrypoint: worker-usage
    container_name: appwrite-worker-usage
    build:
      context: .
    networks:
      - appwrite
    # volumes:
      # - ./app:/usr/src/code/app
      # - ./src:/usr/src/code/src
    depends_on:
      - redis
      - telegraf
    environment:
      - _APP_ENV
      - _APP_REDIS_HOST
      - _APP_REDIS_PORT
      - _APP_REDIS_USER
      - _APP_REDIS_PASS
      - _APP_STATSD_HOST
      - _APP_STATSD_PORT

  appwrite-worker-audits:
    entrypoint: worker-audits
    container_name: appwrite-worker-audits
    build:
      context: .
    networks:
      - appwrite
    # volumes:
      # - ./app:/usr/src/code/app
      # - ./src:/usr/src/code/src
    depends_on:
      - redis
      - mariadb
    environment:
      - _APP_ENV
      - _APP_REDIS_HOST
      - _APP_REDIS_PORT
      - _APP_REDIS_USER
      - _APP_REDIS_PASS
      - _APP_DB_HOST
      - _APP_DB_PORT
      - _APP_DB_SCHEMA
      - _APP_DB_USER
      - _APP_DB_PASS

  appwrite-worker-webhooks:
    entrypoint: worker-webhooks
    container_name: appwrite-worker-webhooks
    build:
      context: .
    networks:
      - appwrite
    # volumes:
      # - ./app:/usr/src/code/app
      # - ./src:/usr/src/code/src
    depends_on:
      - redis
      - mariadb
      - request-catcher
    environment:
      - _APP_ENV
      - _APP_SYSTEM_SECURITY_EMAIL_ADDRESS
      - _APP_REDIS_HOST
      - _APP_REDIS_PORT
      - _APP_REDIS_USER
      - _APP_REDIS_PASS
      - _APP_DB_HOST
      - _APP_DB_PORT
      - _APP_DB_SCHEMA
      - _APP_DB_USER
      - _APP_DB_PASS

  appwrite-worker-tasks:
    entrypoint: worker-tasks
    container_name: appwrite-worker-tasks
    build:
      context: .
    networks:
      - appwrite
    # volumes:
      # - ./app:/usr/src/code/app
      # - ./src:/usr/src/code/src
    depends_on:
      - redis
      - mariadb
    environment:
      - _APP_ENV
      - _APP_SYSTEM_SECURITY_EMAIL_ADDRESS
      - _APP_REDIS_HOST
      - _APP_REDIS_PORT
      - _APP_REDIS_USER
      - _APP_REDIS_PASS
      - _APP_DB_HOST
      - _APP_DB_PORT
      - _APP_DB_SCHEMA
      - _APP_DB_USER
      - _APP_DB_PASS

  appwrite-worker-deletes:
    entrypoint: worker-deletes
    container_name: appwrite-worker-deletes
    build:
      context: .
    networks:
      - appwrite
    volumes: 
      - appwrite-uploads:/storage/uploads:rw
      - appwrite-cache:/storage/cache:rw
      - appwrite-functions:/storage/functions:rw
      - appwrite-certificates:/storage/certificates:rw
      # - ./app:/usr/src/code/app
      # - ./src:/usr/src/code/src
    depends_on:
      - redis
      - mariadb
    environment:
      - _APP_ENV
      - _APP_REDIS_HOST
      - _APP_REDIS_PORT
      - _APP_REDIS_USER
      - _APP_REDIS_PASS
      - _APP_DB_HOST
      - _APP_DB_PORT
      - _APP_DB_SCHEMA
      - _APP_DB_USER
      - _APP_DB_PASS

  appwrite-worker-certificates:
    entrypoint: worker-certificates
    container_name: appwrite-worker-certificates
    build:
      context: .
    networks:
      - appwrite
    volumes: 
      - appwrite-config:/storage/config:rw
      - appwrite-certificates:/storage/certificates:rw
      # - ./app:/usr/src/code/app
      # - ./src:/usr/src/code/src
    depends_on:
      - redis
      - mariadb
    environment:
      - _APP_ENV
      - _APP_SYSTEM_SECURITY_EMAIL_ADDRESS
      - _APP_REDIS_HOST
      - _APP_REDIS_PORT
      - _APP_REDIS_USER
      - _APP_REDIS_PASS
      - _APP_DB_HOST
      - _APP_DB_PORT
      - _APP_DB_SCHEMA
      - _APP_DB_USER
      - _APP_DB_PASS

  appwrite-worker-functions:
    entrypoint: worker-functions
    container_name: appwrite-worker-functions
    build:
      context: .
    networks:
      - appwrite
    volumes:
      # - /var/run/docker.sock:/var/run/docker.sock
      - appwrite-functions:/storage/functions:rw
      # - /tmp:/tmp:rw
      # - ./app:/usr/src/code/app
      # - ./src:/usr/src/code/src
      # - ./docker:/usr/src/code/docker
    depends_on:
      - redis
      - mariadb
    labels:
      - io.balena.features.balena-socket=1
    environment:
      - _APP_ENV
      - _APP_REDIS_HOST
      - _APP_REDIS_PORT
      - _APP_REDIS_USER
      - _APP_REDIS_PASS
      - _APP_DB_HOST
      - _APP_DB_PORT
      - _APP_DB_SCHEMA
      - _APP_DB_USER
      - _APP_DB_PASS
      - _APP_FUNCTIONS_TIMEOUT
      - _APP_FUNCTIONS_CONTAINERS
      - _APP_FUNCTIONS_CPUS
      - _APP_FUNCTIONS_MEMORY
      - _APP_FUNCTIONS_MEMORY_SWAP
      - _APP_USAGE_STATS
      - DOCKERHUB_PULL_USERNAME
      - DOCKERHUB_PULL_PASSWORD

  appwrite-worker-mails:
    entrypoint: worker-mails
    container_name: appwrite-worker-mails
    build:
      context: .
    networks:
      - appwrite
    # volumes:
      # - ./app:/usr/src/code/app
      # - ./src:/usr/src/code/src
    depends_on:
      - redis
      - maildev
      # - smtp
    environment:
      - _APP_ENV
      - _APP_SYSTEM_EMAIL_NAME
      - _APP_SYSTEM_EMAIL_ADDRESS
      - _APP_REDIS_HOST
      - _APP_REDIS_PORT
      - _APP_REDIS_USER
      - _APP_REDIS_PASS
      - _APP_SMTP_HOST
      - _APP_SMTP_PORT
      - _APP_SMTP_SECURE
      - _APP_SMTP_USERNAME
      - _APP_SMTP_PASSWORD

  appwrite-maintenance:
    entrypoint: maintenance
    container_name: appwrite-maintenance
    build:
      context: .
    networks:
      - appwrite
    # volumes:
      # - ./app:/usr/src/code/app
      # - ./src:/usr/src/code/src
    depends_on:
      - redis
    environment:
      - _APP_ENV
      - _APP_REDIS_HOST
      - _APP_REDIS_PORT
      - _APP_REDIS_USER
      - _APP_REDIS_PASS
      - _APP_MAINTENANCE_INTERVAL
      - _APP_MAINTENANCE_RETENTION_EXECUTION
      - _APP_MAINTENANCE_RETENTION_ABUSE
      - _APP_MAINTENANCE_RETENTION_AUDIT

  appwrite-schedule:
    entrypoint: schedule
    container_name: appwrite-schedule
    build:
      context: .
    networks:
      - appwrite
    # volumes:
      # - ./app:/usr/src/code/app
      # - ./src:/usr/src/code/src
    depends_on:
      - redis
    environment:
      - _APP_ENV
      - _APP_REDIS_HOST
      - _APP_REDIS_PORT
      - _APP_REDIS_USER
      - _APP_REDIS_PASS

  mariadb:
    image: appwrite/mariadb:1.2.0 # fix issues when upgrading using: mysql_upgrade -u root -p
    container_name: appwrite-mariadb
    networks:
      - appwrite
    volumes:
      - appwrite-mariadb:/var/lib/mysql:rw
    ports:
      - "3306:3306"
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_DATABASE=${_APP_DB_SCHEMA}
      - MYSQL_USER=${_APP_DB_USER}
      - MYSQL_PASSWORD=${_APP_DB_PASS}
    command: 'mysqld --innodb-flush-method=fsync' # add ' --query_cache_size=0' for DB tests
    # command: mv /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile0.bu && mv /var/lib/mysql/ib_logfile1 /var/lib/mysql/ib_logfile1.bu

  # smtp:
  #   image: appwrite/smtp:1.2.0
  #   container_name: appwrite-smtp
  #   restart: unless-stopped
  #   networks:
  #     - appwrite
  #   environment:
  #     - LOCAL_DOMAINS=@
  #     - RELAY_FROM_HOSTS=192.168.0.0/16 ; *.yourdomain.com
  #     - SMARTHOST_HOST=smtp
  #     - SMARTHOST_PORT=587
  
  redis:
    image: redis:6.0-alpine
    container_name: appwrite-redis
    networks:
      - appwrite
    volumes:
      - appwrite-redis:/data:rw

  # clamav:
  #   image: appwrite/clamav:1.2.0
  #   container_name: appwrite-clamav
  #   networks:
  #     - appwrite
  #   volumes:
  #     - appwrite-uploads:/storage/uploads
      
  influxdb:
    image: appwrite/influxdb:1.0.0
    container_name: appwrite-influxdb
    networks:
      - appwrite
    volumes:
      - appwrite-influxdb:/var/lib/influxdb:rw

  telegraf:
    image: appwrite/telegraf:1.1.0
    container_name: appwrite-telegraf
    networks:
      - appwrite

  # Dev Tools Start ------------------------------------------------------------------------------------------
  # 
  # The Appwrite Team uses the following tools to help debug, monitor and diagnose the Appwrite stack
  #
  # Here is a description of the different tools and why are we using them:
  #
  # MailCatcher - An SMTP server. Catches all system emails and displays them in a nice UI.
  # RequestCatcher - An HTTP server. Catches all system https calls and displays them using a simple HTTP API. Used to debug & tests webhooks and HTTP tasks
  # RedisCommander - A nice UI for exploring Redis data
  # Resque - A nice UI for exploring Reddis pub/sub, view the different queues workloads, pending and failed tasks
  # Chronograf - A nice UI for exploring InfluxDB data
  # Webgrind - A nice UI for exploring and debugging code-level stuff

  maildev: # used mainly for dev tests
    image: appwrite/mailcatcher:1.0.0
    container_name: appwrite-mailcatcher
    ports:
      - '9503:1080'
    networks:
      - appwrite

  request-catcher: # used mainly for dev tests
    image: appwrite/requestcatcher:1.0.0
    container_name: appwrite-requestcatcher
    ports:
      - '9504:5000'
    networks:
      - appwrite

  adminer:
    image: adminer
    restart: always
    ports:
      - 9505:8080
    networks:
      - appwrite

  # redis-commander:
  #   image: rediscommander/redis-commander:latest
  #   restart: unless-stopped
  #   networks:
  #   - appwrite
  #   environment:
  #   - REDIS_HOSTS=redis
  #   ports:
  #   - "8081:8081"

  # resque:
  #   image: appwrite/resque-web:1.1.0
  #   restart: unless-stopped
  #   networks:
  #     - appwrite
  #   ports:
  #     - "5678:5678"
  #   environment:
  #     - RESQUE_WEB_HOST=redis
  #     - RESQUE_WEB_PORT=6379
  #     - RESQUE_WEB_HTTP_BASIC_AUTH_USER=user
  #     - RESQUE_WEB_HTTP_BASIC_AUTH_PASSWORD=password

  # chronograf:
  #   image: chronograf:1.5
  #   container_name: appwrite-chronograf
  #   restart: unless-stopped
  #   networks:
  #   - appwrite
  #   volumes:
  #   - appwrite-chronograf:/var/lib/chronograf
  #   ports:
  #   - "8888:8888"
  #   environment:
  #   - INFLUXDB_URL=http:https://influxdb:8086
  #   - KAPACITOR_URL=http:https://kapacitor:9092
  #   - AUTH_DURATION=48h
  #   - TOKEN_SECRET=duperduper5674829!jwt
  #   - GH_CLIENT_ID=d86f7145a41eacfc52cc
  #   - GH_CLIENT_SECRET=9e0081062367a2134e7f2ea95ba1a32d08b6c8ab
  #   - GH_ORGS=appwrite

  # webgrind:
  #   image: 'jokkedk/webgrind:latest'
  #   volumes:
  #     - './debug:/tmp'
  #   ports:
  #     - '3001:80'
  
  # Dev Tools End   ------------------------------------------------------------------------------------------

networks:
  gateway:
  appwrite:

volumes:
  appwrite-mariadb:
  appwrite-redis:
  appwrite-cache:
  appwrite-uploads:
  appwrite-certificates:
  appwrite-functions:
  appwrite-influxdb:
  appwrite-config:
  # appwrite-chronograf:

Creating the balena app and adding environment variables

balena doesn't support .env. Instead, those variables have to be either defaulted directly in the docker-compose.yml file, Dockerfile, or they can be managed granularly on balenaCloud using either the CLI or dashboard. Here we set those variables using the CLI:

commands
balena app create appwrite
balena env add -a appwrite _APP_ENV production
balena env add -a appwrite _APP_ENV development
balena env add -a appwrite _APP_SYSTEM_EMAIL_NAME Appwrite
balena env add -a appwrite _APP_SYSTEM_EMAIL_ADDRESS [email protected]
balena env add -a appwrite _APP_SYSTEM_SECURITY_EMAIL_ADDRESS [email protected]
balena env add -a appwrite _APP_OPTIONS_ABUSE disabled
balena env add -a appwrite _APP_OPTIONS_FORCE_HTTPS disabled
balena env add -a appwrite _APP_OPENSSL_KEY_V1 your-secret-key
balena env add -a appwrite _APP_DOMAIN demo.appwrite.io
balena env add -a appwrite _APP_DOMAIN_TARGET demo.appwrite.io
balena env add -a appwrite _APP_REDIS_HOST redis
balena env add -a appwrite _APP_REDIS_PORT 6379
balena env add -a appwrite _APP_DB_HOST mariadb
balena env add -a appwrite _APP_DB_PORT 3306
balena env add -a appwrite _APP_DB_SCHEMA appwrite
balena env add -a appwrite _APP_DB_USER user
balena env add -a appwrite _APP_DB_PASS password
balena env add -a appwrite _APP_STORAGE_ANTIVIRUS enabled
balena env add -a appwrite _APP_STORAGE_ANTIVIRUS_HOST clamav
balena env add -a appwrite _APP_STORAGE_ANTIVIRUS_PORT 3310
balena env add -a appwrite _APP_INFLUXDB_HOST influxdb
balena env add -a appwrite _APP_INFLUXDB_PORT 8086
balena env add -a appwrite _APP_STATSD_HOST telegraf
balena env add -a appwrite _APP_STATSD_PORT 8125
balena env add -a appwrite _APP_SMTP_HOST maildev
balena env add -a appwrite _APP_SMTP_PORT 25
balena env add -a appwrite _APP_STORAGE_LIMIT 10000000
balena env add -a appwrite _APP_FUNCTIONS_TIMEOUT 900
balena env add -a appwrite _APP_FUNCTIONS_CONTAINERS 10
balena env add -a appwrite _APP_FUNCTIONS_CPUS 1
balena env add -a appwrite _APP_FUNCTIONS_MEMORY 128
balena env add -a appwrite _APP_FUNCTIONS_MEMORY_SWAP 128
balena env add -a appwrite _APP_MAINTENANCE_INTERVAL 86400
balena env add -a appwrite _APP_USAGE_STATS enabled
balena env add -a appwrite MYSQL_DATABASE appwrite
balena env add -a appwrite MYSQL_USER user
balena env add -a appwrite MYSQL_PASSWORD password

Publish

This steps took about 30 minutes. It uploads the full working directory (except for .dockerignored files), builds all the containers and stores them in its own registry

balena push appwrite

Add a device

Add a device using the dashboard. It will dowload all prebuilt images.
Navigate to the IP address of the device to see the landing page.
You can also access it through the balena public URL for out of network access without any additional configuration.

Next steps

Prebuilt images

Publishing prebuilt images to dockerhub will save the user from the 30 minutes build time, which would be pretty great 😁

One-click button

https://www.balena.io/deploy.svg
balena added support for a one-click button back in september. This would allow anyone with a Raspberry Pi 4 to deploy an Appwrite instance and get started in minimal time.
Looking at the docs, it would be pretty trivial to port the previous steps into a single balena.yml file. No CLI commands, no cloning, just one click 🎉

One blocker I see is that there is no way to specify another docker-compose.yml. The changes to docker-compose.yml previously described would either have to be applied on the master branch, or maintained in a seperate branch with only those changes. I don't know the implications of either of those solutions though.

Originally posted by @edorgeville in #1046

@TorstenDittmann
Copy link
Contributor

Amazing job!

Regarding the version in docker-compose, I think we can fully remove this value from the file as well right?

@loftwah
Copy link

loftwah commented Aug 4, 2021

What is the action that needs to happen here?

@edorgeville
Copy link

Herm, it seems this user just reposted my discussion post as an issue without changing anything, not even the title which makes it sound like its their work 😓 By looking at their profile I think it's just a spam account faking activity to bypass spam restrictions in the future.
Original post is here: #1046

@eldadfux eldadfux closed this as completed Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants