Skip to content

Commit c51f32c

Browse files
committed
Add Docker and GitHub Actions CI/CD.
1 parent 6dcb488 commit c51f32c

6 files changed

Lines changed: 167 additions & 1 deletion

File tree

‎.dockerignore‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
node_modules
2+
.next
3+
.git
4+
.gitignore
5+
*.md
6+
.env
7+
.env.*
8+
!.env.example
9+
.vercel
10+
.tools
11+
coverage
12+
npm-debug.log*
13+
webhook-debug.log
14+
drizzle
15+
docker-compose*.yml
16+
.github

‎.github/workflows/cd.yml‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
12+
jobs:
13+
publish:
14+
name: Build and push image
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: docker/setup-buildx-action@v3
20+
21+
- uses: docker/login-action@v3
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Lowercase image name
28+
run: echo "IMAGE=ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
29+
30+
- name: Image metadata
31+
id: meta
32+
uses: docker/metadata-action@v5
33+
with:
34+
images: ${{ env.IMAGE }}
35+
tags: |
36+
type=sha,prefix=
37+
type=raw,value=latest,enable={{is_default_branch}}
38+
39+
- uses: docker/build-push-action@v6
40+
with:
41+
context: .
42+
file: ./Dockerfile
43+
push: true
44+
tags: ${{ steps.meta.outputs.tags }}
45+
labels: ${{ steps.meta.outputs.labels }}
46+
cache-from: type=gha
47+
cache-to: type=gha,mode=max
48+
build-args: |
49+
NEXT_PUBLIC_APP_URL=${{ vars.NEXT_PUBLIC_APP_URL || 'http://localhost:3000' }}
50+
NEXT_PUBLIC_STREAM_VIDEO_API_KEY=${{ secrets.NEXT_PUBLIC_STREAM_VIDEO_API_KEY || 'placeholder' }}

‎.github/workflows/ci.yml‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
quality:
10+
name: Lint
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: 20
17+
cache: npm
18+
- run: npm ci
19+
- run: npm run lint
20+
21+
docker:
22+
name: Docker build
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: docker/setup-buildx-action@v3
27+
- uses: docker/build-push-action@v6
28+
with:
29+
context: .
30+
file: ./Dockerfile
31+
push: false
32+
tags: nexora-ai:ci
33+
cache-from: type=gha
34+
cache-to: type=gha,mode=max
35+
build-args: |
36+
NEXT_PUBLIC_APP_URL=http://localhost:3000
37+
NEXT_PUBLIC_STREAM_VIDEO_API_KEY=placeholder

‎Dockerfile‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM node:20-alpine AS base
4+
RUN apk add --no-cache libc6-compat
5+
WORKDIR /app
6+
7+
FROM base AS deps
8+
COPY package.json package-lock.json ./
9+
RUN npm ci
10+
11+
FROM base AS builder
12+
COPY --from=deps /app/node_modules ./node_modules
13+
COPY . .
14+
15+
ARG NEXT_PUBLIC_APP_URL=http://localhost:3000
16+
ARG NEXT_PUBLIC_STREAM_VIDEO_API_KEY=placeholder
17+
ENV NEXT_PUBLIC_APP_URL=$NEXT_PUBLIC_APP_URL
18+
ENV NEXT_PUBLIC_STREAM_VIDEO_API_KEY=$NEXT_PUBLIC_STREAM_VIDEO_API_KEY
19+
ENV NEXT_TELEMETRY_DISABLED=1
20+
ENV DATABASE_URL=postgresql://build:build@127.0.0.1:5432/build
21+
ENV BETTER_AUTH_SECRET=docker-build-placeholder-secret-32chars
22+
ENV BETTER_AUTH_URL=$NEXT_PUBLIC_APP_URL
23+
ENV STREAM_VIDEO_SECRET_KEY=docker-build-placeholder-stream-secret
24+
ENV GEMINI_API_KEY=docker-build-placeholder-gemini-key
25+
26+
RUN npm run build
27+
28+
FROM base AS runner
29+
ENV NODE_ENV=production
30+
ENV NEXT_TELEMETRY_DISABLED=1
31+
ENV PORT=3000
32+
ENV HOSTNAME=0.0.0.0
33+
34+
RUN addgroup --system --gid 1001 nodejs \
35+
&& adduser --system --uid 1001 nextjs
36+
37+
COPY --from=builder /app/public ./public
38+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
39+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
40+
41+
USER nextjs
42+
EXPOSE 3000
43+
44+
CMD ["node", "server.js"]

‎docker-compose.yml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
services:
2+
web:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
args:
7+
NEXT_PUBLIC_APP_URL: ${NEXT_PUBLIC_APP_URL:-http://localhost:3000}
8+
NEXT_PUBLIC_STREAM_VIDEO_API_KEY: ${NEXT_PUBLIC_STREAM_VIDEO_API_KEY:-placeholder}
9+
ports:
10+
- "3000:3000"
11+
env_file:
12+
- .env
13+
environment:
14+
NODE_ENV: production
15+
PORT: 3000
16+
HOSTNAME: 0.0.0.0
17+
restart: unless-stopped

‎next.config.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { NextConfig } from "next";
22

3-
const nextConfig: NextConfig = {};
3+
const nextConfig: NextConfig = {
4+
output: "standalone",
5+
};
46

57
export default nextConfig;

0 commit comments

Comments
 (0)