From patchwork Thu Apr 2 19:51:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandeep Gundlupet Raju X-Patchwork-Id: 85190 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE9B3D6AB04 for ; Thu, 2 Apr 2026 19:51:31 +0000 (UTC) Received: from BL2PR02CU003.outbound.protection.outlook.com (BL2PR02CU003.outbound.protection.outlook.com [52.101.52.61]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.4915.1775159481642459175 for ; Thu, 02 Apr 2026 12:51:22 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@amd.com header.s=selector1 header.b=L7V5bylb; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 52.101.52.61, mailfrom: sandeep.gundlupet-raju@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DsiZbkuqWZckhcJX05kzar5AvqrHDZVCeAPkBVjuLtqsCXZ9TUjEevEf5wD4BSDjNUj/Y14PhOWbneQg1U9Q5CFkTsAfexz3O3S/R39H8tYvgvdjHzACHoVTJss2pFJIS7lhohlc1nYR5F1sfGgBvIy60cCQPRJi84+d8EHmXyKn7cKyWtYHxXHFIETZxdC9lxEwWSsNSW6HKekF90iBFdje3AFeY/9kZMTUvycDdtPF36TsKR3pl+towMyl2Y7MPaCTtxHLS6zIbMYNdyYxVqKm9j9AJNOmGVpwFE3Q1XcaY8Mb7xtxa513qa7V4t1lr8dRBvDh8oxfx0ycSnhWuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RZSdL1tVRdoZ66WOLUKLLXBb8nsnYG+0CL3m/r44Tgo=; b=JV083KsRTwMw4cW6i3goLzWH2p6qVzjgtWZc9U7QOdEM5aGuHKrUEWSzWuE1iPWk9w6IJMAxcwd4dCdjvxXZoXJ9e+8z6ztVglHQcAOyoUAKI8XW0hglSQ1UnYiLUGsnac2SHCjhSIJZ5HdXP+SFdVEe3Tf24ifaenlNrQi2Aj2ckYmkSflaId84P/PhpSp35x8L7CcEM7ceJjEVrCtDvnDIHE4lxiU/h5kVhNzBztFkE3o99PwQDId+OmIJdq4YBTSkSbwzebr2c92ZIGsoa1tLUR5mxj2YNabnr5jpnIclJefeCiiF4GxvTe7ciqmz4UBuCMV2SDUbGAo/cg4/wA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.yoctoproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RZSdL1tVRdoZ66WOLUKLLXBb8nsnYG+0CL3m/r44Tgo=; b=L7V5bylbpOVoJpDnFHJ5gDUbgRlMlQknzBF7Fy7z48myodjllpv9iUlGWxVHKQxj649ZhJxDhZT3c+XNHmB8orQbDpFB5ETrgzvgd15fVaboOA/eGLqH6h2JrWo67YJ6Q0t0eLLTU0vkcxXx7cn+iHXkbuRds/b4Dmln/MGShKo= Received: from PH7P220CA0047.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::6) by MW3PR12MB4457.namprd12.prod.outlook.com (2603:10b6:303:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9745.15; Thu, 2 Apr 2026 19:51:14 +0000 Received: from CY4PEPF0000E9CF.namprd03.prod.outlook.com (2603:10b6:510:32b:cafe::56) by PH7P220CA0047.outlook.office365.com (2603:10b6:510:32b::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9745.30 via Frontend Transport; Thu, 2 Apr 2026 19:51:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CY4PEPF0000E9CF.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.17 via Frontend Transport; Thu, 2 Apr 2026 19:51:13 +0000 Received: from satlexmb07.amd.com (10.181.42.216) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 2 Apr 2026 14:51:12 -0500 Received: from xcosswyocto01.xilinx.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Thu, 2 Apr 2026 14:51:12 -0500 From: Sandeep Gundlupet Raju To: CC: , Subject: [layerindex-web][PATCH 1/4] layerindex: Add app dir support for configurable container Date: Thu, 2 Apr 2026 13:51:09 -0600 Message-ID: <20260402195112.1369295-2-sandeep.gundlupet-raju@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260402195112.1369295-1-sandeep.gundlupet-raju@amd.com> References: <20260402195112.1369295-1-sandeep.gundlupet-raju@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9CF:EE_|MW3PR12MB4457:EE_ X-MS-Office365-Filtering-Correlation-Id: 13a4235e-8a61-4a97-129f-08de90f13265 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700016|376014|1800799024|18002099003|56012099003|22082099003; X-Microsoft-Antispam-Message-Info: sI3j83Vvlmx+LZ/85r2Hq6FA7vJvxiZu+xQKOT+gZq+uwYs7NL5S6BAvNoX2RVGdcvVhGpExuI41ld1lNsXfY9RcUTY4c2Nhd38CUoZ7PU0VgPYOrxoTo+KJ5WF2+4eWGyYSVAHtOqOBw7rKg+uVCRfEIfBMIYCZbZhaiBRxBlk1ZB+qgtN1t63DTtgJg8Pf5dO9rN1wCw4me81G+hUj14DV95WtkzebnpektfuPDsv9LYhx4Vqg1t0FTOj8aE4Mq7P4d2fo+NsWdOHQcUQ2fisB/zJtM4XhiP2jrja3kgjynfRKSvRVW3+C2oGDKnBCB/0xMlU3456yNJM2vwvaXikRQOYcyXmfn7maVwHBGPC+v3invgsAeAIYtlePyKddkoKpcfW+IQM7J1462drz9c5vnioM6z2zuJ3TYO/6hH05rqfvXVlme/th4zXwY2i3IybKt/ihQC7SjtLJ1F3Qc3YlTJoYFUNbhvUqDwet1ml9OApMQhAcuUv4goMOnWj6+KTkhp74nKCI56bdrMjRgQp9yWOG7nFl0hKrN36HnnHV6ea7c0F1l8TpsIfeARcBTFfR4s+7SAOIJPtc5OzSD4UOn2J7xpDwWxlX/O5k04I9pZ1ddplxrg+yfcKjv9pXu+23ykyRmVyK6DNRjuxeBpTuOZpT/ZmnVWP+XKr8CBg7sXrlwVmaTOA6DDW7oUIAgzH5s67U/D0kV4G4qoEzPcqys69u4dbF/YFQFHSazUGFwpZZgwWK9o5WeJwygMdbW8zG4BzV/79ch6BWA57XBg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700016)(376014)(1800799024)(18002099003)(56012099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fJfsBXvQ1Q6K7tNNxEyu7xBnkf9OElZy8WiyjiIt731O8o42WuDii8vPTM7zw1zFaZRUS+AHH8/v8APfSYquIyVAfwhFhS6Ap0Nfi8/dCXKR/BBuOZCxrYPudtf7DILbTMK3KncYBLUnrPomU4gA3AdEpadC25UPK8Do+aoWCv2zvKv0jY0hk5kmz2Qjq78sFgQE0SWiYb0lxC+xggpumLcXeSH2KHhPuiBDfjltA6ipD2F6J3zUxBZoRKJMV9Kp0R2sVFbqaJNjgmbqvEjwnmRhk2Qgn/DIV93YKDZtlQP6UkR5PGS3iaqy4JRJUy65XU7ZAzlRUcCeFMUCS2u10v4glWP6ls2vVS++nAkHviBJ2qlOq1/bDMMUhzPO6GBYrbh67/Bd1D5mEmV5SDuRjVDQDNkp3nfnxRsaibFOmRu3qP/H+OemBfyOJpsYxStE X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2026 19:51:13.9317 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 13a4235e-8a61-4a97-129f-08de90f13265 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9CF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4457 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 02 Apr 2026 19:51:31 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/3620 Add a new --app-dir command-line argument (default: /opt) to allow the base directory used inside the containers to be configurable instead of being hardcoded to /opt. Changes: - dockersetup.py: add --app-dir argument; write APP_DIR to .env file via new write_env_file() so docker-compose passes it as a build arg; update edit_dockercompose() to expand build: block and inject APP_DIR build arg reference, and rewrite volume mounts and celery --workdir accordingly; propagate app_dir through setup_https(), check_connectivity(), and all direct docker-compose run call sites - Dockerfile: add ARG APP_DIR=/opt + ENV APP_DIR=${APP_DIR}; replace all hardcoded /opt paths with ${APP_DIR} in COPY, RUN and CMD instructions - docker/migrate.sh: replace /opt with ${APP_DIR:-/opt} - docker/refreshlayers.sh: replace /opt with ${APP_DIR:-/opt} - docker/updatelayers.sh: replace /opt with ${APP_DIR:-/opt} AI-Generated: GitHub Copilot (Claude Sonnet 4.6) Signed-off-by: Sandeep Gundlupet Raju --- Dockerfile | 24 +++++++------ docker/migrate.sh | 2 +- docker/refreshlayers.sh | 2 +- docker/updatelayers.sh | 2 +- dockersetup.py | 79 +++++++++++++++++++++++++++++++++-------- 5 files changed, 80 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index 72f57d2..8e6e508 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,8 @@ FROM ubuntu:jammy LABEL maintainer="Michael Halstead " +ARG APP_DIR=/opt +ENV APP_DIR=${APP_DIR} ENV PYTHONUNBUFFERED=1 \ LANGUAGE=en_US \ LANG=en_US.UTF-8 \ @@ -55,22 +57,22 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean -COPY . /opt/layerindex -RUN rm -rf /opt/layerindex/docker -COPY docker/settings.py /opt/layerindex/settings.py -COPY docker/refreshlayers.sh /opt/refreshlayers.sh -COPY docker/updatelayers.sh /opt/updatelayers.sh -COPY docker/migrate.sh /opt/migrate.sh -COPY docker/connectivity_check.sh /opt/connectivity_check.sh +COPY . ${APP_DIR}/layerindex +RUN rm -rf ${APP_DIR}/layerindex/docker +COPY docker/settings.py ${APP_DIR}/layerindex/settings.py +COPY docker/refreshlayers.sh ${APP_DIR}/refreshlayers.sh +COPY docker/updatelayers.sh ${APP_DIR}/updatelayers.sh +COPY docker/migrate.sh ${APP_DIR}/migrate.sh +COPY docker/connectivity_check.sh ${APP_DIR}/connectivity_check.sh -RUN mkdir /opt/workdir \ +RUN mkdir ${APP_DIR}/workdir \ && adduser --system --uid=500 layers \ - && chown -R layers /opt/workdir + && chown -R layers ${APP_DIR}/workdir USER layers # Always copy in .gitconfig and proxy helper script (they need editing to be active) COPY docker/.gitconfig /home/layers/.gitconfig -COPY docker/git-proxy /opt/bin/git-proxy +COPY docker/git-proxy ${APP_DIR}/bin/git-proxy # Start Gunicorn -CMD ["/usr/local/bin/gunicorn", "wsgi:application", "--workers=4", "--bind=:5000", "--timeout=60", "--log-level=debug", "--chdir=/opt/layerindex"] +CMD ["/bin/sh", "-c", "/usr/local/bin/gunicorn wsgi:application --workers=4 --bind=:5000 --timeout=60 --log-level=debug --chdir=${APP_DIR}/layerindex"] diff --git a/docker/migrate.sh b/docker/migrate.sh index ca15368..bb9f646 100755 --- a/docker/migrate.sh +++ b/docker/migrate.sh @@ -1,2 +1,2 @@ #!/bin/bash -python3 /opt/layerindex/manage.py migrate "$@" +python3 ${APP_DIR:-/opt}/layerindex/manage.py migrate "$@" diff --git a/docker/refreshlayers.sh b/docker/refreshlayers.sh index 0c550bd..5adaf86 100755 --- a/docker/refreshlayers.sh +++ b/docker/refreshlayers.sh @@ -1,3 +1,3 @@ #!/bin/bash -update=/opt/layerindex/layerindex/update.py +update=${APP_DIR:-/opt}/layerindex/layerindex/update.py $update -q -r diff --git a/docker/updatelayers.sh b/docker/updatelayers.sh index 21640ba..6f0e8f0 100755 --- a/docker/updatelayers.sh +++ b/docker/updatelayers.sh @@ -1,3 +1,3 @@ #!/bin/bash -update=/opt/layerindex/layerindex/update.py +update=${APP_DIR:-/opt}/layerindex/layerindex/update.py $update -q diff --git a/dockersetup.py b/dockersetup.py index bc7478c..920b2c8 100755 --- a/dockersetup.py +++ b/dockersetup.py @@ -70,6 +70,7 @@ def get_args(): parser.add_argument('--no-migrate', action="store_true", default=False, help='Skip running database migrations') parser.add_argument('--no-admin-user', action="store_true", default=False, help='Skip adding admin user') parser.add_argument('--no-connectivity', action="store_true", default=False, help='Skip checking external network connectivity') + parser.add_argument('--app-dir', type=str, help='Base directory inside the container for application files. Default is %(default)s', required=False, default='/opt') args = parser.parse_args() @@ -253,14 +254,16 @@ def yaml_comment(line): # Add hostname, secret key, db info, and email host in docker-compose.yml -def edit_dockercompose(hostname, dbpassword, dbapassword, secretkey, rmqpassword, portmapping, letsencrypt, email_host, email_port, email_user, email_password, email_ssl, email_tls): +def edit_dockercompose(hostname, dbpassword, dbapassword, secretkey, rmqpassword, portmapping, letsencrypt, email_host, email_port, email_user, email_password, email_ssl, email_tls, app_dir='/opt'): + + in_layersapp_build = False def adjust_cert_mount_line(ln): linesplit = ln.split(':') if letsencrypt: linesplit[1] = '/etc/letsencrypt' else: - linesplit[1] = '/opt/cert' + linesplit[1] = app_dir + '/cert' # This allows us to handle if there is a ":ro" or similar on the end return ':'.join(linesplit) @@ -305,6 +308,33 @@ def edit_dockercompose(hostname, dbpassword, dbapassword, secretkey, rmqpassword newlines.append(ucline + '\n') else: newlines.append(yaml_comment(line) + '\n') + elif re.match(r'^\s+build:\s+\.$', line): + # Convert inline 'build: .' to block form so we can pass APP_DIR as a build arg + indent = line[:len(line) - len(line.lstrip())] + newlines.append(indent + 'build:\n') + newlines.append(indent + ' context: .\n') + newlines.append(indent + ' args:\n') + newlines.append(indent + ' - APP_DIR=${APP_DIR}\n') + in_layersapp_build = True + continue + elif '- APP_DIR=' in line: + # Keep APP_DIR referencing the .env file (do not embed value here) + format = line[:line.find('- APP_DIR=')].replace('#', '') + newlines.append(format + '- APP_DIR=${APP_DIR}\n') + continue + elif re.match(r'^\s+context:\s+\.$', line) and in_layersapp_build: + in_layersapp_build = False + newlines.append(line + '\n') + continue + elif ':/opt/workdir' in line: + newlines.append(line.replace(':/opt/workdir', ':' + app_dir + '/workdir') + '\n') + continue + elif ':/opt/layerindex-task-logs' in line: + newlines.append(line.replace(':/opt/layerindex-task-logs', ':' + app_dir + '/layerindex-task-logs') + '\n') + continue + elif '--workdir=/opt/layerindex' in line: + newlines.append(line.replace('--workdir=/opt/layerindex', '--workdir=' + app_dir + '/layerindex') + '\n') + continue elif "layersweb:" in line: in_layersweb = True newlines.append(line + "\n") @@ -474,9 +504,9 @@ def edit_dockerfile_web(hostname, no_https): writefile("Dockerfile.web", ''.join(newlines)) -def setup_https(hostname, http_port, https_port, letsencrypt, letsencrypt_production, cert, cert_key, emailaddr): +def setup_https(hostname, http_port, https_port, letsencrypt, letsencrypt_production, cert, cert_key, emailaddr, app_dir='/opt'): local_cert_dir = os.path.abspath('docker/certs') - container_cert_dir = '/opt/cert' + container_cert_dir = app_dir + '/cert' if letsencrypt: # Create dummy cert container_cert_dir = '/etc/letsencrypt' @@ -578,8 +608,26 @@ def edit_options_file(project_name): f.write('project_name=%s\n' % project_name) -def check_connectivity(): - return_code = subprocess.call(['docker-compose', 'run', '--rm', 'layersapp', '/opt/connectivity_check.sh'], shell=False) +def write_env_file(app_dir): + """Write APP_DIR to .env so docker-compose passes it as a build arg.""" + env_vars = {} + try: + with open('.env', 'r') as f: + for line in f: + line = line.strip() + if '=' in line and not line.startswith('#'): + k, v = line.split('=', 1) + env_vars[k.strip()] = v.strip() + except FileNotFoundError: + pass + env_vars['APP_DIR'] = app_dir + with open('.env', 'w') as f: + for k, v in env_vars.items(): + f.write('%s=%s\n' % (k, v)) + + +def check_connectivity(app_dir='/opt'): + return_code = subprocess.call(['docker-compose', 'run', '--rm', 'layersapp', app_dir + '/connectivity_check.sh'], shell=False) if return_code != 0: print("Connectivity check failed - if you are behind a proxy, please check that you have correctly specified the proxy settings on the command line (see --help for details)") sys.exit(1) @@ -741,15 +789,16 @@ if args.uninstall: if args.update: args.no_https = read_dockerfile_web() if not args.no_https: - container_cert_dir = '/opt/cert' + container_cert_dir = args.app_dir + '/cert' args.hostname, https_port, certdir, certfile, keyfile = read_nginx_ssl_conf(container_cert_dir) edit_nginx_ssl_conf(args.hostname, https_port, certdir, certfile, keyfile) else: # Always edit these in case we switch from proxy to no proxy edit_gitproxy(socks_proxy_host, socks_proxy_port, args.no_proxy) edit_dockerfile(args.http_proxy, args.https_proxy, args.no_proxy) + write_env_file(args.app_dir) - edit_dockercompose(args.hostname, dbpassword, dbapassword, secretkey, rmqpassword, args.portmapping, args.letsencrypt, email_host, email_port, args.email_user, args.email_password, args.email_ssl, args.email_tls) + edit_dockercompose(args.hostname, dbpassword, dbapassword, secretkey, rmqpassword, args.portmapping, args.letsencrypt, email_host, email_port, args.email_user, args.email_password, args.email_ssl, args.email_tls, args.app_dir) edit_dockerfile_web(args.hostname, args.no_https) @@ -758,7 +807,7 @@ else: edit_options_file(args.project_name) if not args.no_https: - setup_https(args.hostname, http_port, https_port, args.letsencrypt, args.letsencrypt_production, args.cert, args.cert_key, emailaddr) + setup_https(args.hostname, http_port, https_port, args.letsencrypt, args.letsencrypt_production, args.cert, args.cert_key, emailaddr, args.app_dir) ## Start up containers return_code = subprocess.call(['docker-compose', 'up', '-d', '--build'], shell=False) @@ -768,7 +817,7 @@ if return_code != 0: if not (args.update or args.no_connectivity): ## Run connectivity check - check_connectivity() + check_connectivity(args.app_dir) # Get real project name (if only there were a reasonable way to do this... ugh) real_project_name = '' @@ -830,7 +879,7 @@ if not args.no_migrate: env = os.environ.copy() env['DATABASE_USER'] = 'root' env['DATABASE_PASSWORD'] = dbapassword - return_code = subprocess.call(['docker-compose', 'run', '--rm', '-e', 'DATABASE_USER', '-e', 'DATABASE_PASSWORD', 'layersapp', '/opt/migrate.sh'], shell=False, env=env) + return_code = subprocess.call(['docker-compose', 'run', '--rm', '-e', 'DATABASE_USER', '-e', 'DATABASE_PASSWORD', 'layersapp', args.app_dir + '/migrate.sh'], shell=False, env=env) if return_code != 0: print("Applying migrations failed") sys.exit(1) @@ -864,13 +913,13 @@ if not args.update: break for volume in volumes: volname = '%s_%s' % (real_project_name, volume) - return_code = subprocess.call(['docker', 'run', '--rm', '-v', '%s:/opt/mount' % volname, 'debian:stretch', 'chown', '500', '/opt/mount'], shell=False) + return_code = subprocess.call(['docker', 'run', '--rm', '-v', '%s:%s/mount' % (volname, args.app_dir), 'debian:stretch', 'chown', '500', args.app_dir + '/mount'], shell=False) if return_code != 0: print("Setting volume permissions for volume %s failed" % volume) sys.exit(1) ## Generate static assets. Run this command again to regenerate at any time (when static assets in the code are updated) -return_code = subprocess.call("docker-compose run --rm -e STATIC_ROOT=/usr/share/nginx/html -v %s_layersstatic:/usr/share/nginx/html layersapp /opt/layerindex/manage.py collectstatic --noinput" % quote(real_project_name), shell = True) +return_code = subprocess.call("docker-compose run --rm -e STATIC_ROOT=/usr/share/nginx/html -v %s_layersstatic:/usr/share/nginx/html layersapp %s/layerindex/manage.py collectstatic --noinput" % (quote(real_project_name), args.app_dir), shell = True) if return_code != 0: print("Collecting static files failed") sys.exit(1) @@ -891,12 +940,12 @@ else: if not args.update: if not args.databasefile: ## Set site name - return_code = subprocess.call(['docker-compose', 'run', '--rm', 'layersapp', '/opt/layerindex/layerindex/tools/site_name.py', host, 'OpenEmbedded Layer Index'], shell=False) + return_code = subprocess.call(['docker-compose', 'run', '--rm', 'layersapp', args.app_dir + '/layerindex/layerindex/tools/site_name.py', host, 'OpenEmbedded Layer Index'], shell=False) if not args.no_admin_user: ## For a fresh database, create an admin account print("Creating database superuser. Input user name and password when prompted.") - return_code = subprocess.call(['docker-compose', 'run', '--rm', 'layersapp', '/opt/layerindex/manage.py', 'createsuperuser', '--email', emailaddr], shell=False) + return_code = subprocess.call(['docker-compose', 'run', '--rm', 'layersapp', args.app_dir + '/layerindex/manage.py', 'createsuperuser', '--email', emailaddr], shell=False) if return_code != 0: print("Creating superuser failed") sys.exit(1)