@@ -38,38 +38,51 @@ NASASpaceAppsChallenge2025/
3838├── src/
3939│ ├── __init__.py
4040│ └── server.py # FastAPI application serving the HTML page
41- └── web/
42- └── index.html # Static HTML served at the root route
43- └── deploy/
44- └── deploy.sh # Helper script to install and run the service via systemd
41+ ├── web/
42+ │ ├── index.html # Landing page served at the root route
43+ │ └── aladin.html # Secondary page under /aladin
44+ ├── deploy/
45+ │ └── remote_deploy.sh # Remote helper script invoked by the CI workflow
46+ └── .github/
47+ └── workflows/
48+ └── deploy.yml # Continuous deployment pipeline for EC2
4549```
4650
4751Feel free to build on this foundation for richer APIs or interfaces.
4852
49- ## Deployment script
53+ ## Continuous deployment to EC2
5054
51- The ` deploy/deploy.sh ` script provisions the application on a Linux host using ` systemd ` . It:
55+ Every push to ` main ` triggers the GitHub Actions workflow in ` .github/workflows/deploy.yml ` . The
56+ pipeline performs the following steps:
5257
53- - Syncs the repository into ` /opt/nasa-sky-app/app ` (configurable with ` APP_ROOT ` ).
54- - Ensures ` /opt/nasa-sky-app ` exists with the proper ownership, then syncs code and creates a
55- virtual environment for dependencies.
56- - Generates a ` systemd ` unit that runs Uvicorn on port ` 80 ` by default.
57- - Enables and restarts the service.
58+ 1 . Checks out the latest code.
59+ 2 . Copies the repository to your EC2 instance via ` rsync ` (preserving any existing ` .venv ` or
60+ ` logs ` folders).
61+ 3 . Runs ` deploy/remote_deploy.sh ` on the instance to create/refresh a virtual environment, install
62+ dependencies, and restart the application via ` systemd ` when available. If a systemd service is
63+ not present, it falls back to launching Uvicorn in the background with ` nohup ` .
5864
59- Run it directly on the target server after cloning or syncing the repository:
65+ ### Required GitHub secrets
6066
61- ``` bash
62- chmod +x deploy/deploy.sh
63- APP_ROOT=/opt/nasa-sky-app SERVICE_NAME=nasa-sky-app ./deploy/deploy.sh
64- ```
67+ Create the following secrets at ** Settings → Secrets and variables → Actions** :
68+
69+ - ` EC2_HOST ` – Public DNS name or IP address of the instance.
70+ - ` EC2_USER ` – SSH user (for example, ` ubuntu ` ).
71+ - ` EC2_SSH_KEY ` – Private SSH key allowed to log in as ` EC2_USER ` .
72+
73+ ### Optional overrides
6574
66- Override ` SERVICE_USER ` , ` SERVICE_GROUP ` , ` PORT ` , or ` PYTHON_BIN ` to fit your environment. When the
67- port is below ` 1024 ` (the default ` 80 ` ), the generated unit grants
68- ` CAP_NET_BIND_SERVICE ` so the application can bind to the port without running as root.
75+ You can customise the deployment without editing the workflow by providing additional (optional)
76+ secrets:
6977
70- ### GitHub Actions deployment
78+ - ` EC2_APP_DIR ` – Absolute path where the repo should live (defaults to ` /home/ubuntu/nasa-sky-explorer ` ).
79+ - ` EC2_PYTHON_BIN ` – Python interpreter used to build the virtual environment (defaults to
80+ ` /usr/bin/python3 ` ).
81+ - ` EC2_SERVICE_NAME ` – Name of the ` systemd ` service to restart (defaults to ` nasaspaceapps ` ).
82+ - ` EC2_UVICORN_PORT ` – Port exposed by Uvicorn when no ` systemd ` unit is available (defaults to
83+ ` 8000 ` ).
7184
72- A workflow at ` .github/workflows/deploy.yml ` uses the repository secrets ` EC2_HOST ` , ` EC2_USER ` ,
73- and ` EC2_SSH_KEY ` to sync the codebase to an Ubuntu 24.04 EC2 instance and execute the deployment
74- script remotely. It runs on every push to ` main ` (and can be triggered manually). Optional
75- repository variable ` DEPLOY_PORT ` lets you override the port without editing the workflow .
85+ Ensure the EC2 machine has ` git ` , ` rsync ` , ` python3 ` , and ` pip ` installed. If you prefer a managed
86+ service, create a ` systemd ` unit named after ` EC2_SERVICE_NAME ` that executes
87+ ` /home/ubuntu/nasa-sky-explorer/.venv/bin/uvicorn src.server:app --host 0.0.0.0 --port 8000 `
88+ and the workflow will restart it after each deployment .
0 commit comments