Add Docker deployment for ZimaOS
- Updated Dockerfile for local storage deployment (removed Firebase dependencies) - Created docker-compose.yml with persistent data volumes - Added deploy.sh script for automated deployment - Created DEPLOYMENT.md with ZimaOS deployment guide - Added .env.example for configuration template - Updated .gitignore to protect sensitive data - Fixed package.json to use port 7654 in production - Cleared all test user data for fresh deployment - Updated README with deployment section
This commit is contained in:
1 parent
0b9ab53266
commit
ad37bb57ae
8 files changed
+273
-27
No files matched your search
@@ -0,0 +1,11 @@
|
|||||||
|
# IMPORTANT: Generate a secure encryption key before deploying
|
||||||
|
# Run: openssl rand -base64 32
|
||||||
|
# Then replace the value below with your generated key
|
||||||
|
|
||||||
|
ENCRYPTION_KEY=change-this-to-a-secure-random-key
|
||||||
|
|
||||||
|
# Optional: Set custom port (default is 7654)
|
||||||
|
# PORT=7654
|
||||||
|
|
||||||
|
# Environment
|
||||||
|
NODE_ENV=production
|
||||||
@@ -32,6 +32,7 @@ yarn-error.log*
|
|||||||
|
|
||||||
# env files (can opt-in for committing if needed)
|
# env files (can opt-in for committing if needed)
|
||||||
.env*
|
.env*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
# vercel
|
# vercel
|
||||||
.vercel
|
.vercel
|
||||||
@@ -39,3 +40,10 @@ yarn-error.log*
|
|||||||
# typescript
|
# typescript
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
next-env.d.ts
|
next-env.d.ts
|
||||||
|
|
||||||
|
# Docker
|
||||||
|
docker-compose.override.yml
|
||||||
|
|
||||||
|
# User data (encrypted local storage)
|
||||||
|
data/*
|
||||||
|
!data/.gitignore
|
||||||
+148
@@ -0,0 +1,148 @@
|
|||||||
|
# Capsule Budget - ZimaOS Deployment Guide
|
||||||
|
|
||||||
|
## Quick Deploy
|
||||||
|
|
||||||
|
1. **Clone or upload this repository to your ZimaOS device**
|
||||||
|
|
||||||
|
2. **Run the deployment script:**
|
||||||
|
```bash
|
||||||
|
./deploy.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
This will:
|
||||||
|
- Generate a secure encryption key
|
||||||
|
- Clear any test data
|
||||||
|
- Build the Docker image
|
||||||
|
- Start the container
|
||||||
|
|
||||||
|
3. **Access Capsule:**
|
||||||
|
- Open browser to `http://your-zima-ip:7654`
|
||||||
|
- Create your account and start budgeting!
|
||||||
|
|
||||||
|
## Manual Deployment
|
||||||
|
|
||||||
|
If you prefer manual setup:
|
||||||
|
|
||||||
|
1. **Create .env file:**
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Generate encryption key:**
|
||||||
|
```bash
|
||||||
|
openssl rand -base64 32
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Update .env with your key:**
|
||||||
|
```bash
|
||||||
|
ENCRYPTION_KEY=your-generated-key-here
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Build and start:**
|
||||||
|
```bash
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
## ZimaOS Integration
|
||||||
|
|
||||||
|
### Using ZimaOS Apps
|
||||||
|
|
||||||
|
If ZimaOS supports custom apps:
|
||||||
|
|
||||||
|
1. Navigate to Apps section
|
||||||
|
2. Click "Add Custom App"
|
||||||
|
3. Point to this directory
|
||||||
|
4. Configure port: 7654
|
||||||
|
|
||||||
|
### Using ZimaOS File Manager
|
||||||
|
|
||||||
|
1. Upload project via web interface or SMB
|
||||||
|
2. SSH into ZimaOS
|
||||||
|
3. Navigate to project directory
|
||||||
|
4. Run `./deploy.sh`
|
||||||
|
|
||||||
|
## Data Persistence
|
||||||
|
|
||||||
|
All user data is stored in `./data/` directory:
|
||||||
|
- User credentials (hashed)
|
||||||
|
- Budget data (encrypted with AES-GCM)
|
||||||
|
- Transaction history
|
||||||
|
|
||||||
|
**Backup Strategy:**
|
||||||
|
```bash
|
||||||
|
# Backup data
|
||||||
|
cp -r data data-backup-$(date +%Y%m%d)
|
||||||
|
|
||||||
|
# Or use ZimaOS snapshot feature
|
||||||
|
```
|
||||||
|
|
||||||
|
## Management Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# View logs
|
||||||
|
docker-compose logs -f
|
||||||
|
|
||||||
|
# Stop Capsule
|
||||||
|
docker-compose stop
|
||||||
|
|
||||||
|
# Restart Capsule
|
||||||
|
docker-compose restart
|
||||||
|
|
||||||
|
# Stop and remove container
|
||||||
|
docker-compose down
|
||||||
|
|
||||||
|
# Rebuild after updates
|
||||||
|
docker-compose build --no-cache
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
## Updating Capsule
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Pull latest changes
|
||||||
|
git pull
|
||||||
|
|
||||||
|
# Rebuild and restart
|
||||||
|
docker-compose down
|
||||||
|
docker-compose build
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Your data in `./data/` will persist across updates.
|
||||||
|
|
||||||
|
## Security Notes
|
||||||
|
|
||||||
|
- Change the default ENCRYPTION_KEY before first use
|
||||||
|
- Keep your `.env` file secure and never commit it
|
||||||
|
- Use ZimaOS firewall to restrict access if needed
|
||||||
|
- Consider VPN-only access for additional security
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Container won't start
|
||||||
|
```bash
|
||||||
|
# Check logs
|
||||||
|
docker-compose logs
|
||||||
|
|
||||||
|
# Verify .env file exists
|
||||||
|
ls -la .env
|
||||||
|
```
|
||||||
|
|
||||||
|
### Port already in use
|
||||||
|
Edit `docker-compose.yml` and change port mapping:
|
||||||
|
```yaml
|
||||||
|
ports:
|
||||||
|
- "8080:7654" # Change 8080 to your preferred port
|
||||||
|
```
|
||||||
|
|
||||||
|
### Data not persisting
|
||||||
|
Ensure `./data` directory has correct permissions:
|
||||||
|
```bash
|
||||||
|
chmod 755 data
|
||||||
|
```
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
For issues or questions:
|
||||||
|
- GitHub: https://github.com/nmemmert/budget
|
||||||
|
- Check logs: `docker-compose logs -f`
|
||||||
+11
-22
@@ -1,4 +1,4 @@
|
|||||||
FROM node:20-alpine
|
FROM node:18-alpine
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -6,34 +6,23 @@ WORKDIR /app
|
|||||||
# Copy package files
|
# Copy package files
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies (production only)
|
||||||
RUN npm ci
|
RUN npm ci --only=production
|
||||||
|
|
||||||
# Copy source code
|
# Copy source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Set environment variables
|
|
||||||
ARG NEXT_PUBLIC_FIREBASE_API_KEY
|
|
||||||
ARG NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
|
|
||||||
ARG NEXT_PUBLIC_FIREBASE_PROJECT_ID
|
|
||||||
ARG NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET
|
|
||||||
ARG NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID
|
|
||||||
ARG NEXT_PUBLIC_FIREBASE_APP_ID
|
|
||||||
ARG NEXT_PUBLIC_ENCRYPTION_KEY
|
|
||||||
|
|
||||||
ENV NEXT_PUBLIC_FIREBASE_API_KEY=$NEXT_PUBLIC_FIREBASE_API_KEY
|
|
||||||
ENV NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=$NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
|
|
||||||
ENV NEXT_PUBLIC_FIREBASE_PROJECT_ID=$NEXT_PUBLIC_FIREBASE_PROJECT_ID
|
|
||||||
ENV NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=$NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET
|
|
||||||
ENV NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=$NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID
|
|
||||||
ENV NEXT_PUBLIC_FIREBASE_APP_ID=$NEXT_PUBLIC_FIREBASE_APP_ID
|
|
||||||
ENV NEXT_PUBLIC_ENCRYPTION_KEY=$NEXT_PUBLIC_ENCRYPTION_KEY
|
|
||||||
|
|
||||||
# Build the application
|
# Build the application
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Expose port
|
# Create data directory for encrypted local storage
|
||||||
EXPOSE 3000
|
RUN mkdir -p /app/data && chmod 755 /app/data
|
||||||
|
|
||||||
|
# Expose port 7654 (Capsule default port)
|
||||||
|
EXPOSE 7654
|
||||||
|
|
||||||
|
# Set production environment
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
# Start the application
|
# Start the application
|
||||||
CMD ["npm", "start"]
|
CMD ["npm", "start"]
|
||||||
@@ -286,6 +286,30 @@ Date,Amount,Description,Category
|
|||||||
- Export to JSON format for data backup or integration
|
- Export to JSON format for data backup or integration
|
||||||
- Includes complete transaction history and envelope details
|
- Includes complete transaction history and envelope details
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
### ZimaOS Deployment (Recommended)
|
||||||
|
|
||||||
|
Capsule is designed for self-hosted deployment on ZimaOS and similar platforms.
|
||||||
|
|
||||||
|
**Quick Deploy:**
|
||||||
|
```bash
|
||||||
|
./deploy.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
See [DEPLOYMENT.md](./DEPLOYMENT.md) for detailed ZimaOS deployment instructions.
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
- Docker containerization for easy deployment
|
||||||
|
- Persistent data storage in `./data` directory
|
||||||
|
- Health checks and auto-restart
|
||||||
|
- Encrypted local storage (no cloud required)
|
||||||
|
|
||||||
|
**Access:**
|
||||||
|
- Default port: 7654
|
||||||
|
- Local: `http://localhost:7654`
|
||||||
|
- Network: `http://your-device-ip:7654`
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
1. Fork the repository
|
1. Fork the repository
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Capsule Budget - ZimaOS Deployment Script
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "🚀 Deploying Capsule to ZimaOS..."
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Check if .env file exists
|
||||||
|
if [ ! -f .env ]; then
|
||||||
|
echo "⚠️ .env file not found!"
|
||||||
|
echo "Creating .env from .env.example..."
|
||||||
|
cp .env.example .env
|
||||||
|
|
||||||
|
# Generate a secure encryption key
|
||||||
|
ENCRYPTION_KEY=$(openssl rand -base64 32)
|
||||||
|
|
||||||
|
# Update .env with generated key
|
||||||
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
# macOS
|
||||||
|
sed -i '' "s/change-this-to-a-secure-random-key/$ENCRYPTION_KEY/" .env
|
||||||
|
else
|
||||||
|
# Linux
|
||||||
|
sed -i "s/change-this-to-a-secure-random-key/$ENCRYPTION_KEY/" .env
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✅ Generated secure encryption key"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clear test data
|
||||||
|
echo "🧹 Clearing test data..."
|
||||||
|
rm -rf data/*
|
||||||
|
echo "✅ Test data cleared"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Build and start containers
|
||||||
|
echo "🔨 Building Docker image..."
|
||||||
|
docker-compose build
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "🚀 Starting Capsule..."
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "✅ Deployment complete!"
|
||||||
|
echo ""
|
||||||
|
echo "📊 Capsule is running at:"
|
||||||
|
echo " http://localhost:7654"
|
||||||
|
echo " http://$(hostname -I | awk '{print $1}'):7654"
|
||||||
|
echo ""
|
||||||
|
echo "🔧 Useful commands:"
|
||||||
|
echo " docker-compose logs -f # View logs"
|
||||||
|
echo " docker-compose stop # Stop container"
|
||||||
|
echo " docker-compose restart # Restart container"
|
||||||
|
echo " docker-compose down # Stop and remove container"
|
||||||
|
echo ""
|
||||||
|
echo "💾 Your data is stored in: ./data/"
|
||||||
|
echo ""
|
||||||
+10
-4
@@ -1,15 +1,21 @@
|
|||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
budget-app:
|
capsule:
|
||||||
image: ghcr.io/nmemmert/budget:dbaff55
|
build: .
|
||||||
|
container_name: capsule-budget
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "7654:7654"
|
||||||
|
volumes:
|
||||||
|
# Persist user data outside container
|
||||||
|
- ./data:/app/data
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
|
# Generate a secure key: openssl rand -base64 32
|
||||||
|
- ENCRYPTION_KEY=${ENCRYPTION_KEY:-change-this-to-a-secure-key}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:3000"]
|
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:7654"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -p 7654",
|
"dev": "next dev -p 7654",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start -p 7654",
|
||||||
"lint": "eslint"
|
"lint": "eslint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Reference in new issue
Block a user