From cfee90f45d1365beab8e6f695985f9ec6fc8ebb1 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sat, 5 Nov 2022 13:30:03 +0800 Subject: [PATCH 1/5] Allow injection of arbitrary Dockerfile content. --- cookiecutter.json | 1 + {{ cookiecutter.formal_name }}/Dockerfile | 3 +++ 2 files changed, 4 insertions(+) diff --git a/cookiecutter.json b/cookiecutter.json index 456da7f..ea26f8a 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -6,6 +6,7 @@ "url": "https://example.com", "description": "Short description of app", "python_version": "3.X.0", + "dockerfile_extra_content": "", "_extensions": [ "briefcase.integrations.cookiecutter.PythonVersionExtension" ] diff --git a/{{ cookiecutter.formal_name }}/Dockerfile b/{{ cookiecutter.formal_name }}/Dockerfile index b62f13c..7908634 100644 --- a/{{ cookiecutter.formal_name }}/Dockerfile +++ b/{{ cookiecutter.formal_name }}/Dockerfile @@ -49,3 +49,6 @@ RUN apt-get update -y && \ # Use the brutus user for operations in the container USER brutus + +# ========== START USER PROVIDED CONTENT ========== +{{ cookiecutter.dockerfile_extra_content }} From 067120496499c3b4131baa3cca33b14dca8d438a Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Wed, 9 Nov 2022 11:21:08 +0800 Subject: [PATCH 2/5] Add support for the BRIEFCASE_MAIN_MODULE testing override. --- ...kiecutter.bundle }}.{{ cookiecutter.app_name }} | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/{{ cookiecutter.formal_name }}/{{ cookiecutter.formal_name }}.AppDir/usr/bin/{{ cookiecutter.bundle }}.{{ cookiecutter.app_name }} b/{{ cookiecutter.formal_name }}/{{ cookiecutter.formal_name }}.AppDir/usr/bin/{{ cookiecutter.bundle }}.{{ cookiecutter.app_name }} index c412bfb..3d452d2 100755 --- a/{{ cookiecutter.formal_name }}/{{ cookiecutter.formal_name }}.AppDir/usr/bin/{{ cookiecutter.bundle }}.{{ cookiecutter.app_name }} +++ b/{{ cookiecutter.formal_name }}/{{ cookiecutter.formal_name }}.AppDir/usr/bin/{{ cookiecutter.bundle }}.{{ cookiecutter.app_name }} @@ -1,7 +1,11 @@ #!/bin/bash export APPDIR=$(dirname "$0") -# echo "APPDIR IS $APPDIR" -export PYTHONPATH=$APPDIR/usr/app:$APPDIR/usr/app_packages -# echo "PYTHONPATH IS $PYTHONPATH" -# echo "PATH IS $PATH" -$APPDIR/usr/bin/python3 -u -s -c 'import runpy, sys; sys.path.pop(0); runpy.run_module("{{ cookiecutter.module_name }}", run_name="__main__", alter_sys=True)' "$@" +# echo "APPDIR=${APPDIR}" +export PYTHONPATH=${APPDIR}/usr/app:${APPDIR}/usr/app_packages +# echo "PYTHONPATH=${PYTHONPATH}" +# echo "PATH=${PATH}" +if [[ -z "${BRIEFCASE_MAIN_MODULE}" ]]; then + BRIEFCASE_MAIN_MODULE="{{ cookiecutter.module_name }}" +fi +# echo "BRIEFCASE_MAIN_MODULE=${BRIEFCASE_MAIN_MODULE}" +"${APPDIR}/usr/bin/python3" -u -s -c "import runpy, sys; sys.path.pop(0); runpy.run_module('${BRIEFCASE_MAIN_MODULE}', run_name='__main__', alter_sys=True)" "$@" From c5cdb63feb9b99c676181d524ac8c1f571ed2f8a Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Wed, 9 Nov 2022 13:52:10 +0800 Subject: [PATCH 3/5] Improve formatting of support revision tag. --- {{ cookiecutter.formal_name }}/briefcase.toml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/{{ cookiecutter.formal_name }}/briefcase.toml b/{{ cookiecutter.formal_name }}/briefcase.toml index 3cc122a..5ca5ed0 100644 --- a/{{ cookiecutter.formal_name }}/briefcase.toml +++ b/{{ cookiecutter.formal_name }}/briefcase.toml @@ -3,7 +3,12 @@ app_path = "{{ cookiecutter.formal_name }}.AppDir/usr/app" app_packages_path = "{{ cookiecutter.formal_name }}.AppDir/usr/app_packages" support_path = "{{ cookiecutter.formal_name }}.AppDir/usr" -{{ {"3.8": "support_revision = 7", "3.9": "support_revision = 5", "3.10": "support_revision = 4", "3.11": "support_revision = 1"}.get(cookiecutter.python_version|py_tag, "") }} +{{ { + "3.8": "support_revision = 7", + "3.9": "support_revision = 5", + "3.10": "support_revision = 4", + "3.11": "support_revision = 1" +}.get(cookiecutter.python_version|py_tag, "") }} icon.16 = "{{ cookiecutter.formal_name }}.AppDir/usr/share/icons/hicolor/16x16/apps/{{ cookiecutter.bundle }}.{{ cookiecutter.app_name }}.png" icon.32 = "{{ cookiecutter.formal_name }}.AppDir/usr/share/icons/hicolor/32x32/apps/{{ cookiecutter.bundle }}.{{ cookiecutter.app_name }}.png" From ef7202f02cc10acdae26e69c53267018948ec8bc Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 22 Nov 2022 10:51:09 +0800 Subject: [PATCH 4/5] Bump 3.11 support revision. --- {{ cookiecutter.formal_name }}/briefcase.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{ cookiecutter.formal_name }}/briefcase.toml b/{{ cookiecutter.formal_name }}/briefcase.toml index 5ca5ed0..cd28450 100644 --- a/{{ cookiecutter.formal_name }}/briefcase.toml +++ b/{{ cookiecutter.formal_name }}/briefcase.toml @@ -7,7 +7,7 @@ support_path = "{{ cookiecutter.formal_name }}.AppDir/usr" "3.8": "support_revision = 7", "3.9": "support_revision = 5", "3.10": "support_revision = 4", - "3.11": "support_revision = 1" + "3.11": "support_revision = 2", }.get(cookiecutter.python_version|py_tag, "") }} icon.16 = "{{ cookiecutter.formal_name }}.AppDir/usr/share/icons/hicolor/16x16/apps/{{ cookiecutter.bundle }}.{{ cookiecutter.app_name }}.png" From 14931b8d934a70e59c5dcb5f8402c76b2102dc61 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 22 Nov 2022 12:33:31 +0800 Subject: [PATCH 5/5] Modify Dockerfile to perform Python actions as Brutus, and not aggressively update setuptools. --- {{ cookiecutter.formal_name }}/Dockerfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/{{ cookiecutter.formal_name }}/Dockerfile b/{{ cookiecutter.formal_name }}/Dockerfile index 7908634..512027c 100644 --- a/{{ cookiecutter.formal_name }}/Dockerfile +++ b/{{ cookiecutter.formal_name }}/Dockerfile @@ -27,12 +27,6 @@ RUN apt-get update -y && \ python${PY_VERSION}-dev \ python${PY_VERSION}-venv -# Install (and update) pip, disabling the global cache -RUN python${PY_VERSION} -m ensurepip && \ - python${PY_VERSION} -m pip config set global.cache-dir false && \ - python${PY_VERSION} -m pip install --upgrade pip && \ - python${PY_VERSION} -m pip install --upgrade setuptools wheel - # Ensure Docker user UID:GID matches host user UID:GID (beeware/briefcase#403) # Use --non-unique to avoid problems when the UID:GID of the host user # collides with entries provided by the Docker container. @@ -42,7 +36,13 @@ RUN groupadd --non-unique --gid $HOST_GID briefcase && \ useradd --non-unique --uid $HOST_UID --gid $HOST_GID brutus --home /home/brutus && \ mkdir -p /home/brutus && chown brutus:briefcase /home/brutus -# Install system packages required by app +# Ensure pip is available; do this as the brutus user +# to ensure that the pip cache is created user-readable. +USER brutus +RUN python${PY_VERSION} -m ensurepip + +# As root, Install system packages required by app +USER root ARG SYSTEM_REQUIRES RUN apt-get update -y && \ apt-get install --no-install-recommends -y ${SYSTEM_REQUIRES}