Skip to content

Commit

Permalink
added dockerhub support
Browse files Browse the repository at this point in the history
  • Loading branch information
eibrahim committed Feb 17, 2025
1 parent f3086a2 commit 9963675
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 2 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Docker Publish

on:
push:
branches: ["main"]
tags: ["v*.*.*"]
pull_request:
branches: ["main"]

env:
REGISTRY: docker.io
IMAGE_NAME: eibrahim/fluid-calendar

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log into Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: docker/production/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,40 @@ Note: For production deployment, you'll need to:

## Installation

### Option 1: Local Development
### Option 1: Docker Image (Recommended)

The easiest way to run FluidCalendar is using our official Docker image:

```bash
# Pull the latest image
docker pull eibrahim/fluid-calendar:latest

# Create a .env file
cat > .env << EOL
DATABASE_URL=file:/app/data/dev.db
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-secret-key
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
EOL

# Run the container
docker run -d \
--name fluid-calendar \
-p 3000:3000 \
-v $(pwd)/data:/app/data \
--env-file .env \
eibrahim/fluid-calendar:latest
```

Available tags:
- `latest` - Latest stable release
- `dev` - Development version
- `v*.*.*` - Specific versions (e.g., v1.0.0)

For production deployments, we recommend using specific version tags.

### Option 2: Local Development

1. Clone the repository:
```bash
Expand Down Expand Up @@ -131,7 +164,7 @@ npm run prisma:migrate
npm run clean
```

### Option 2: Docker Development
### Option 3: Docker Development

We provide a Docker setup for easy development. This is the recommended way to get started.

Expand Down
48 changes: 48 additions & 0 deletions docker/production/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Build stage
FROM node:20-alpine AS builder

WORKDIR /app

# Install dependencies
COPY package*.json ./
COPY prisma ./prisma/

# Install dependencies and generate Prisma client
RUN npm ci
RUN npx prisma generate

# Copy source
COPY . .

# Build application
RUN npm run build

# Production stage
FROM node:20-alpine AS runner

WORKDIR /app

# Install production dependencies
COPY --from=builder /app/package*.json ./
RUN npm ci --only=production

# Copy built application
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma

# Create and switch to non-root user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs

# Expose port
EXPOSE 3000

# Set environment variables
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1

# Start the application
CMD ["npm", "start"]

0 comments on commit 9963675

Please sign in to comment.