Skip to content
Merged
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
27 changes: 27 additions & 0 deletions .devcontainer/00-blind-by-design_02-intermediate/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "πŸ§ͺ Adventure 00 | 🟑 Intermediate (Outcome by cohort)",
"dockerComposeFile": "docker-compose.yml",
"service": "workspace",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}/adventures/planned/00-blind-by-design/intermediate",
"postCreateCommand": "bash /workspaces/${localWorkspaceFolderBasename}/.devcontainer/00-blind-by-design_02-intermediate/post-create.sh",
"postStartCommand": "bash /workspaces/${localWorkspaceFolderBasename}/.devcontainer/00-blind-by-design_02-intermediate/post-start.sh",
"customizations": {
"vscode": {
"extensions": [
"vscjava.vscode-java-pack",
"vmware.vscode-spring-boot",
"vscjava.vscode-spring-boot-dashboard"
]
},
"codespaces": {
"openFiles": [
"adventures/planned/00-blind-by-design/docs/intermediate.md",
"adventures/planned/00-blind-by-design/intermediate/src/main/java/dev/openfeature/demo/java/demo/OpenFeatureConfig.java",
"adventures/planned/00-blind-by-design/intermediate/flags.json"
]
}
},
"otherPortsAttributes": {
"onAutoForward": "ignore"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Multi-container devcontainer for Intermediate. The lab itself runs in
# `workspace`; flagd runs as a sibling so participants who finish the
# FILE-mode path early can flip the FlagdProvider to RPC mode and talk
# to flagd:8013 without any Docker-in-Docker dance.
#
# Both services bind-mount the same workspace at the same path. flagd
# watches the participant's flags.json directly β€” edit it in the IDE,
# the file watcher reloads.

services:
workspace:
image: mcr.microsoft.com/devcontainers/java:1-21
volumes:
- ../..:/workspaces/${localWorkspaceFolderBasename:-open-ecosystem-challenges}:cached
command: sleep infinity
environment:
# Pre-set FLAGD_HOST so participants who switch to RPC mode in
# OpenFeatureConfig do not have to hard-code the hostname.
- FLAGD_HOST=flagd
- FLAGD_PORT=8013
# The trial's country of registration. Used by OpenFeatureConfig
# via System.getenv("COUNTRY") to populate the global eval context.
# `de` by default so F5 / Spring Boot Dashboard runs already exercise
# the country-targeting branch. Override with run-austria.sh or
# `COUNTRY=at ./mvnw spring-boot:run` to flip.
- COUNTRY=de

flagd:
image: ghcr.io/open-feature/flagd:v0.15.4
container_name: side-effects-intermediate-flagd
volumes:
- ../..:/workspaces/${localWorkspaceFolderBasename:-open-ecosystem-challenges}:ro
command:
- start
- --uri
- file:/workspaces/${localWorkspaceFolderBasename:-open-ecosystem-challenges}/adventures/planned/00-blind-by-design/intermediate/flags.json
# No `ports:` block β€” the lab reaches flagd on the docker-internal
# network as `flagd:8013`. Only :8080 is forwarded into the Codespace.
30 changes: 30 additions & 0 deletions .devcontainer/00-blind-by-design_02-intermediate/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -e

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"

# shellcheck disable=SC1091
source "$REPO_ROOT/lib/scripts/tracker.sh"
set_tracking_context "00-blind-by-design" "intermediate"
track_codespace_created

"$REPO_ROOT/lib/shared/init.sh" --version v0.17.0 # https://github.com/charmbracelet/gum/releases

# jq is needed by verify.sh; the Java devcontainer image is debian-based.
if ! command -v jq >/dev/null 2>&1; then
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends jq
fi

CHALLENGE_DIR="$REPO_ROOT/adventures/planned/00-blind-by-design/intermediate"

# Make the Maven wrapper executable so the participant can just `./mvnw ...`
if [[ -f "$CHALLENGE_DIR/mvnw" ]]; then
chmod +x "$CHALLENGE_DIR/mvnw"
fi

echo "✨ Pre-warming the Maven dependency cache so the first ./mvnw is fast..."
( cd "$CHALLENGE_DIR" && ./mvnw -q -DskipTests dependency:go-offline ) || \
echo "⚠️ Dependency pre-warm skipped (network or wrapper not ready yet)"

echo "βœ… Post-create complete."
53 changes: 53 additions & 0 deletions .devcontainer/00-blind-by-design_02-intermediate/post-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -e

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
CHALLENGE_DIR="$REPO_ROOT/adventures/planned/00-blind-by-design/intermediate"

cat <<EOF

✨ Level 2 - 🟑 Intermediate (Outcome by cohort)

πŸ“‚ Challenge directory:
$CHALLENGE_DIR

πŸ§ͺ Sibling services already running (managed by devcontainer compose):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are multiple ports mentioned here but only 8080 is forwarded in devcontainer.json. is that intended?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As everything happens in teh terminal: do we even need to forward any port?

- flagd β†’ reachable inside the compose network as flagd:8013 (gRPC).
No host-side forwarding β€” the lab calls it container-to-container.

β–Ά Run the lab β€” three named launch configs ship in .vscode/launch.json:
πŸ‡©πŸ‡ͺ Run the Lab β€” Germany (COUNTRY=de)
πŸ‡¦πŸ‡Ή Run the Lab β€” Austria (COUNTRY=at)
🌍 Run the Lab β€” No country
Open the Run and Debug view (Ctrl/Cmd + Shift + D) and pick one.

Or from the terminal:
./run-germany.sh # COUNTRY=de + tee app.log
./run-austria.sh # COUNTRY=at + tee app.log

πŸ‘‰ In another terminal, exercise the cohorts:
curl 'http://localhost:8080/?species=zyklop' # per-subject targeting
curl 'http://localhost:8080/' # falls through to country branch

βœ… Run the verification when you're ready:
./verify.sh
or use the πŸ§ͺ Verify Solution task: Tasks β†’ Run Test Task.

EOF

# Track that the environment is ready
# shellcheck disable=SC1091
source "$REPO_ROOT/lib/scripts/tracker.sh"
set_tracking_context "blind-by-design" "intermediate"
track_codespace_initialized

# Open the relevant files in the connected editor. customizations.codespaces.openFiles
# is unreliable for dockerComposeFile-based devcontainers (the orchestrator merges
# devcontainer.json and the field is sometimes dropped). `code` is the same CLI the
# editor uses internally and works against either the web or desktop client.
if command -v code >/dev/null 2>&1; then
code "$REPO_ROOT/adventures/planned/00-blind-by-design/docs/intermediate.md" \
"$CHALLENGE_DIR/src/main/java/dev/openfeature/demo/java/demo/OpenFeatureConfig.java" \
"$CHALLENGE_DIR/flags.json" \
2>/dev/null || true
fi
Loading
Loading