diff --git a/.gitignore b/.gitignore index 1ad9fd5d..83e404a9 100644 --- a/.gitignore +++ b/.gitignore @@ -42,7 +42,5 @@ server/manifestmergetool/bin/* /server/docker/victoria-metrics-data/* /server/docker/grafana-data/* -/dynamo_home/ -/dynamo_home/** /server/envs/user.env diff --git a/README_DEBUGGING.md b/README_DEBUGGING.md index 8a515dd0..3351e131 100644 --- a/README_DEBUGGING.md +++ b/README_DEBUGGING.md @@ -12,7 +12,7 @@ There is a debug script that you can run to download a specific SDK version, or $ ./server/scripts/debug_defoldsdk.py [] -This downloads the latest sdk to the folder `defoldsdk//defoldsdk`; creates link from `defoldsdk//defoldsdk` to `./dynamo_home`; sets the environment variable `DYNAMO_HOME` and then starts the extender server with profile `all`. If you want to run docker compose with other profiles - it can be done via COMPOSE_PROFILES variable. For example +This downloads the latest sdk to the folder `defoldsdk//defoldsdk`; sets the environment variable `DYNAMO_HOME` and then starts the extender server with profile `all`. If you want to run docker compose with other profiles - it can be done via `COMPOSE_PROFILES` variable. For example ```sh COMPOSE_PROFILES=web,windows python ./server/scripts/debug_defoldsdk.py @@ -62,9 +62,9 @@ The command will connect to the container using the `extender` user, and execute ## Preparation -* For locally built SDK's (in DYNAMO_HOME), it's good to map the same folder path locally as is in the Docker container. Create a symlink to ./dynamo_home folder: +* To use locally built SDK set `DYNAMO_HOME` variable before docker compose command. For example, ```sh - ln -sf $DYNAMO_HOME ./dynamo_home + DYNAMO_HOME=/Users/user/work/defold/tmp/dynamo_home docker compose -f ./server/docker/docker-compose.yml --profile android up ``` * Run docker compose with following environment variables: ```sh diff --git a/server/docker/common-services.yml b/server/docker/common-services.yml index 2f6269b9..69cd94e3 100644 --- a/server/docker/common-services.yml +++ b/server/docker/common-services.yml @@ -14,10 +14,10 @@ services: - ./../app/:/app/:ro - ./../app/:/etc/extender/apps/:ro - ./../configs:/etc/defold/extender:ro - - ${DYNAMO_HOME:-./../app/dummy:/dynamo_home} + - ${DYNAMO_HOME:-./../app/dummy}:/dynamo_home entrypoint: ["java","-Xmx4g","-XX:MaxDirectMemorySize=2g","-jar","/app/extender.jar"] environment: - - DYNAMO_HOME + - ${DYNAMO_HOME:+DYNAMO_HOME=/dynamo_home} - DM_DEBUG_COMMANDS - DM_DEBUG_DISABLE_PROGUARD - DM_DEBUG_JOB_FOLDER diff --git a/server/scripts/debug_defoldsdk.py b/server/scripts/debug_defoldsdk.py index 9a84d1fe..17cab33f 100755 --- a/server/scripts/debug_defoldsdk.py +++ b/server/scripts/debug_defoldsdk.py @@ -7,6 +7,8 @@ import shutil import argparse +domain=os.environ.get("DM_ARCHIVE_DOMAIN", "d.defold.com") + def get_latest_version(): url = "http://d.defold.com/stable/info.json" response = urllib.request.urlopen(url) @@ -16,33 +18,25 @@ def get_latest_version(): def download_file(url): print("Downloading %s" % url) - tmpfile = '_dl.zip' + tmpfile = '_dl' try: urllib.request.urlretrieve(url, tmpfile) except: return None return tmpfile -def find_or_download_sdk(sha1): - path = 'defoldsdk/%s.zip' % sha1 - if os.path.exists(path): - print("%s already downloaded" % path) - return path +def download(target_path, urls): + if os.path.exists(target_path): + print("%s already downloaded" % target_path) + return target_path - print("%s not found. Downloading" % path) + print("%s not found. Downloading" % target_path) - dirpath = os.path.dirname(path) + dirpath = os.path.dirname(target_path) if not os.path.exists(dirpath): print("Created directory %s" % dirpath) os.makedirs(dirpath) - domain=os.environ.get("DM_ARCHIVE_DOMAIN", "d.defold.com") - urls = [ - "http://%s/archive/stable/%s/engine/defoldsdk.zip" % (domain, sha1), - "http://%s/archive/beta/%s/engine/defoldsdk.zip" % (domain, sha1), - "http://%s/archive/dev/%s/engine/defoldsdk.zip" % (domain, sha1), - "http://%s/archive/%s/engine/defoldsdk.zip" % (domain, sha1), - ] for url in urls: tmpfile = download_file(url) @@ -54,11 +48,22 @@ def find_or_download_sdk(sha1): print("Downloaded file was empty. Are the credentials ok?") sys.exit(1) - shutil.move(tmpfile, path) - print("Downloaded %s" % path) - return path + shutil.move(tmpfile, target_path) + print("Downloaded %s" % target_path) + return target_path + -def unpack_file(path): +def find_or_download_sdk(sha1): + path = 'defoldsdk/%s.zip' % sha1 + urls = [ + "https://%s/archive/stable/%s/engine/defoldsdk.zip" % (domain, sha1), + "https://%s/archive/beta/%s/engine/defoldsdk.zip" % (domain, sha1), + "https://%s/archive/dev/%s/engine/defoldsdk.zip" % (domain, sha1), + "https://%s/archive/%s/engine/defoldsdk.zip" % (domain, sha1), + ] + return download(path, urls) + +def unpack_file(path, sha1): unpack_path = os.path.join(os.path.dirname(path), sha1) if os.path.exists(unpack_path): return unpack_path @@ -66,6 +71,17 @@ def unpack_file(path): os.system('unzip %s -d %s' % (path, unpack_path)) return unpack_path +def download_mappings(sha1, target_path): + path = '%s/platform.sdks.json' % target_path + mappings_urls = [ + "https://%s/archive/stable/%s/engine/platform.sdks.json" % (domain, sha1), + "https://%s/archive/beta/%s/engine/platform.sdks.json" % (domain, sha1), + "https://%s/archive/dev/%s/engine/platform.sdks.json" % (domain, sha1), + "https://%s/archive/%s/engine/platform.sdks.json" % (domain, sha1), + ] + return download(path, mappings_urls) + + def Usage(): print("Usage: ./debug_defoldsdk []") print("Docker compose profiles can be passed by variable COMPOSE_PROFILES") @@ -88,13 +104,12 @@ def Usage(): print("SHA1: %s" % sha1) path = find_or_download_sdk(sha1) - unpack_path = unpack_file(path) + unpack_path = unpack_file(path, sha1) sdk_path = os.path.abspath(os.path.join(unpack_path, 'defoldsdk')) + download_mappings(sha1, sdk_path) if not 'COMPOSE_PROFILES' in os.environ: os.environ['COMPOSE_PROFILES'] = 'all' - os.environ['DYNAMO_HOME'] = '/dynamo_home' - print('Create symlink from {} to ./dynamo_home'.format(sdk_path)) - os.system('ln -sf {} ./dynamo_home'.format(sdk_path)) + os.environ['DYNAMO_HOME'] = sdk_path os.system("docker compose --file ./server/docker/docker-compose.yml up")