Skip to content

Commit

Permalink
Remove docker (#20)
Browse files Browse the repository at this point in the history
* chore(docker): remove docker + cleanup docs
* fix(server): remove correct websockets
* ver 0.5.1
  • Loading branch information
jerdog authored Dec 20, 2024
1 parent a82d553 commit 2e55362
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 291 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/docker-publish.yml

This file was deleted.

6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ dist/
build/
*.egg-info/

# Docker
.docker/
docker-compose.override.yml
*.env
!example.env

# Testing
.coverage
htmlcov/
Expand Down
60 changes: 0 additions & 60 deletions Dockerfile

This file was deleted.

35 changes: 7 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A cross-platform desktop notification system for Bluesky. Monitor and receive notifications from your favorite Bluesky accounts.

[![Version](https://img.shields.io/badge/version-0.4.2-blue.svg)](https://github.com/jerdog/bluesky-notify)
[![Version](https://img.shields.io/badge/version-0.5.1-blue.svg)](https://github.com/jerdog/bluesky-notify)
[![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![Flask](https://img.shields.io/badge/Flask-3.1.0-blue)](https://pypi.org/project/Flask/)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
Expand All @@ -12,17 +12,14 @@ https://pypi.org/project/bluesky-notify/
## Features

- Monitor multiple Bluesky accounts for new posts
- Real-time browser notifications in Docker environment
- Desktop notifications support across platforms (macOS, Linux, Windows)
- Daemon mode for continuous monitoring
- Web interface for easy account management
- Email notifications support (requires Mailgun configuration)
- XDG-compliant configuration storage
- SQLite database for reliable post tracking
- Cross-platform compatibility
- Consistent CLI interface with clear version and configuration information
- Comprehensive logging system with rotation and separate error logs
- WebSocket support for real-time updates in Docker environment

## Installation

Expand All @@ -41,7 +38,7 @@ bluesky-notify --version

Example output:
```
Bluesky Notify v0.4.1
Bluesky Notify v0.5.1
Config: /Users/username/.local/share/bluesky-notify

A cross-platform desktop notification system for Bluesky. Monitor and receive notifications from your favorite Bluesky accounts.
Expand Down Expand Up @@ -73,7 +70,7 @@ The application uses the XDG Base Directory Specification for storing its data:
- Configuration: `~/.config/bluesky-notify/`
- Data: `~/.local/share/bluesky-notify/`
- Cache: `~/.cache/bluesky-notify/`
- Logs:
- Logs:
- macOS: `~/Library/Logs/bluesky-notify/`
- Linux: `~/.local/share/bluesky-notify/logs/`
Expand All @@ -85,17 +82,6 @@ The web interface runs on port 3000 by default. On macOS, port 5000 is avoided a
bluesky-notify settings --port NUMBER
```

### Email Notifications (Optional)

To enable email notifications, set the following environment variables:

```bash
export MAILGUN_API_KEY='your-api-key'
export MAILGUN_DOMAIN='your-domain'
export MAILGUN_FROM_EMAIL='[email protected]'
export MAILGUN_TO_EMAIL='[email protected]'
```

## Usage

### Starting the Service
Expand Down Expand Up @@ -127,7 +113,6 @@ Note: The handle should be provided without the '@' symbol.

Options:
- `--desktop/--no-desktop`: Enable/disable desktop notifications (default: enabled)
- `--email/--no-email`: Enable/disable email notifications (default: disabled)

### Listing Monitored Accounts

Expand All @@ -149,18 +134,9 @@ bluesky-notify remove username.bsky.social

Update notification preferences:
```bash
bluesky-notify update username.bsky.social --desktop/--no-desktop --email/--no-email
bluesky-notify update username.bsky.social --desktop/--no-desktop
```

## Docker Support

When running in Docker, the application supports browser notifications through WebSocket connections. The web interface will automatically detect the Docker environment and enable real-time notifications.

### Environment Variables

- `DOCKER_CONTAINER`: Set to 'true' to enable Docker-specific features
- `PORT`: Override the default port (default: 5001 in Docker)

## Logging

The application uses a comprehensive logging system:
Expand Down Expand Up @@ -222,6 +198,9 @@ If you encounter any issues or have questions, please file an issue on the GitHu

## Version History

- 0.5.1: Remove docker functionality
- 0.5.0: Cleanup codebase, remove old functionality
- 0.4.4: Fix erratic notification issues
- 0.4.2: Enhance monitoring + logging
- 0.4.1: Validate Docker container image builds correctly, make CLI co-exist
- 0.4.0: Add web interface to daemon + terminal mode
Expand Down
29 changes: 0 additions & 29 deletions docker-compose.yml

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "bluesky-notify"
version = "0.5.0"
version = "0.5.1"
authors = [
{ name = "Jeremy Meiss", email = "[email protected]" },
]
Expand Down
16 changes: 7 additions & 9 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ def start_notifier_thread(flask_app):
"""Start the notification service in a new event loop."""
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

# Create app context
with flask_app.app_context():
loop.run_until_complete(run_notifier(flask_app))

loop.close()

if __name__ == "__main__":
Expand All @@ -48,20 +48,18 @@ def start_notifier_thread(flask_app):
settings = Settings()
current_settings = settings.get_settings()
port = current_settings.get('port', 5001)

logger.info("Starting Bluesky Notification Tracker...")
is_container = os.environ.get('DOCKER_CONTAINER', 'false').lower() == 'true'


# Start the notification service in a separate thread
notifier_thread = threading.Thread(target=start_notifier_thread, args=(app,), daemon=True)
notifier_thread.start()
logger.info("Notification service started in background")

# Start the web server
run_server(
host="0.0.0.0" if is_container else "127.0.0.1",
port=port,
debug=not is_container # Disable debug mode in container
host="127.0.0.1",
port=port
)
except Exception as e:
logger.error(f"Application failed to start: {e}")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name="bluesky-notify",
version="0.5.0",
version="0.5.1",
description="Bluesky Notification Manager - Track and receive notifications from Bluesky accounts",
author="Jeremy Meiss",
author_email="[email protected]",
Expand Down
12 changes: 1 addition & 11 deletions src/bluesky_notify/api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,10 @@ def index():
"""Serve the main page."""
return render_template('index.html')

@app.route('/health')
def health_check():
"""Health check endpoint for Docker container."""
return jsonify({
'status': 'healthy',
'timestamp': datetime.now().isoformat()
}), 200

# Register blueprints
app.register_blueprint(bp, url_prefix='/api')

if __name__ == '__main__':
# Use port 3001 for local development, 5001 for Docker
is_docker = os.path.exists('/.dockerenv')
default_port = 5001 if is_docker else 3001
default_port = 5001
port = int(os.environ.get('PORT', default_port))
app.run(host='0.0.0.0', port=port, debug=False)
30 changes: 0 additions & 30 deletions src/bluesky_notify/api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,36 +151,6 @@ def broadcast_notification(title, message, url):
if not has_websocket:
return

notification = {
'type': 'notification',
'title': title,
'message': message,
'url': url
}
with ws_lock:
disconnected = set()
for client in ws_clients:
try:
client.send(json.dumps(notification))
except Exception:
disconnected.add(client)
# Clean up disconnected clients
for client in disconnected:
ws_clients.remove(client)

if has_websocket:
@sock.route('/ws')
def ws_handler(ws):
"""Handle WebSocket connections for real-time notifications."""
with ws_lock:
ws_clients.add(ws)
try:
while True:
# Keep connection alive and handle disconnection
ws.receive()
except Exception:
with ws_lock:
ws_clients.remove(ws)

@app.route('/shutdown', methods=['GET'])
def shutdown():
Expand Down
3 changes: 0 additions & 3 deletions src/bluesky_notify/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

def get_port() -> int:
"""Get the appropriate port based on the environment."""
# Check if we're running in Docker
if os.environ.get('DOCKER_CONTAINER') == 'true':
return int(os.environ.get('PORT', 5001)) # Docker container port

# For macOS, never use port 5000 as it's reserved for AirPlay
if platform.system() == 'Darwin':
Expand Down
2 changes: 0 additions & 2 deletions src/bluesky_notify/services/launchd/com.bluesky-notify.plist
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
<string>/Users/jerdog/Library/Logs/bluesky-notify.error.log</string>
<key>EnvironmentVariables</key>
<dict>
<key>DOCKER_CONTAINER</key>
<string>false</string>
<key>PATH</key>
<string>/opt/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
<key>HOME</key>
Expand Down
1 change: 0 additions & 1 deletion src/bluesky_notify/services/systemd/bluesky-notify.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ After=network.target

[Service]
Type=simple
Environment="DOCKER_CONTAINER=false"
ExecStart=/usr/local/bin/bluesky-notify start
Restart=always
RestartSec=10
Expand Down
Loading

0 comments on commit 2e55362

Please sign in to comment.