Skip to content

Commit

Permalink
Fix documentations in area of debugging.
Browse files Browse the repository at this point in the history
Fix DYNAMO_HOME handling in Docker environment.
  • Loading branch information
ekharkunov committed Oct 1, 2024
1 parent d43c286 commit dac33be
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 30 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,5 @@ server/manifestmergetool/bin/*

/server/docker/victoria-metrics-data/*
/server/docker/grafana-data/*
/dynamo_home/
/dynamo_home/**

/server/envs/user.env
6 changes: 3 additions & 3 deletions README_DEBUGGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [<sha1>]

This downloads the latest sdk to the folder `defoldsdk/<sha1>/defoldsdk`; creates link from `defoldsdk/<sha1>/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/<sha1>/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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions server/docker/common-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 38 additions & 23 deletions server/scripts/debug_defoldsdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -54,18 +48,40 @@ 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
print("Unpacking to %s" % unpack_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 [<engine sha1>]")
print("Docker compose profiles can be passed by variable COMPOSE_PROFILES")
Expand All @@ -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")

0 comments on commit dac33be

Please sign in to comment.