Skip to content

Commit

Permalink
validated docker image works with cli
Browse files Browse the repository at this point in the history
  • Loading branch information
jerdog committed Nov 27, 2024
1 parent dc7337e commit 99825d5
Show file tree
Hide file tree
Showing 14 changed files with 604 additions and 311 deletions.
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Create necessary directories with proper permissions
RUN mkdir -p /app/src/bluesky_notify/data /app/logs /app/instance \
&& chmod -R 777 /app/src/bluesky_notify/data \
&& chmod -R 777 /app/logs \
&& chmod 777 /app/instance
RUN mkdir -p /app/.local/share/bluesky-notify/logs /app/.local/share/bluesky-notify/data \
&& chmod -R 777 /app/.local/share/bluesky-notify

# Create a non-root user
RUN useradd -m -r appuser \
Expand All @@ -43,12 +41,15 @@ RUN pip install --no-cache-dir .
# Switch to non-root user
USER appuser

# Set HOME for XDG base directories
ENV HOME=/app

# Expose the application port
EXPOSE 5001

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import requests; requests.get('http://localhost:5001/health')"
CMD curl -f http://localhost:5001/ || exit 1

# Run the application
CMD ["python", "run.py"]
Expand Down
205 changes: 92 additions & 113 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

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.0-blue.svg)](https://github.com/jerdog/bluesky-notify)
[![Version](https://img.shields.io/badge/version-0.4.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)

## 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
Expand All @@ -19,6 +20,7 @@ A cross-platform desktop notification system for Bluesky. Monitor and receive no
- 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 @@ -33,7 +35,7 @@ bluesky-notify --version

Example output:
```
Bluesky Notify v0.4.0
Bluesky Notify v0.4.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 All @@ -43,19 +45,19 @@ Usage: bluesky-notify [OPTIONS] COMMAND [ARGS]...
Run 'bluesky-notify start --daemon' to install and run as a system service.
Options:
--version Show version and exit
--help Show this message and exit.
--version Show version and exit
--help Show this message and exit
Commands:
add Add a Bluesky account to monitor.
list List all monitored Bluesky accounts and their notification...
remove Remove a Bluesky account from monitoring.
settings View or update application settings.
start Start the notification service.
status View the current status of the service.
stop Stop the notification service.
toggle Toggle monitoring status for a Bluesky account.
update Update notification preferences for a monitored account.
add Add a Bluesky account to monitor.
list List all monitored Bluesky accounts and their notification...
remove Remove a Bluesky account from monitoring.
settings View or update application settings.
start Start the notification service.
status View the current status of the service.
stop Stop the notification service.
toggle Toggle monitoring status for a Bluesky account.
update Update notification preferences for a monitored account.
```

## Configuration
Expand All @@ -65,6 +67,17 @@ 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:
- macOS: `~/Library/Logs/bluesky-notify/`
- Linux: `~/.local/share/bluesky-notify/logs/`

### Port Configuration

The web interface runs on port 3000 by default. On macOS, port 5000 is avoided as it's reserved for AirPlay. You can change the port using:

```bash
bluesky-notify settings --port NUMBER
```

### Email Notifications (Optional)

Expand All @@ -79,6 +92,18 @@ export MAILGUN_TO_EMAIL='[email protected]'

## Usage

### Starting the Service

Start the service with debug logging:
```bash
bluesky-notify start --log-level DEBUG
```

Start as a system service:
```bash
bluesky-notify start --daemon
```

### Command Help

To see all available commands and options:
Expand All @@ -104,136 +129,102 @@ Options:
bluesky-notify list
```

### Removing an Account

```bash
bluesky-notify remove username.bsky.social
```

### Toggling Account Status
### Managing Accounts

Toggle monitoring for an account:
```bash
bluesky-notify toggle username.bsky.social
```

### Updating Notification Preferences

```bash
bluesky-notify update username.bsky.social --desktop --no-email
```

### Checking Service Status

View the current status of the service:
```bash
bluesky-notify status
```

This will show:
- Service status (running/not running) and mode (terminal/daemon)
- Web interface status and URL
- Data directory location
- Current configuration

### Starting and Stopping the Service

Start the service:
Remove an account:
```bash
# Run in terminal mode
bluesky-notify start

# Run as system service (daemon mode)
bluesky-notify start --daemon
bluesky-notify remove username.bsky.social
```

Stop the service:
Update notification preferences:
```bash
bluesky-notify stop
bluesky-notify update username.bsky.social --desktop/--no-desktop --email/--no-email
```
The stop command will automatically detect whether the service is running in terminal or daemon mode and stop it accordingly.

### Viewing/Updating Settings
## Docker Support

View current settings:
```bash
bluesky-notify settings
```
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.

Update settings:
```bash
# Change check interval
bluesky-notify settings --interval 120
### Environment Variables

# Change log level
bluesky-notify settings --log-level debug
- `DOCKER_CONTAINER`: Set to 'true' to enable Docker-specific features
- `PORT`: Override the default port (default: 5001 in Docker)

# Change web interface port
bluesky-notify settings --port 8080
```

Available settings:
- Check interval (in seconds)
- Log level (DEBUG, INFO, WARNING, ERROR)
- Web interface port

### Logging
## Logging

The application uses a comprehensive logging system:

- Log files are stored in `~/.local/share/bluesky-notify/logs/`
- Log files are stored in platform-specific locations:
- macOS: `~/Library/Logs/bluesky-notify/`
- Linux: `~/.local/share/bluesky-notify/logs/`

- Two log files are maintained:
- `bluesky-notify.log`: General application logs (INFO level and above)
- `bluesky-notify.error.log`: Error-specific logs (ERROR level only)
- `bluesky-notify.error.log`: Error logs only (ERROR level)

- Log rotation is enabled:
- Maximum file size: 1MB
- Keeps up to 5 backup files
- Rotated files are named with numerical suffixes (e.g., bluesky-notify.log.1)

Log levels can be configured using the settings command:
```bash
bluesky-notify settings --log-level debug # Set to DEBUG level
bluesky-notify settings --log-level info # Set to INFO level (default)
```
- Debug logging can be enabled with:
```bash
bluesky-notify start --log-level DEBUG
```

## Version History
## Development

- 0.4.0: Add web interface to daemon + terminal mode
- 0.3.0: Add daemon mode, web interface, and improved CLI help text
- 0.2.7: Fixed CLI output formatting and help text organization
- 0.2.6: Enhanced CLI interface with consistent version and config display
- 0.2.5: Improved help text formatting and command output
- 0.2.4: Added version and config information to all commands
- 0.2.3: Refined CLI presentation and version display
- 0.2.0: Initial public release
### Requirements

## Development
- Python 3.9 or higher
- Dependencies listed in pyproject.toml

### Setting Up Development Environment

1. Clone the repository:
```bash
git clone https://github.com/jerdog/bluesky-notify.git
cd bluesky-notify
```

2. Create a virtual environment:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```

3. Install development dependencies:
2. Install development dependencies:
```bash
pip install -e ".[dev]"
```

4. Build the package:
3. Run tests:
```bash
python -m build
pytest
```

5. Install the built package:
```bash
pip install dist/bluesky_notify-0.4.0-py3-none-any.whl
```
## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.

## Version History

- 0.4.1: Validate Docker container image builds correctly, make CLI co-exist
- 0.4.0: Add web interface to daemon + terminal mode
- 0.3.0: Add daemon mode, web interface, and improved CLI help text
- 0.2.7: Fixed CLI output formatting and help text organization
- 0.2.6: Enhanced CLI interface with consistent version and config display
- 0.2.5: Improved help text formatting and command output
- 0.2.4: Added version and config information to all commands
- 0.2.3: Refined CLI presentation and version display
- 0.2.0: Initial public release

## Troubleshooting

Expand All @@ -250,15 +241,3 @@ pip install dist/bluesky_notify-0.4.0-py3-none-any.whl
- Verify Bluesky handles are entered correctly (without '@' symbol)
- Check your internet connection
- Ensure the Bluesky API is accessible

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.
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.4.0"
version = "0.4.1"
authors = [
{ name = "Jeremy Meiss", email = "[email protected]" },
]
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ sqlalchemy>=2.0.36
flask>=3.1.0
flask-cors>=5.0.0
flask-sqlalchemy>=3.1.1
flask-sock>=0.7.0
simple-websocket>=0.10.1
click>=8.1.7
python-dotenv>=1.0.1
rich>=13.9.4
Expand Down
Loading

0 comments on commit 99825d5

Please sign in to comment.