-
-
Notifications
You must be signed in to change notification settings - Fork 163
feat: Introduce two-command local development setup (#962) #963
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
Open
Lakshya-2440
wants to merge
18
commits into
alphaonelabs:main
Choose a base branch
from
Lakshya-2440:feature/local-dev-sandbox
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ea4d5eb
Local Development Sandbox, setup made easier
Lakshya-2440 bcdd182
fix(devcontainer): strip comments to fix JSON linting
Lakshya-2440 0292d53
ci: run smoke test on .env.sample changes
Lakshya-2440 f368b72
ci: fail the job if npm run doctor fails
Lakshya-2440 b4e8382
ci: quote SERVER_PID in bash scripts to prevent word splitting
Lakshya-2440 3e55b3f
fix(setup): escape sed special characters in generated secrets
Lakshya-2440 fc21cca
ci: commit scripts as executable and remove redundant chmod from work…
Lakshya-2440 06d31a8
ci: cache poetry instead of pip
Lakshya-2440 fc653b5
Apply PR review codebase fixes: devcontainer, doctor, setup, and dev …
Lakshya-2440 a56a553
Merge branch 'main' into feature/local-dev-sandbox
Lakshya-2440 f15df30
Merge branch 'main' into feature/local-dev-sandbox
Lakshya-2440 1aa5565
Merge branch 'main' into feature/local-dev-sandbox
Lakshya-2440 bb869b3
bug fixes
Lakshya-2440 dc95c66
fix(ci): run checks on all pull requests
Lakshya-2440 db19a15
chore: trigger CI again
Lakshya-2440 30e6643
chore: trigger CI via pr comment
Lakshya-2440 522d607
Fix trailing whitespace causing linting errors
Lakshya-2440 f424c50
Merge branch 'main' into feature/local-dev-sandbox
Lakshya-2440 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| { | ||
| "name": "Alpha One Labs — Dev", | ||
| "dockerComposeFile": "../docker-compose.dev.yml", | ||
| "service": "web", | ||
| "workspaceFolder": "/app", | ||
| "forwardPorts": [ | ||
| 8000, | ||
| 3306, | ||
| 6379 | ||
| ], | ||
| "postCreateCommand": "pip install poetry==1.8.3 && poetry config virtualenvs.create false --local && poetry install --no-interaction", | ||
| "postStartCommand": "python manage.py migrate --no-input && python manage.py collectstatic --noinput", | ||
Lakshya-2440 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "customizations": { | ||
| "vscode": { | ||
| "settings": { | ||
| "python.defaultInterpreterPath": "/usr/local/bin/python", | ||
| "python.linting.enabled": true, | ||
| "python.linting.flake8Enabled": true, | ||
Lakshya-2440 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "editor.formatOnSave": true, | ||
| "[python]": { | ||
| "editor.defaultFormatter": "ms-python.black-formatter" | ||
| } | ||
| }, | ||
| "extensions": [ | ||
| "ms-python.python", | ||
| "ms-python.vscode-pylance", | ||
| "ms-python.black-formatter", | ||
| "ms-python.isort", | ||
| "ms-python.flake8", | ||
| "batisteo.vscode-django", | ||
| "monosans.djlint" | ||
| ] | ||
| } | ||
| }, | ||
| "features": { | ||
| "ghcr.io/devcontainers/features/git:1": {} | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # ============================================================================= | ||
| # Onboarding Smoke Test | ||
| # | ||
| # Ensures that the setup script and dev server work on every PR. | ||
| # Uses SQLite (no Docker/MySQL needed) so the CI job is fast and simple. | ||
| # | ||
| # This test guards against regressions that would break new-contributor | ||
| # onboarding — if this job fails, someone can't get started. | ||
| # ============================================================================= | ||
| name: Onboarding Smoke Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "scripts/**" | ||
| - "package.json" | ||
| - "pyproject.toml" | ||
| - "poetry.lock" | ||
| - ".env.sample" | ||
| - ".github/workflows/onboarding-smoke-test.yml" | ||
| pull_request: | ||
| paths: | ||
| - "scripts/**" | ||
| - "package.json" | ||
| - "pyproject.toml" | ||
| - "poetry.lock" | ||
| - ".env.sample" | ||
| - ".github/workflows/onboarding-smoke-test.yml" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| smoke-test: | ||
| name: Setup & Boot | ||
| runs-on: ubuntu-latest | ||
Lakshya-2440 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python 3.10 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.10" | ||
| cache: "poetry" | ||
|
|
||
| - name: Set up Node.js (for npm run commands) | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
|
|
||
| - name: Run setup script | ||
| run: | | ||
| npm run setup | ||
|
|
||
| - name: Run doctor | ||
| run: | | ||
| npm run doctor | ||
|
|
||
| - name: Boot server and hit health endpoint | ||
| run: | | ||
|
|
||
Lakshya-2440 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Start the dev server in the background | ||
| npm run dev & | ||
| SERVER_PID=$! | ||
|
|
||
| # Wait for the server to be ready (up to 30 seconds) | ||
| echo "Waiting for server to start..." | ||
| for i in $(seq 1 30); do | ||
| if curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/en/ | grep -qE "200|301|302"; then | ||
| echo "Server is up! (attempt ${i})" | ||
| break | ||
| fi | ||
| if [ $i -eq 30 ]; then | ||
Lakshya-2440 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| echo "Server failed to start within 30 seconds" | ||
| kill "${SERVER_PID}" 2>/dev/null || true | ||
| exit 1 | ||
| fi | ||
| sleep 1 | ||
| done | ||
|
|
||
| # Verify the response | ||
| HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/en/) | ||
| echo "HTTP response code: ${HTTP_CODE}" | ||
|
|
||
| if echo "${HTTP_CODE}" | grep -qE "200|301|302"; then | ||
| echo "✔ Health check passed!" | ||
| else | ||
| echo "✖ Health check failed with HTTP ${HTTP_CODE}" | ||
| kill "${SERVER_PID}" 2>/dev/null || true | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Clean shutdown | ||
| kill "${SERVER_PID}" 2>/dev/null || true | ||
| wait "${SERVER_PID}" 2>/dev/null || true | ||
| echo "✔ Server stopped cleanly" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,5 @@ backup.json | |
| ansible/inventory.yml | ||
| education-website-*.json | ||
| *.sql | ||
| node_modules/ | ||
| .venv/ | ||
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
|
|
||
| > alphaonelabs-education-website@1.0.0 dev | ||
| > bash scripts/dev.sh | ||
|
|
||
| [0;34m[1mPre-flight checks...[0m | ||
| [0;32m ✔ .env file found[0m | ||
| [0;32m ✔ Python: /Users/lakshyagupta/Desktop/GSOC'26/OSL/alphaonelabs-education-website/.venv/bin/python[0m | ||
| [1;33m ⚠ Redis CLI not found — skipping Redis check.[0m | ||
| [1;33m ⚠ WebSocket features (chat, whiteboard) require Redis at runtime.[0m | ||
| [0;34m[1mCollecting static files...[0m | ||
| Sentry DSN not configured; error events will not be sent. | ||
| Using console email backend with Slack notifications for development | ||
| Warning: Service account file not found at /Users/lakshyagupta/Desktop/GSOC'26/OSL/alphaonelabs-education-website/your-service-account-file-path | ||
| [0;32m ✔ Static files ready[0m | ||
|
|
||
| [0;32m[1m══════════════════════════════════════════════════════════[0m | ||
| [0;32m[1m Alpha One Labs — Development Server[0m | ||
| [0;32m[1m══════════════════════════════════════════════════════════[0m | ||
|
|
||
| [0;36mLocal:[0m http://localhost:8000 | ||
| [0;36mNetwork:[0m http://0.0.0.0:8000 | ||
| [0;36mAdmin:[0m http://localhost:8000/a-dmin-url123/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| # ============================================================================= | ||
| # docker-compose.dev.yml — Local development services | ||
| # | ||
| # Usage: docker compose -f docker-compose.dev.yml up | ||
| # | ||
| # Provides: Django (hot-reload), MySQL 8, Redis 7 | ||
| # Data persists across restarts via named volumes. | ||
| # ============================================================================= | ||
|
|
||
| services: | ||
| # --------------------------------------------------------------------------- | ||
| # MySQL 8 — relational database | ||
| # --------------------------------------------------------------------------- | ||
| db: | ||
| image: mysql:8.0 | ||
| restart: unless-stopped | ||
| environment: | ||
| MYSQL_ROOT_PASSWORD: rootpassword | ||
| MYSQL_DATABASE: education_website | ||
| MYSQL_USER: django | ||
| MYSQL_PASSWORD: django_password | ||
| ports: | ||
Lakshya-2440 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - "3306:3306" | ||
| volumes: | ||
| - mysql_data:/var/lib/mysql | ||
| healthcheck: | ||
| test: | ||
| [ | ||
| "CMD", | ||
| "mysqladmin", | ||
| "ping", | ||
| "-h", | ||
| "127.0.0.1", | ||
| "-u", | ||
| "root", | ||
| "-prootpassword", | ||
| ] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 5 | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Redis 7 — channel layer for Django Channels (WebSockets) | ||
| # --------------------------------------------------------------------------- | ||
| redis: | ||
| image: redis:7-alpine | ||
| restart: unless-stopped | ||
| ports: | ||
| - "6379:6379" | ||
| volumes: | ||
| - redis_data:/data | ||
| healthcheck: | ||
| test: ["CMD", "redis-cli", "ping"] | ||
| interval: 10s | ||
| timeout: 3s | ||
| retries: 5 | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Django web application — development server with hot-reload | ||
| # --------------------------------------------------------------------------- | ||
| web: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile | ||
| command: > | ||
| bash -c " | ||
| echo 'Waiting for MySQL...' && | ||
| while ! mysqladmin ping -h db -u django -pdjango_password --silent 2>/dev/null; do | ||
| sleep 1 | ||
| done && | ||
| echo 'MySQL is ready!' && | ||
| python manage.py migrate --no-input && | ||
| python manage.py create_test_data && | ||
| python manage.py collectstatic --noinput && | ||
| echo '========================================' && | ||
| echo ' Dev server: http://localhost:8000' && | ||
| echo '========================================' && | ||
| python manage.py runserver 0.0.0.0:8000 | ||
| " | ||
| volumes: | ||
| # Bind-mount the source code for hot-reload | ||
| - .:/app | ||
| # Prevent the container's venv from being overwritten by the bind mount | ||
| - /app/.venv | ||
| ports: | ||
| - "8000:8000" | ||
| environment: | ||
| - DATABASE_URL=mysql://django:django_password@db:3306/education_website | ||
| - REDIS_URL=redis://redis:6379/0 | ||
| - ENVIRONMENT=development | ||
| - DEBUG=True | ||
| - SECRET_KEY=docker-dev-secret-key-not-for-production | ||
| - DJANGO_SETTINGS_MODULE=web.settings | ||
| depends_on: | ||
| db: | ||
| condition: service_healthy | ||
| redis: | ||
| condition: service_healthy | ||
| restart: unless-stopped | ||
|
|
||
| volumes: | ||
| mysql_data: | ||
| driver: local | ||
| redis_data: | ||
| driver: local | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "name": "alphaonelabs-education-website", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "description": "Script runner for Alpha One Labs Education Platform — no Node dependencies required.", | ||
| "scripts": { | ||
| "setup": "bash scripts/setup.sh", | ||
| "dev": "bash scripts/dev.sh", | ||
| "doctor": "bash scripts/doctor.sh", | ||
| "test": "bash -c 'python manage.py test'" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| [virtualenvs] | ||
| create = false | ||
| create = true | ||
| in-project = true |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.