Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ yarn-error.log*

*storybook.log
storybook-static

.env.docker
.env.docker.*
140 changes: 140 additions & 0 deletions DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Docker Deployment Guide

This guide explains how to build and deploy the Eventer application using Docker.

## Prerequisites

- Docker and Docker Compose installed on your system
- Environment variables configured

## Quick Start

1. **Clone the repository and navigate to the project root:**

```bash
cd /path/to/eventer
```

2. **Set up environment variables:**

```bash
cp .env.docker .env
# Edit .env file with your actual values
```

3. **Build and run all services:**

```bash
docker-compose up --build
```

4. **Access the applications:**
- Web application: http://localhost:3000
- Backend API: http://localhost:4000
- Database: localhost:5432

## Individual Application Deployment

### Backend Application

1. **Build the backend Docker image:**

```bash
cd apps/backend
docker build -t eventer-backend .
```

2. **Run the backend container:**
```bash
docker run -p 4000:4000 \
-e DATABASE_URL="your_database_url" \
-e SUPABASE_URL="your_supabase_url" \
-e SUPABASE_KEY="your_supabase_key" \
eventer-backend
```

### Web Application

1. **Build the web Docker image:**

```bash
cd apps/web
docker build -t eventer-web .
```

2. **Run the web container:**
```bash
docker run -p 3000:3000 \
-e NEXT_PUBLIC_APP_URL="http://localhost:3000" \
-e NEXT_PUBLIC_BACKEND_URL="http://localhost:4000" \
eventer-web
```

## Environment Variables

### Backend

- `DATABASE_URL`: PostgreSQL connection string
- `SUPABASE_URL`: Supabase project URL
- `SUPABASE_KEY`: Supabase API key
- `PORT`: Port for the backend server (default: 4000)
- `CORS_ORIGIN`: Allowed CORS origin (default: http://localhost:3000)

### Web

- `NEXT_PUBLIC_APP_URL`: Public URL of the web application
- `NEXT_PUBLIC_BACKEND_URL`: Public URL of the backend API

## Production Deployment

For production deployment, you may want to:

1. **Use environment-specific configurations:**

```bash
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
```

2. **Set up proper SSL certificates and reverse proxy (nginx/traefik)**

3. **Use external database services instead of the local PostgreSQL container**

4. **Configure proper backup and monitoring solutions**

## Database Migration

After starting the backend container, you may need to run database migrations:

```bash
docker exec -it eventer-backend-1 bun run db:migrate
```

## Troubleshooting

### Common Issues

1. **Port conflicts**: Make sure ports 3000, 4000, and 5432 are available
2. **Environment variables**: Verify all required environment variables are set
3. **Database connection**: Ensure the database is running and accessible
4. **Build failures**: Check that all dependencies are properly installed

### Logs

View logs for specific services:

```bash
docker-compose logs backend
docker-compose logs web
docker-compose logs db
```

## Development with Docker

For development with hot reloading:

```bash
# Override the default commands for development
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
```

This setup provides a complete containerized environment for the Eventer application with both backend and web components.
62 changes: 62 additions & 0 deletions apps/backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Dependencies
node_modules
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Build outputs
dist
.next
out

# Environment files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# IDE files
.vscode
.idea
*.swp
*.swo

# OS files
.DS_Store
Thumbs.db

# Git
.git
.gitignore
README.md

# Testing
coverage
.nyc_output

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Temporary folders
tmp
temp

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
65 changes: 65 additions & 0 deletions apps/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Backend Dockerfile
FROM oven/bun:1.2.8-alpine AS base

# Prune workspace to only include @eventer/backend and its dependencies
FROM base AS pruner
WORKDIR /app

# Install turbo
RUN bun install -g turbo

# Copy the entire monorepo for pruning
COPY . .

# Prune the workspace for the backend app
RUN turbo prune @eventer/backend --docker

# Install dependencies for the pruned workspace
FROM base AS installer
WORKDIR /app

# Install turbo for building
RUN bun install -g turbo

# Copy pruned workspace
COPY --from=pruner /app/out/json/ .
COPY --from=pruner /app/out/bun.lock* ./

# Install dependencies including dev dependencies for building
RUN bun install

# Copy pruned source code
COPY --from=pruner /app/out/full/ .

# Build the application using turbo
RUN turbo build --filter=@eventer/backend

# Production image, copy all the files and run the app
FROM base AS runner
WORKDIR /app

# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 backend

# Copy the built application from installer stage
COPY --from=installer /app/apps/backend/dist ./dist
COPY --from=installer /app/apps/backend/drizzle ./drizzle

# Copy package.json and remove workspace dependencies
COPY apps/backend/package.json ./package.json
RUN sed -i '/"@eventer\/typescript-config":/d' package.json

# Install only production dependencies
RUN bun install --production

USER backend

# Set environment variables
ENV NODE_ENV=production
ENV PORT=4000

EXPOSE 4000

# Run the application
CMD ["bun", "run", "dist/index.js"]
66 changes: 66 additions & 0 deletions apps/web/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Dependencies
node_modules
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Build outputs
.next
out
dist

# Environment files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# IDE files
.vscode
.idea
*.swp
*.swo

# OS files
.DS_Store
Thumbs.db

# Git
.git
.gitignore
README.md

# Testing
coverage
.nyc_output
tests

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Temporary folders
tmp
temp

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Vitest
vitest.config.ts
Loading