Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
bentwnghk committed Feb 14, 2025
2 parents dd621b8 + 23b9089 commit 859c308
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 30 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Docker Build and Push

on:
push:
branches: [main]
pull_request:
branches: [main]

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: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
44 changes: 18 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,33 @@
FROM oven/bun:1 AS base
WORKDIR /app

# build
FROM base AS builder
# Base image
FROM oven/bun:1.1.3-alpine AS builder

# Install build tools
RUN apk add --no-cache nodejs npm git

WORKDIR /app

# Install dependencies (separated for better cache utilization)
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile

# Copy source code and build
COPY . .
# in production build, skip validation of typescript
RUN sed -i 's/nextConfig = {/nextConfig = { typescript: { ignoreBuildErrors: true }, eslint: { ignoreDuringBuilds: true },/' next.config.mjs
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
RUN bun next telemetry disable
RUN bun run build

# Production image, copy all the files and run next
FROM base AS runner
# Runtime stage
FROM oven/bun:1.1.3-alpine AS runner
WORKDIR /app

ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1

# Copy only necessary files from builder
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/bun.lockb ./bun.lockb
COPY --from=builder /app/node_modules ./node_modules

# Set the correct permission for prerender cache
RUN mkdir .next && chown bun:bun .next

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=bun:bun /app/.next/standalone ./
COPY --from=builder --chown=bun:bun /app/.next/static ./.next/static

USER bun

EXPOSE 3000

ENV PORT=3000

CMD ["bun", "run", "server.js"]
# Start development server
CMD ["bun", "dev", "-H", "0.0.0.0"]
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,31 @@ Visit http://localhost:3000 in your browser.

## 🌐 Deploy

Host your own live version of Morphic with Vercel or Cloudflare Pages.
Host your own live version of Morphic with Vercel, Cloudflare Pages, or Docker.

### Vercel

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fmiurla%2Fmorphic&env=OPENAI_API_KEY,TAVILY_API_KEY,UPSTASH_REDIS_REST_URL,UPSTASH_REDIS_REST_TOKEN)

### Docker Prebuilt Image

Prebuilt Docker images are available on GitHub Container Registry:

```bash
docker pull ghcr.io/miurla/morphic:latest
```

You can use it with docker-compose:

```yaml
services:
morphic:
image: ghcr.io/miurla/morphic:latest
env_file: .env.local
ports:
- '3000:3000'
```
## 🔎 Search Engine
### Setting up the Search Engine in Your Browser
Expand Down
12 changes: 9 additions & 3 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# This is a Docker Compose file for setting up the morphic-stack environment.
# Docker Compose configuration for the morphic-stack development environment

name: morphic-stack
services:
morphic:
container_name: morphic
image: ghcr.io/miurla/morphic:latest
image: ghcr.io/${GITHUB_REPOSITORY:-your-username/morphic}:latest
build:
context: .
dockerfile: Dockerfile
cache_from:
- morphic:builder
- morphic:latest
command: bun dev -H 0.0.0.0
env_file: .env.local # Load environment variables
ports:
- '3000:3000' # Maps port 3000 on the host to port 3000 in the container.
Expand Down

0 comments on commit 859c308

Please sign in to comment.