Commit Graph

76 Commits

Author SHA1 Message Date
58687e77f5 Always scroll logs to bottom on every update 2025-12-31 14:56:56 -08:00
83986626a4 Fix container name conflict on redeployment
Remove old container before creating new one instead of trying to keep
it for rollback. Rollback isn't safe anyway because database migrations
may have been applied by the new container.

The old stop-then-rollback approach failed because Docker doesn't allow
two containers with the same name, even if one is stopped.
2025-12-31 14:48:16 -08:00
d2f2747ae6 Fix real-time build log streaming and scroll behavior
- Use line-by-line reading for Docker build output instead of io.Copy
  to ensure each log line is written immediately without buffering
- Add isNearBottom() helper to check scroll position before auto-scroll
- Only auto-scroll logs if user was already near bottom (better UX)
- Use requestAnimationFrame for smoother scroll-to-bottom animation
2025-12-31 14:44:15 -08:00
f1cc7d65a6 Integrate Alpine.js for reactive UI
- Add Alpine.js (self-hosted, embedded in static/)
- Refactor app.js to use Alpine.js stores and components
- Update templates to use x-data, x-bind, x-show, x-text directives
- Add reactive deploy button state, live logs, status badges
- Add auto-dismiss alerts with close button and transitions
- Add copy-to-clipboard component with feedback
- Add confirm dialog component for destructive actions
- Add relative time component with auto-update
- Add prettier to make fmt target for JS formatting
2026-01-01 05:37:46 +07:00
ab7e917b03 Add real-time deployment updates and refactor JavaScript
- Add deploy stats (last deploy time, total count) to dashboard
- Add recent-deployments API endpoint for real-time updates
- Add live build logs to deployments history page
- Fix git clone regression (preserve entrypoint for simple clones)
- Refactor JavaScript into shared app.js with page init functions
- Deploy button disables immediately on click
- Auto-refresh deployment list and logs during builds
- Format JavaScript with Prettier (4-space indent)
2026-01-01 05:22:56 +07:00
307955dae1 Improve footer styling and fix license to WTFPL 2025-12-30 15:08:22 +07:00
b3ac3c60c2 Add deployment improvements and UI enhancements
- Clone specific commit SHA from webhook instead of just branch HEAD
- Log webhook payload in deployment logs
- Add build/deploy timing to ntfy and Slack notifications
- Implement container rollback on deploy failure
- Remove old container only after successful deployment
- Show relative times in deployment history (hover for full date)
- Update port mappings UI with labeled text inputs
- Add footer with version info, license, and repo link
- Format deploy key comment as upaas_DATE_appname
2025-12-30 15:05:26 +07:00
bc275f7b9c Add TCP/UDP port mapping support
- Add app_ports table for storing port mappings per app
- Add Port model with CRUD operations
- Add handlers for adding/deleting port mappings
- Add ports section to app detail template
- Update Docker client to configure port bindings when creating containers
- Support both TCP and UDP protocols
2025-12-30 12:11:57 +07:00
4ece7431af Use app name and deployment ID in build directory structure
Change build directory from builds/<app-id>-<random> to
builds/<appname>/<deployment-id>-<random> for better organization
and easier debugging.
2025-12-30 11:57:02 +07:00
2ed23912a9 Update branding to µPaaS by @sneak
Change all references from "upaas" to "µPaaS" in page titles,
headers, and README. Add attribution link to sneak.berlin in
the navigation bar.
2025-12-29 17:04:53 +07:00
dc6500eac6 Fix repository cloning when running inside a container
Use DataDir/builds instead of /tmp for clone directories so that bind
mounts work correctly when upaas itself runs in a Docker container.
The /tmp directory inside the upaas container isn't accessible to the
Docker daemon on the host, causing bind mount failures.

Also fix test setups to pass Config to deploy service and add delay
to webhook test to avoid temp directory cleanup race with async
deployment goroutine.
2025-12-29 17:02:01 +07:00
5dc454d752 Improve deploy key and webhook URL display
- Format deploy key with comment: upaas-<date>-<vhost>
- Build webhook URL using Host header with https://
2025-12-29 16:51:42 +07:00
4d03350943 Fix logout route to accept POST 2025-12-29 16:46:30 +07:00
ee823b6a84 Fix static file route to serve at /s/ 2025-12-29 16:39:51 +07:00
cc6dee9fd8 Install golangci-lint v2 in Docker build 2025-12-29 16:29:16 +07:00
5690fbd17d Add WTFPL license 2025-12-29 16:25:22 +07:00
3eb15839c8 Use Go 1.25 (latest stable release) 2025-12-29 16:23:57 +07:00
e59b3a0ee4 Update to Go 1.24 for golang.org/x/tools compatibility 2025-12-29 16:21:46 +07:00
219a561473 Use PORT instead of UPAAS_PORT for listen port 2025-12-29 16:15:05 +07:00
0f2df60c58 Add docker-compose.yml for deployment 2025-12-29 16:13:20 +07:00
dce898bbdb Auto-generate and persist session secret on first startup
- Generate random 32-byte session secret if not set via env var
- Persist to $UPAAS_DATA_DIR/session.key for container restarts
- Load existing secret from file on subsequent startups
- Change container data directory to /var/lib/upaas
2025-12-29 16:12:30 +07:00
5fb0b111fc Use ULID for app IDs and Docker label for container lookup
- Replace UUID with ULID for app ID generation (lexicographically sortable)
- Remove container_id column from apps table (migration 002)
- Add upaas.id Docker label to identify containers by app ID
- Implement FindContainerByAppID in Docker client to query by label
- Update handlers and deploy service to use label-based container lookup
- Show system-managed upaas.id label in UI with editing disabled

Container association is now determined dynamically via Docker label
rather than stored in the database, making the system more resilient
to container recreation or external changes.
2025-12-29 16:06:40 +07:00
c13fd8c746 Update TODO.md with completed items
Mark as complete:
- Server.Run(), Shutdown(), SetupRoutes()
- Container logs viewing
- Container restart/stop/start controls
2025-12-29 15:51:54 +07:00
8403e431d2 Add container restart/stop/start controls
- Add HandleAppRestart, HandleAppStop, HandleAppStart handlers
- Wire up POST routes for /apps/{id}/restart, /stop, /start
- Use helper function to reduce code duplication
2025-12-29 15:50:51 +07:00
daaf00893c Implement container logs handler
- Add Docker client to handlers for container operations
- Implement HandleAppLogs() to fetch and return container logs
- Support ?tail=N query parameter (default 500 lines)
- Handle missing container gracefully
2025-12-29 15:48:23 +07:00
3f9d83c436 Initial commit with server startup infrastructure
Core infrastructure:
- Uber fx dependency injection
- Chi router with middleware stack
- SQLite database with embedded migrations
- Embedded templates and static assets
- Structured logging with slog

Features implemented:
- Authentication (login, logout, session management, argon2id hashing)
- App management (create, edit, delete, list)
- Deployment pipeline (clone, build, deploy, health check)
- Webhook processing for Gitea
- Notifications (ntfy, Slack)
- Environment variables, labels, volumes per app
- SSH key generation for deploy keys

Server startup:
- Server.Run() starts HTTP server on configured port
- Server.Shutdown() for graceful shutdown
- SetupRoutes() wires all handlers with chi router
2025-12-29 15:46:03 +07:00