feat: Containerize the application with Docker and Docker Compose, including a PostgreSQL database and a deployment script.

This commit is contained in:
Moh Dzulfikri Maulana
2026-03-09 00:13:31 +07:00
parent bdd61d11d3
commit c7b022d502
6 changed files with 139 additions and 1 deletions

23
deploy.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
# Load environment variables from .env if it exists
if [ -f .env ]; then
export $(grep -v '^#' .env | xargs)
fi
# Name of the database container
DB_CONTAINER_NAME="portfolio-db"
# Check if the database container is already running
if [ "$(docker ps -q -f name=${DB_CONTAINER_NAME})" ]; then
echo "✅ Database container '${DB_CONTAINER_NAME}' is already running."
echo "🚀 Deploying/Updating only the application..."
docker-compose up -d --no-recreate db
docker-compose up -d app
else
echo "⚠️ Database container '${DB_CONTAINER_NAME}' not found or stopped."
echo "🏗️ Deploying full stack (Database + App)..."
docker-compose up -d
fi
echo "✨ Deployment script finished!"