@@ -42,18 +42,24 @@ ruff check .
4242
4343```
4444NASASpaceAppsChallenge2025/
45- ├── requirements.txt # FastAPI and Uvicorn dependencies
45+ ├── requirements.txt # FastAPI and Uvicorn dependencies
4646├── src/
4747│ ├── __init__.py
48- │ └── server.py # FastAPI application serving the HTML page
48+ │ └── server.py # FastAPI application serving the HTML page
4949├── web/
50- │ ├── index.html # Landing page served at the root route
51- │ └── aladin.html # Secondary page under /aladin
50+ │ ├── index.html # Landing page served at the root route
51+ │ ├── aladin.html # FITS explorer with Aladin Lite integration
52+ │ └── styles.css # Styling for the viewer interface
5253├── deploy/
53- │ └── remote_deploy.sh # Remote helper script invoked by the CI workflow
54- └── .github/
55- └── workflows/
56- └── deploy.yml # Continuous deployment pipeline for EC2
54+ │ ├── remote_deploy.sh # Remote deployment script (run on EC2)
55+ │ └── nasaspaceapps.service.template # SystemD service unit template
56+ ├── .github/
57+ │ └── workflows/
58+ │ └── deploy.yml # Continuous deployment pipeline for EC2
59+ ├── README.md # Main documentation
60+ ├── MIGRATION.md # Migration guide for existing deployments
61+ ├── DEPLOYMENT_CHANGES.md # Detailed deployment architecture documentation
62+ └── OPS_REFERENCE.md # Quick reference for operations team
5763```
5864
5965Feel free to extend the UI with annotations, multi-layer comparisons, or temporal sliders to address the broader Space Apps challenge goals.
@@ -64,33 +70,46 @@ Every push to `main` triggers the GitHub Actions workflow in `.github/workflows/
6470pipeline performs the following steps:
6571
66721 . Checks out the latest code.
67- 2 . Copies the repository to your EC2 instance via ` rsync ` (preserving any existing ` .venv ` or
68- ` logs ` folders).
69- 3 . Runs ` deploy/remote_deploy.sh ` on the instance to create/refresh a virtual environment, install
70- dependencies, and restart the application via ` systemd ` when available. If a systemd service is
71- not present, it falls back to launching Uvicorn in the background with ` nohup ` .
73+ 2 . Copies the repository to ` /opt/nasa-sky-explorer ` on your EC2 instance via ` rsync ` .
74+ 3 . Creates a dedicated service user (` nasaapp ` ) if it doesn't exist.
75+ 4 . Sets proper ownership and permissions for the application directory.
76+ 5 . Installs Python dependencies in a virtual environment owned by the service user.
77+ 6 . Applies necessary capabilities to bind to port 80 (if running on a privileged port).
78+ 7 . Restarts the systemd service or launches Uvicorn as a background process.
7279
7380### Required GitHub secrets
7481
7582Create the following secrets at ** Settings → Secrets and variables → Actions** :
7683
7784- ` EC2_HOST ` – Public DNS name or IP address of the instance.
78- - ` EC2_USER ` – SSH user (for example, ` ubuntu ` ).
85+ - ` EC2_USER ` – SSH user with sudo privileges (for example, ` ubuntu ` ).
7986- ` EC2_SSH_KEY ` – Private SSH key allowed to log in as ` EC2_USER ` .
8087
8188### Optional overrides
8289
8390You can customise the deployment without editing the workflow by providing additional (optional)
8491secrets:
8592
86- - ` EC2_APP_DIR ` – Absolute path where the repo should live (defaults to ` /home/ubuntu /nasa-sky-explorer ` ).
93+ - ` EC2_APP_DIR ` – Absolute path where the repo should live (defaults to ` /opt /nasa-sky-explorer ` ).
8794- ` EC2_PYTHON_BIN ` – Python interpreter used to build the virtual environment (defaults to
8895 ` /usr/bin/python3 ` ).
8996- ` EC2_SERVICE_NAME ` – Name of the ` systemd ` service to restart (defaults to ` nasaspaceapps ` ).
90- - ` EC2_UVICORN_PORT ` – Port exposed by Uvicorn when no ` systemd ` unit is available (defaults to
91- ` 8000 ` ).
97+ - ` EC2_UVICORN_PORT ` – Port exposed by Uvicorn (defaults to ` 80 ` ).
9298
93- Ensure the EC2 machine has ` git ` , ` rsync ` , ` python3 ` , and ` pip ` installed. If you prefer a managed
94- service, create a ` systemd ` unit named after ` EC2_SERVICE_NAME ` that executes
95- ` /home/ubuntu/nasa-sky-explorer/.venv/bin/uvicorn src.server:app --host 0.0.0.0 --port 8000 `
96- and the workflow will restart it after each deployment.
99+ ### Setting up the systemd service
100+
101+ For production use, create a systemd service to manage the application lifecycle:
102+
103+ ``` bash
104+ # On your EC2 instance:
105+ sudo cp /opt/nasa-sky-explorer/deploy/nasaspaceapps.service.template /etc/systemd/system/nasaspaceapps.service
106+ sudo systemctl daemon-reload
107+ sudo systemctl enable nasaspaceapps.service
108+ sudo systemctl start nasaspaceapps.service
109+ ```
110+
111+ The service runs as the ` nasaapp ` user and automatically restarts on failure. Logs are written to
112+ ` /opt/nasa-sky-explorer/logs/uvicorn.log ` .
113+
114+ ** Note:** The application directory ` /opt/nasa-sky-explorer ` is accessible to all sudo users, and the
115+ service runs under a dedicated unprivileged user (` nasaapp ` ) for security.
0 commit comments