mirror of
https://github.com/kyantech/Palmr.git
synced 2025-10-23 06:11:58 +00:00
chore: add Dockerfile, docker-compose, and .dockerignore for multi-service setup
Introduce a Dockerfile for building the Palmr application with multi-stage builds for both server and web components. Update docker-compose.yaml to consolidate services under a single 'palmr' service, ensuring proper health checks and environment variable configurations. Add a .dockerignore file to optimize Docker builds by excluding unnecessary files. Include a Makefile for simplified build and deployment commands.
This commit is contained in:
33
infra/SCRIPTS.md
Normal file
33
infra/SCRIPTS.md
Normal file
@@ -0,0 +1,33 @@
|
||||
## 🚀 Quick Start
|
||||
|
||||
Palmr. includes a convenient Makefile to simplify development and deployment tasks:
|
||||
|
||||
```bash
|
||||
# Show all available commands
|
||||
make help
|
||||
|
||||
# Build Docker image with multi-platform support
|
||||
make build
|
||||
|
||||
# Start the application
|
||||
make start
|
||||
|
||||
# View application logs
|
||||
make logs
|
||||
|
||||
# Stop the application
|
||||
make stop
|
||||
|
||||
# Clean up containers and images
|
||||
make clean
|
||||
```
|
||||
|
||||
### Available Commands:
|
||||
- `make build` - Build Docker image using the build script in `./infra/`
|
||||
- `make start` - Start the application using docker-compose
|
||||
- `make stop` - Stop all running containers
|
||||
- `make logs` - Show application logs
|
||||
- `make clean` - Clean up containers and images
|
||||
- `make shell` - Access the application container shell
|
||||
|
||||
All infrastructure scripts are organized in the `./infra/` directory for better project organization.
|
43
infra/build-docker.sh
Executable file
43
infra/build-docker.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Ask for tag interactively
|
||||
echo "🏷️ Please enter a tag for the build (e.g., v1.0.0, production, beta):"
|
||||
read -p "Tag: " TAG
|
||||
|
||||
# Check if tag was provided
|
||||
if [ -z "$TAG" ]; then
|
||||
echo "❌ Error: Tag cannot be empty"
|
||||
echo "Please run the script again and provide a valid tag"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "🚀 Building Palmr Unified Image for AMD64 and ARM..."
|
||||
echo "📦 Building tags: latest and $TAG"
|
||||
|
||||
# Ensure buildx is available and create/use a builder instance
|
||||
docker buildx create --name palmr-builder --use 2>/dev/null || docker buildx use palmr-builder
|
||||
|
||||
# Build the unified image for multiple platforms without cache
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--no-cache \
|
||||
-t kyantech/palmr:latest \
|
||||
-t kyantech/palmr:$TAG \
|
||||
--load \
|
||||
.
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ Multi-platform build completed successfully!"
|
||||
echo ""
|
||||
echo "Built for platforms: linux/amd64, linux/arm64"
|
||||
echo "Built tags: palmr:latest and palmr:$TAG"
|
||||
echo ""
|
||||
echo "Access points:"
|
||||
echo "- API: http://localhost:3333"
|
||||
echo "- Web App: http://localhost:5487"
|
||||
echo ""
|
||||
echo "Read the docs for more information"
|
||||
else
|
||||
echo "❌ Build failed!"
|
||||
exit 1
|
||||
fi
|
29
infra/server-start.sh
Normal file
29
infra/server-start.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Starting Palmr Server..."
|
||||
|
||||
# Set proper environment
|
||||
export HOME=/home/palmr
|
||||
export NPM_CONFIG_CACHE=/home/palmr/.npm
|
||||
export PNPM_HOME=/home/palmr/.pnpm
|
||||
|
||||
# Wait for PostgreSQL
|
||||
echo "Waiting for PostgreSQL..."
|
||||
while ! nc -z postgres 5432; do
|
||||
sleep 1
|
||||
done
|
||||
echo "PostgreSQL is up!"
|
||||
|
||||
cd /app/server
|
||||
|
||||
echo "Generating Prisma client..."
|
||||
npx prisma generate --schema=./prisma/schema.prisma
|
||||
|
||||
echo "Running migrations..."
|
||||
npx prisma migrate deploy
|
||||
|
||||
echo "Running database seeds..."
|
||||
node prisma/seed.js || echo "Seeds failed or already exist, continuing..."
|
||||
|
||||
echo "Starting server application..."
|
||||
exec node dist/server.js
|
Reference in New Issue
Block a user