diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..194e1c7968 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.12-slim-bullseye + +# Dev dependencies +RUN apt-get update \ + && apt-get install -y build-essential git libmagic1 libbz2-dev libjpeg62-turbo-dev zlib1g-dev --no-install-recommends \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +ENV PYTHONUNBUFFERED 1 +ENV PYTHONDONTWRITEBYTECODE 1 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..8fc35c400a --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,18 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/python +{ + "name": "Plone Coredev", + "build": { "dockerfile": "Dockerfile" }, + + // Use 'portsAttributes' to set default properties for specific forwarded ports. + // More info: https://containers.dev/implementors/json_reference/#port-attributes + "portsAttributes": { + "8080": { + "label": "Plone Backend", + "onAutoForward": "notify" + } + }, + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "make install && .venv/bin/zconsole run instance/etc/zope.conf setup-codespace.py" +} diff --git a/setup-codespace.py b/setup-codespace.py new file mode 100644 index 0000000000..c87962dbed --- /dev/null +++ b/setup-codespace.py @@ -0,0 +1,9 @@ +import os +import transaction + +CODESPACE_NAME = os.environ.get("CODESPACE_NAME", None) +if CODESPACE_NAME: + DOMAIN = os.environ["GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN"] + hostname = f"{CODESPACE_NAME}-8080.{DOMAIN}" + app.virtual_hosting.set_map(f"localhost:8080/VirtualHostBase/https/{hostname}:443/VirtualHostRoot") + transaction.commit()