Skip to content

Commit

Permalink
Merge pull request #186 from rit-sse/docker-deployment
Browse files Browse the repository at this point in the history
Docker deployment & new CI
  • Loading branch information
PokeJofeJr4th authored Nov 3, 2024
2 parents da6aa53 + b356bc1 commit 88f8a15
Show file tree
Hide file tree
Showing 29 changed files with 144 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Docker Image CI

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

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Build the Docker image
working-directory: ./next
run: docker build . --file Dockerfile --tag sse-web:$(date +%s)
70 changes: 70 additions & 0 deletions next/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
FROM node:20 AS base

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.

WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

RUN npx prisma generate

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED=1

RUN \
if [ -f yarn.lock ]; then yarn run build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi

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

ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED=1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

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

USER nextjs

EXPOSE 3000

ENV PORT=3000

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
2 changes: 2 additions & 0 deletions next/app/api/authLevel/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { PrismaClient } from "@prisma/client";
import { NextRequest, NextResponse } from "next/server";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

/**
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/course/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

/**
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/course/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

/**
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/courseTaken/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Prisma, PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

/**
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/departments/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

/**
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/departments/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

/**
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/go/[golink]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

/**
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/golinks/officer/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client"

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient()

export async function GET() {
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/golinks/public/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client"

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient()

export async function GET() {
Expand Down
3 changes: 3 additions & 0 deletions next/app/api/golinks/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

function validateGoLink(goLink: string) {
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/hourBlocks/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

/**
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/mentor/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

/**
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/mentor/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

/**
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/mentorSkill/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

export async function GET(request: Request, { params }: { params: { id: string } }) {
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/mentorSkill/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

export async function GET() {
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/officer/[active]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

export async function GET() {
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/officer/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

export async function GET() {
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/quotes/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

/**
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/quotes/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

/**
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/schedule/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

/**
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/schedule/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Prisma, PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

/**
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/skill/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

export async function GET(request: Request, { params }: { params: { id: string } }) {
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/skill/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

export async function GET() {
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/skills/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

export async function GET(request: Request, { params }: { params: { id: string } }) {
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/skills/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

export async function GET() {
Expand Down
2 changes: 2 additions & 0 deletions next/app/api/user/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PrismaClient } from "@prisma/client";

export const dynamic = 'force-dynamic'

const prisma = new PrismaClient();

/**
Expand Down
3 changes: 2 additions & 1 deletion next/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
const nextConfig = {
images: {
domains: ['dummyimage.com']
}
},
output: "standalone",
}

module.exports = nextConfig

0 comments on commit 88f8a15

Please sign in to comment.