Skip to content

Commit 73fb626

Browse files
Add devcontainer config
1 parent 613b256 commit 73fb626

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM mcr.microsoft.com/devcontainers/python:1-3.12-bookworm
2+
3+
RUN apt-get update \
4+
&& apt-get install -y --no-install-recommends \
5+
ca-certificates \
6+
curl \
7+
git \
8+
gnupg \
9+
&& rm -rf /var/lib/apt/lists/*

.devcontainer/devcontainer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "ReactPy",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": ".."
6+
},
7+
// "remoteUser": "vscode",
8+
// "containerEnv": {
9+
// "BUN_INSTALL": "/home/vscode/.bun"
10+
// },
11+
// "remoteEnv": {
12+
// "BUN_INSTALL": "/home/vscode/.bun",
13+
// "PATH": "/home/vscode/.bun/bin:${containerEnv:PATH}"
14+
// },
15+
"postCreateCommand": "bash .devcontainer/post-create.sh",
16+
"customizations": {
17+
"vscode": {
18+
"settings": {
19+
"python.defaultInterpreterPath": "/usr/local/bin/python",
20+
"python.terminal.activateEnvironment": false
21+
},
22+
"extensions": [
23+
"ms-python.python",
24+
"ms-python.vscode-pylance",
25+
"charliermarsh.ruff",
26+
"ms-playwright.playwright"
27+
]
28+
}
29+
}
30+
}

.devcontainer/post-create.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
export BUN_INSTALL="${BUN_INSTALL:-$HOME/.bun}"
6+
export PATH="$BUN_INSTALL/bin:$PATH"
7+
8+
if [[ -f /etc/apt/sources.list.d/yarn.list ]]; then
9+
echo "Refreshing Yarn APT keyring..."
10+
curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg \
11+
| gpg --dearmor \
12+
| sudo tee /usr/share/keyrings/yarn-archive-keyring.gpg >/dev/null
13+
fi
14+
15+
if ! command -v hatch >/dev/null 2>&1; then
16+
echo "Installing Hatch..."
17+
python3 -m pip install --user hatch
18+
fi
19+
20+
if ! command -v bun >/dev/null 2>&1; then
21+
echo "Installing Bun..."
22+
curl -fsSL https://bun.sh/install | bash
23+
fi
24+
25+
echo "Building JavaScript packages..."
26+
hatch run javascript:build --dev
27+
28+
echo "Building Python package..."
29+
hatch build --clean
30+
31+
echo "Running ReactPy smoke test..."
32+
hatch run python - <<'PY'
33+
from reactpy import component, html
34+
35+
36+
@component
37+
def test_component():
38+
return html.div([
39+
html.h1("Test"),
40+
html.p("ReactPy is working"),
41+
])
42+
43+
44+
vdom = test_component()
45+
print(type(vdom).__name__)
46+
PY

0 commit comments

Comments
 (0)