#!/bin/bash

# Save env variables to a temporary file
env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAVIS_REPO_|TRAVIS_BUILD_|TRAVIS_BRANCH|TRAVIS_PULL_REQUEST_|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_' >/tmp/docker-env.list

#Xvfb :99 -screen 0 1024x768x24 &

#DISPLAY=:99
docker run --rm -ti \
  --env-file /tmp/docker-env.list \
  --env ELECTRON_CACHE="/root/.cache/electron" \
  --env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
  --env XDG_RUNTIME_DIR="/tmp/runtime-nils" \
  -v "${PWD}:/project" \
  -v "${PWD##*/}-node-modules:/project/node_modules" \
  -v "$HOME/.cache/electron:/root/.cache/electron" \
  -v "$HOME/.cache/electron-builder:/root/.cache/electron-builder" \
  -w /project \
  electronuserland/builder:wine
