Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev containers support for VS Code and GitHub Codespaces #970

Draft
wants to merge 6 commits into
base: 6.1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
9 changes: 9 additions & 0 deletions setup-codespace.py
Original file line number Diff line number Diff line change
@@ -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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is app a global variable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiru Yes, for scripts run with zope's zconsole run command. I'll probably clean this up a bit...just a proof of concept so far

transaction.commit()