-
Notifications
You must be signed in to change notification settings - Fork 25
Pocketbase Dockerfile and deployment documentation #5253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
✅ Deploy Preview for hpe-theme-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for unrivaled-bublanina-3a9bae ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR establishes a complete PocketBase cloud deployment infrastructure for the HPE Design System. It introduces the first app in the proposed monorepo structure with comprehensive Docker containerization, Google Cloud Run deployment scripts, and detailed documentation for cloud-based data persistence.
- Creates complete PocketBase deployment infrastructure with Cloud Run integration
- Introduces
apps/pocketbase_appas the first application in a new monorepo structure - Provides automated deployment scripts and comprehensive documentation
Reviewed Changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| startup.sh | Container startup script with health checks and graceful shutdown handling |
| deploy.sh | Automated deployment script for Google Cloud infrastructure setup |
| cloud-run-service.yaml | Static Cloud Run service configuration for HPE Design System |
| cloud-run-service.template.yaml | Portable templated configuration with environment variable substitution |
| README.md | Project overview and quick start documentation |
| QUICK_REFERENCE.md | Essential commands and operations reference |
| LICENSE.md | MIT license for open-source compliance |
| Dockerfile.orig | Original Docker configuration preserved for reference |
| Dockerfile | Production-ready container build with security hardening |
| DEPLOYMENT.md | Comprehensive deployment guide with troubleshooting |
| CLOUD_STORAGE_SETUP.md | Detailed Cloud Storage integration documentation |
| CHANGELOG.md | PocketBase version changelog (v0.29.1) |
| .gitignore | Repository exclusions for binaries and generated files |
| .env.example | Environment configuration template |
| else | ||
| echo "⚠️ Data directory is not writable, attempting to fix permissions..." | ||
| # This might not work if we're not root, but it's worth trying | ||
| chmod 755 "$DATA_DIR" 2>/dev/null || true |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using chmod 755 on a data directory could expose sensitive database files to other users on the system. Consider using 750 or 700 for better security, as PocketBase data should only be accessible by the application user.
| chmod 755 "$DATA_DIR" 2>/dev/null || true | |
| chmod 700 "$DATA_DIR" 2>/dev/null || true |
apps/pocketbase_app/deploy.sh
Outdated
| echo "🔐 Granting permissions to service account..." | ||
| gcloud projects add-iam-policy-binding "$PROJECT_ID" \ | ||
| --member="serviceAccount:$SERVICE_ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com" \ | ||
| --role="roles/storage.admin" |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Granting 'roles/storage.admin' provides broad permissions including the ability to delete buckets and modify IAM policies. Consider using 'roles/storage.objectAdmin' which provides sufficient permissions for PocketBase data operations without bucket-level administrative access.
| --role="roles/storage.admin" | |
| --role="roles/storage.objectAdmin" |
| autoscaling.knative.dev/maxScale: "1" | ||
| spec: | ||
| # Use the service account with Cloud Storage permissions | ||
| serviceAccountName: pocketbase-service-account@hpe-design-system-adoption.iam.gserviceaccount.com |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The service account email is hardcoded with a specific project ID 'hpe-design-system-adoption'. This makes the configuration non-portable across different projects. Consider using the template version or environment variable substitution for better maintainability.
| serviceAccountName: pocketbase-service-account@hpe-design-system-adoption.iam.gserviceaccount.com | |
| serviceAccountName: pocketbase-service-account@${PROJECT_ID}.iam.gserviceaccount.com |
| # Use the service account with Cloud Storage permissions | ||
| serviceAccountName: pocketbase-service-account@hpe-design-system-adoption.iam.gserviceaccount.com | ||
| containers: | ||
| - image: gcr.io/hpe-design-system-adoption/pocketbase-app:latest |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The container image reference is hardcoded with a specific project ID 'hpe-design-system-adoption'. This makes the configuration non-portable across different projects. Consider using the template version for better maintainability.
| - image: gcr.io/hpe-design-system-adoption/pocketbase-app:latest | |
| serviceAccountName: pocketbase-service-account@${PROJECT_ID}.iam.gserviceaccount.com | |
| containers: | |
| - image: gcr.io/${PROJECT_ID}/pocketbase-app:latest |
| csi: | ||
| driver: gcsfuse.run.googleapis.com | ||
| volumeAttributes: | ||
| bucketName: ds-pocketbase |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bucket name is hardcoded as 'ds-pocketbase'. This makes the configuration non-portable across different projects where the bucket name might need to be different. Consider using the template version for better maintainability.
| bucketName: ds-pocketbase | |
| bucketName: ${GCS_BUCKET_NAME} |
| fi && \ | ||
| echo "✅ Checksum verification passed" && \ | ||
| unzip /tmp/pocketbase.zip -d /app && \ | ||
| rm /tmp/pocketbase.zip /tmp/checksums.txt && \ |
Copilot
AI
Aug 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checksum verification assumes the checksum file uses space as delimiter and the hash is in the first field. However, different checksum formats may use different delimiters or field orders. Consider using sha256sum -c with a properly formatted checksums file for more robust verification.
| rm /tmp/pocketbase.zip /tmp/checksums.txt && \ | |
| grep "pocketbase_${PB_VERSION}_linux_amd64.zip" /tmp/checksums.txt | \ | |
| sed "s/pocketbase_${PB_VERSION}_linux_amd64.zip$/\/tmp\/pocketbase.zip/" > /tmp/pb_checksum.txt && \ | |
| sha256sum -c /tmp/pb_checksum.txt && \ | |
| echo "✅ Checksum verification passed" && \ | |
| unzip /tmp/pocketbase.zip -d /app && \ | |
| rm /tmp/pocketbase.zip /tmp/checksums.txt /tmp/pb_checksum.txt && \ |
Co-authored-by: Copilot <[email protected]>
Overview
appsdirectory as part of the monorepo structure.pocketbase_appis the first app. Future monorepo structure might resemble the following:Above structure is conceptual and discussion is welcome.
PR detail
This pull request introduces a complete setup for deploying the PocketBase backend for the HPE Design System to Google Cloud Run with persistent storage and production-ready configuration. It adds essential documentation, a Dockerfile for containerization, a startup script for efficient data handling, and proper licensing. The changes focus on enabling persistent, performant, and safe operation of PocketBase in a cloud environment.
Cloud Deployment & Data Persistence
Dockerfilethat builds a minimal Alpine-based container, downloads the PocketBase binary, sets up required directories, and uses a startup script to manage data and server startup.startup.shscript that copies the database from the mounted Cloud Storage volume to local storage on startup for performance, and backs up data to Cloud Storage on shutdown for persistence..gitignoreto exclude PocketBase binaries, data, logs, and temporary directories to keep the repository clean.Documentation & Usage
DEPLOYMENT.mdguide detailing step-by-step deployment to Google Cloud Run, including prerequisites, setup, admin access, architecture, troubleshooting, and best practices for SQLite persistence.QUICK_REFERENCE.mdwith essential commands for deployment, admin credential reset, log checking, and key operational notes.README.mdto explain the backend's purpose, PocketBase features, and a high-level overview of cloud deployment strategies, emphasizing Cloud Run with persistent storage.Licensing
LICENSE.mdfile with the MIT license for proper open-source compliance.