Commit Graph

90 Commits

Author SHA1 Message Date
clawbot
ed4ddc5536 fix: clean up Docker container when deleting an app (closes #2) 2026-02-08 12:02:56 -08:00
clawbot
e212910143 fix: limit webhook request body size to 1MB to prevent DoS (closes #1) 2026-02-08 12:02:06 -08:00
d4eae284b5 Fix build logs auto-scroll with double RAF and change detection
Use double requestAnimationFrame to ensure DOM has fully reflowed before
scrolling, and only scroll when log content actually changes.
2026-01-08 10:31:19 -08:00
ee4afbde80 Fix build logs overflow by using Alpine.js reactive bindings
Replaced manual DOM manipulation with a deploymentCard Alpine component
that uses x-text bindings and x-ref for proper scrolling, matching the
working container logs implementation.
2026-01-08 10:21:16 -08:00
aaa55fd153 Fix app status not updated when deployment fails or service restarts
- Update app status to error when health check fails with an error
- Update app status to error in cleanupStuckDeployments for apps stuck in building state
- This fixes the inconsistency where app shows "building" but deployment is "failed"
2026-01-01 06:59:03 -08:00
a71bf07dbf Fix deploy button strobing by using deployment status
Use latestDeploymentStatus instead of app status to determine if
a deployment is in progress. The deployment status is more reliable
during state transitions and prevents the button from flickering.
2026-01-01 06:52:43 -08:00
ee34f3b70c Change Docker image naming to upaas-appname:deploymentID
- Use upaas-appname format instead of upaas/appname
- Tag with deployment number instead of 'latest'
- Example: upaas-myapp:42
2026-01-01 06:50:54 -08:00
ba4893a98a Simplify logs pane structure to fix scrolling
- Remove details/summary element that may have caused layout issues
- Use simpler layout with header row and logs block below
- Change overflow-auto to overflow-y-scroll to force scrollbar
- Add break-all to handle long lines
2026-01-01 06:48:06 -08:00
c01bfcc9a9 Fix logs pane overflow by moving background/padding to wrapper
Move bg-gray-900, rounded-lg, and p-4 from the pre element to the
wrapper div. This matches the working structure in app_detail.html
and allows overflow-auto to work correctly.
2026-01-01 06:40:31 -08:00
2b63219f66 Fix realtime build logs scrolling in deployment history
- Reload page when new deployment starts but no card exists in DOM
- Only update logs content when it changes to avoid unnecessary reflows
- Use double requestAnimationFrame for reliable scroll-to-bottom timing
2026-01-01 06:10:25 -08:00
2cbcd3d72a Add build log file storage and download functionality
- Write deployment logs to files when deployment finishes (success or failure)
- Log files stored in DataDir/logs/<hostname>/<appname>/<appname>_<sha>_<timestamp>.log.txt
- Capture commit SHA for manual deploys by parsing git rev-parse HEAD after clone
- Add download endpoint for log files at /apps/{id}/deployments/{deploymentID}/download
- Add download link in deployment history view for finished deployments
2026-01-01 06:08:00 -08:00
c4362c3143 Add commit URL to Slack notifications with link and backtick formatting
- Add commit_url column to webhook_events and deployments tables
- Extract commit URL from webhook payload (from commit object or repo URL)
- Format Slack messages with backticks for branch and commit SHA
- Link commit SHA to the actual commit URL on the git server
- Keep plain text format for ntfy notifications
2025-12-31 16:29:22 -08:00
4cd12d717c Remove separate live logs section, update logs in deployment card 2025-12-31 15:06:35 -08:00
a2539ebf3a Fix finished time showing for in-progress deployments 2025-12-31 14:58:41 -08:00
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