Skip to content

Commit 53b90bd

Browse files
explodedclaude
andcommitted
Tidy README structure
- Move GitHub secrets and deployment trigger into a dedicated Deployment section - Add Configuration parent heading for Environment Variables and Server Settings - Fix Windows Development code block indentation - Normalise copyright years to 2020-2026 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b7b1ba5 commit 53b90bd

1 file changed

Lines changed: 16 additions & 299 deletions

File tree

README.md

Lines changed: 16 additions & 299 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ A web application that calculates and displays moon rise and set times for any l
88
- Automatic geolocation detection
99
- Smart timezone selector with auto-detection and 50+ timezones
1010
- Real-time moon rise and set calculations
11-
- 10-day calendar view with sun and moon times
12-
- Fully responsive design for mobile and desktop
13-
- Security headers and CSP protection
14-
- Static asset caching for performance
15-
- ARIA accessibility features
11+
- Full month calendar view with sun and moon times
1612

1713
## Technology Stack
1814

@@ -21,11 +17,6 @@ A web application that calculates and displays moon rise and set times for any l
2117
- **Maps**: Google Maps JavaScript API with AdvancedMarkerElement
2218
- **Calculations**: [riseset](https://github.com/exploded/riseset) library
2319

24-
## Prerequisites
25-
26-
- Go 1.21 or higher
27-
- Google Maps API key with Maps JavaScript API enabled
28-
2920
## Local Development
3021

3122
1. **Clone the repository**
@@ -40,10 +31,8 @@ A web application that calculates and displays moon rise and set times for any l
4031
```
4132

4233
3. **Set up environment variables**
43-
```bash
44-
cp .env.example .env
45-
```
46-
Edit `.env` and set your values:
34+
Use .env.example to create your own .env file
35+
4736
```env
4837
GOOGLE_MAPS_API_KEY=your_actual_api_key_here
4938
PROD=False
@@ -61,43 +50,20 @@ A web application that calculates and displays moon rise and set times for any l
6150
- For local development: `http://localhost:8484/*`
6251
- **API restrictions**: Restrict key to "Maps JavaScript API" only
6352
- Set usage quotas to prevent abuse
64-
65-
> **Security Note**: Google Maps JavaScript API keys are client-side visible by design. The security comes from properly configuring API key restrictions in Google Cloud Console, not from hiding the key.
66-
67-
## Running the Application
68-
69-
### Development
7053

71-
```bash
72-
# Load environment variables and run
73-
go run moon.go
74-
```
75-
76-
The server will start on `http://localhost:8484`
54+
> **Security Note**: Google Maps JavaScript API keys are client-side visible by design. The security comes from properly configuring API key restrictions in Google Cloud Console, not from hiding the key.
7755
7856
### Windows Development
7957

80-
Use the provided batch files:
81-
82-
1. **First time setup:**
83-
```cmd
84-
build.bat
85-
```
86-
This will:
87-
- Build the application
88-
- Create `.env` from `.env.example` if missing
89-
- Prompt you to add your API key
58+
```cmd
59+
build.bat
60+
```
9061

91-
2. **Edit `.env`** and replace the placeholder with your actual API key
62+
Or for quick restart (when already built):
9263

93-
3. **Run the application:**
94-
```cmd
95-
build.bat
96-
```
97-
or for quick restart (when already built):
98-
```cmd
99-
run.bat
100-
```
64+
```cmd
65+
run.bat
66+
```
10167

10268
### Cross-Compilation (Building for Linux from Windows)
10369

@@ -108,220 +74,21 @@ set GOARCH=amd64
10874
go build -o moon
10975
```
11076

111-
**Build for Debian/Ubuntu (arm64 - Raspberry Pi, etc):**
112-
```cmd
113-
set GOOS=linux
114-
set GOARCH=arm64
115-
go build -o moon
116-
```
117-
11877
**Build for Windows (local):**
11978
```cmd
12079
set GOOS=windows
12180
set GOARCH=amd64
12281
go build -o moon.exe
12382
```
12483

125-
Or use PowerShell:
126-
```powershell
127-
$env:GOOS="linux"; $env:GOARCH="amd64"; go build -o moon
128-
```
129-
130-
Then upload the `moon` binary to your Debian server.
131-
132-
### Production
133-
134-
```bash
135-
# Build the binary
136-
go build -o moon
137-
138-
# Set environment variables
139-
export GOOGLE_MAPS_API_KEY="your_key_here"
140-
export PROD="True"
141-
142-
# Run the server
143-
./moon
144-
```
145-
146-
### Using systemd (Linux)
147-
148-
1. Build and install the binary:
149-
```bash
150-
go run moon.go
151-
```
152-
The server starts on `http://localhost:8484`
153-
154-
### Google Maps API Key
155-
156-
- Go to [Google Cloud Console](https://console.cloud.google.com/)
157-
- Enable "Maps JavaScript API" and create an API key
158-
- Restrict the key to HTTP referrers (`http://localhost:8484/*` for dev, your domain for prod) and to "Maps JavaScript API" only
159-
160-
4. Install and enable the service:
161-
```bash
162-
sudo cp moon.service /etc/systemd/system/
163-
sudo systemctl daemon-reload
164-
sudo systemctl enable moon
165-
sudo systemctl start moon
166-
sudo systemctl status moon
167-
```
168-
169-
### Debian/Ubuntu Production Deployment
170-
171-
#### 1. Deploy Application
172-
173-
```bash
174-
# Create application directory
175-
sudo mkdir -p /var/www/moon
176-
sudo chown $USER:$USER /var/www/moon
177-
178-
# Clone or copy your application
179-
cd /var/www/moon
180-
# ... copy your files here ...
181-
182-
# Install dependencies
183-
go mod download
184-
185-
# Build the application
186-
go build -o moon
187-
188-
# Make executable
189-
chmod +x moon
190-
```
191-
192-
#### 2. Build and Install Binary
193-
194-
```bash
195-
# Build for Linux (if cross-compiling from Windows, see Cross-Compilation section)
196-
cd /var/www/moon
197-
go build -o moon
198-
199-
# Install binary to system location
200-
sudo cp moon /usr/local/bin/moon
201-
sudo chmod +x /usr/local/bin/moon
202-
```
203-
204-
#### 3. Create Environment File
205-
206-
```bash
207-
sudo nano /usr/local/bin/moon-env
208-
```
209-
210-
Add:
211-
```env
212-
GOOGLE_MAPS_API_KEY=your_actual_api_key_here
213-
PROD=True
214-
```
215-
216-
```bash
217-
sudo chmod 600 /usr/local/bin/moon-env
218-
```
219-
220-
#### 4. Install and Start systemd Service
221-
222-
```bash
223-
# Copy service file
224-
sudo cp moon.service /etc/systemd/system/
225-
226-
# Set proper ownership for working directory
227-
sudo chown -R www-data:www-data /var/www/moon
228-
229-
# Reload systemd
230-
sudo systemctl daemon-reload
231-
232-
# Enable and start
233-
sudo systemctl enable moon
234-
sudo systemctl start moon
235-
236-
# Check status
237-
sudo systemctl status moon
238-
239-
# View logs
240-
sudo journalctl -u moon -f
241-
```
242-
243-
#### 5. Configure Nginx Reverse Proxy (Optional)
244-
245-
Install Nginx:
246-
```bash
247-
sudo apt install nginx -y
248-
```
249-
250-
Create site configuration:
251-
```bash
252-
sudo nano /etc/nginx/sites-available/moon
253-
```
254-
255-
```nginx
256-
server {
257-
listen 80;
258-
server_name your-domain.com;
259-
260-
location / {
261-
proxy_pass http://localhost:8484;
262-
proxy_http_version 1.1;
263-
proxy_set_header Upgrade $http_upgrade;
264-
proxy_set_header Connection 'upgrade';
265-
proxy_set_header Host $host;
266-
proxy_set_header X-Real-IP $remote_addr;
267-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
268-
proxy_set_header X-Forwarded-Proto $scheme;
269-
proxy_cache_bypass $http_upgrade;
270-
}
271-
}
272-
```
273-
274-
Enable site:
275-
```bash
276-
sudo ln -s /etc/nginx/sites-available/moon /etc/nginx/sites-enabled/
277-
sudo nginx -t
278-
sudo systemctl restart nginx
279-
```
280-
281-
#### 6. Setup SSL with Let's Encrypt (Optional)
282-
283-
```bash
284-
# Install certbot
285-
sudo apt install certbot python3-certbot-nginx -y
286-
287-
# Obtain certificate
288-
sudo certbot --nginx -d your-domain.com
289-
290-
# Auto-renewal is configured automatically
291-
# Test renewal:
292-
sudo certbot renew --dry-run
293-
```
294-
295-
#### 7. Firewall Configuration
296-
297-
```bash
298-
# If using UFW
299-
sudo ufw allow 'Nginx Full'
300-
sudo ufw allow OpenSSH
301-
sudo ufw enable
302-
sudo ufw status
303-
```
304-
305-
## CI/CD Deployment (GitHub Actions → Linode)
306-
307-
Every push to `master` automatically runs tests, builds a Linux binary, and deploys it to your Linode server via SSH.
308-
309-
### How it works
310-
311-
1. GitHub Actions runs `go test`
312-
2. If tests pass, it cross-compiles a Linux amd64 binary
313-
3. It SCPs the binary and web assets to the server
314-
4. It SSHs in, installs the files, and restarts the systemd service
315-
316-
### One-time server setup
317-
318-
Run the provided setup script **once** on your Linode server:
84+
## Testing
31985

32086
```bash
321-
sudo bash scripts/server-setup.sh
87+
go test -v
88+
go test -cover
32289
```
32390

324-
This creates a `deploy` user with SSH keys and the minimal sudoers permissions needed for deployment, then prints the secrets to add to GitHub.
91+
## Deployment
32592

32693
### GitHub repository secrets
32794

@@ -342,46 +109,6 @@ git push origin master
342109

343110
View deployment logs at `https://github.com/exploded/moon/actions`
344111

345-
## Testing
346-
347-
```bash
348-
go test -v
349-
go test -cover
350-
```
351-
352-
## Project Structure
353-
354-
```
355-
moon/
356-
├── moon.go # Main server application
357-
├── moon_test.go # Unit tests
358-
├── index.html # Home page
359-
├── about.html # About page
360-
├── calendar.html # Calendar view
361-
├── static/
362-
│ ├── styles.css # Global styles
363-
│ ├── script.js # Client-side JavaScript
364-
│ └── moon.jpg # Background image
365-
├── .github/
366-
│ └── workflows/
367-
│ └── deploy.yml # GitHub Actions CI/CD pipeline
368-
├── scripts/
369-
│ └── server-setup.sh # One-time Linode server setup
370-
├── go.mod # Go module dependencies
371-
├── .env.example # Environment variables template
372-
├── .gitignore # Git ignore rules
373-
├── moon.service # systemd service file
374-
└── README.md # This file
375-
```
376-
377-
## API Endpoints
378-
379-
- `GET /` - Home page with map interface
380-
- `GET /about` - About page
381-
- `GET /calendar` - Calendar view (query params: lat, lon, zon)
382-
- `GET /gettimes` - JSON API for moon times (query params: lat, lon, zon)
383-
- `GET /static/*` - Static assets (cached 7 days)
384-
385112
## Configuration
386113

387114
### Environment Variables
@@ -409,19 +136,9 @@ moon/
409136
- Graceful shutdown on SIGTERM/SIGINT
410137
- API key injected via server-side template rendering (not exposed via endpoint)
411138

412-
## Browser Support
413-
414-
Chrome/Edge, Firefox, Safari (all latest), iOS Safari, Chrome Mobile.
415-
416-
## Known Limitations
417-
418-
- Calendar view shows 10 days from current date
419-
- Requires JavaScript enabled
420-
- Geolocation requires HTTPS in production
421-
422139
## License
423140

424-
Copyright 2020, 2023, 2026 James McHugh
141+
Copyright 20202026 James McHugh
425142

426143
Licensed under the Apache License, Version 2.0. See [LICENSE](http://www.apache.org/licenses/LICENSE-2.0).
427144

0 commit comments

Comments
 (0)