feat(docker): added docker + scripts to get started

This commit is contained in:
Waleed Latif
2025-03-03 12:23:29 -08:00
parent db3c711378
commit 890e380c2c
6 changed files with 101 additions and 0 deletions

11
.dockerignore Normal file
View File

@@ -0,0 +1,11 @@
# Exclude files from Docker build
.git
.github
node_modules
.next
.vercel
.husky
.env
.env.*
npm-debug.log
README.md

15
Dockerfile Normal file
View File

@@ -0,0 +1,15 @@
FROM node:20-alpine
WORKDIR /app
# Copy package files
COPY package.json package-lock.json ./
RUN npm ci
# Copy everything else (for build)
COPY . .
EXPOSE 3000
# Default to development mode
CMD ["npm", "run", "dev"]

42
docker-compose.yml Normal file
View File

@@ -0,0 +1,42 @@
version: '3.8'
services:
simstudio:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
volumes:
- .:/app
- /app/node_modules
- /app/.next
environment:
- NODE_ENV=development
- DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio
- POSTGRES_URL=postgresql://postgres:postgres@db:5432/simstudio
- BETTER_AUTH_URL=http://localhost:3000
- NEXT_PUBLIC_APP_URL=http://localhost:3000
depends_on:
- db
command: npm run dev
db:
image: postgres:16-alpine
restart: always
ports:
- "5432:5432"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=simstudio
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
volumes:
postgres_data:

7
generate_migrations.sh Normal file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
# Generate migrations using Drizzle
echo "Generating database migrations..."
docker compose exec simstudio npm run db:push
echo "Migrations generated successfully."

View File

@@ -36,6 +36,7 @@ const nextConfig: NextConfig = {
},
]
},
output: 'standalone',
}
export default nextConfig

25
start_simstudio_docker.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
# Check if .env file exists, if not, create from example
if [ ! -f .env ]; then
echo "Creating .env file from .env.example..."
cp .env.example .env
echo "Please update .env file with your configuration."
fi
# Stop any running containers
docker compose down
# Build and start containers in detached mode
docker compose up --build -d
# Wait for database to be ready
echo "Waiting for database to be ready..."
sleep 5
# Apply migrations automatically
echo "Applying database migrations..."
docker compose exec simstudio npm run db:push
echo "Sim Studio is now running at http://localhost:3000"
echo "To view logs, run: docker compose logs -f simstudio"