# e2e/docker-compose.yml from repo
# https://github.com/bahmutov/cypress-open-from-docker-compose
version: '3.8'

services:
  apkbuilder:
    image: alvrme/alpine-android-base:latest-jdk11
    logging:
      options:
        max-size: '12m'
        max-file: '5'
      driver: json-file
    working_dir: /data
    command : './gradlew task :app:assembleRelease'
    volumes:
      - ./MyApp:/data
      - ./gradle-cache:/cache

  filebrowser:
    image: filebrowser/filebrowser:latest
    volumes:
      - output_apk:/srv  
      - ./database.db:/database.db
    labels:
      - traefik.enable=true
      - traefik.http.routers.filebrowser-apk.rule=Host(`${URL_APK}`)
      - traefik.http.routers.filebrowser-apk.entrypoints=websecure
      - traefik.http.routers.filebrowser-apk.tls=true
      - traefik.http.routers.filebrowser-apk.tls.certresolver=lets-encrypt
      - traefik.http.services.filebrowser-apk.loadbalancer.server.port=80
      - traefik.docker.network=${NETWORK_TRAEFIK}
    restart: unless-stopped
    networks:
      - traefik-proxy

networks:
  traefik-proxy:
    external:
      name: ${NETWORK_TRAEFIK}

volumes:      
  output_apk:
    driver: local
    driver_opts:
      type: none
      device: ${VOLUME_APK}
      o: bind
#  apkSigner:
#    image: agileek/ionic-framework:2.0.0
#    working_dir: /data
#    command : './gradlew task :app:assembleRelease'
#    volumes:
#        - ./MyApp/MyApplication2:/data
#        - ./gradle-cache:/cache

#https://jpnarowski.com/how-to-publish-an-ionic-android-app-with-docker
#jarsigner -keystore YOUR_KEYSTORE_PATH -storepass YOUR_KEYSTORE_PASS app-release-unsigned.apk YOUR_KEYSTORE_ALIAS &&
#zipalign 4 app-release-unsigned.apk app-release.apk
#