diff --git a/nextjs/.dockerignore b/nextjs/.dockerignore new file mode 100644 index 0000000..7c64fb8 --- /dev/null +++ b/nextjs/.dockerignore @@ -0,0 +1,10 @@ +.next/ +node_modules/ +storage/ +temp/ +.env +build.sh +run.sh +README.md + + diff --git a/nextjs/Dockerfile b/nextjs/Dockerfile new file mode 100644 index 0000000..8a5c536 --- /dev/null +++ b/nextjs/Dockerfile @@ -0,0 +1,15 @@ +FROM node:22-alpine + +WORKDIR /app + +COPY package*.json . + +RUN npm i + +COPY . . + +RUN mkdir -p storage + +RUN npm run build + +CMD [ "npm", "run", "start" ] \ No newline at end of file diff --git a/nextjs/build.sh b/nextjs/build.sh new file mode 100755 index 0000000..6a9923e --- /dev/null +++ b/nextjs/build.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +MAJOR_VERSION="2" +MINOR_VERSION="0" +VERSION="$MAJOR_VERSION.$MINOR_VERSION" + +docker build -t canvas_management:$VERSION . + + + +echo "to push run: " +echo "" +echo "docker image tag canvas_management:$VERSION alexmickelson/canvas_management:$VERSION" +echo "docker image tag canvas_management:$VERSION alexmickelson/canvas_management:$MAJOR_VERSION" +echo "docker image tag canvas_management:latest alexmickelson/canvas_management:latest" +echo "docker push alexmickelson/canvas_management:$VERSION" +echo "docker push alexmickelson/canvas_management:$MAJOR_VERSION" +echo "docker push alexmickelson/canvas_management:latest" + diff --git a/nextjs/docker-compose.yml b/nextjs/docker-compose.yml new file mode 100644 index 0000000..668e57f --- /dev/null +++ b/nextjs/docker-compose.yml @@ -0,0 +1,17 @@ +services: + canvas_manager: + image: alexmickelson/canvas_management:2 + user: "1000:1000" + ports: + - 3000:3000 + env_file: + - .env + environment: + - storageDirectory=/app/storage + - TZ=America/Denver + volumes: + - ~/projects/faculty/1430/2024-fall-alex/modules:/app/storage/UX + - ~/projects/faculty/4850_AdvancedFE/2024-fall-alex/modules:/app/storage/advanced_frontend + - ~/projects/faculty/1810/2024-fall-alex/modules:/app/storage/intro_to_web + # - ~/projects/faculty/1420/2024-fall/Modules:/app/storage/1420 + # - ~/projects/faculty/1425/2024-fall/Modules:/app/storage/1425 \ No newline at end of file diff --git a/nextjs/src/app/layout.tsx b/nextjs/src/app/layout.tsx index 96306dc..31e11c9 100644 --- a/nextjs/src/app/layout.tsx +++ b/nextjs/src/app/layout.tsx @@ -6,6 +6,7 @@ import { getQueryClient } from "./providersQueryClientUtils"; import { hydrateCourses } from "@/hooks/hookHydration"; import { dehydrate, HydrationBoundary } from "@tanstack/react-query"; import { MyToaster } from "./MyToaster"; +import { cookies } from "next/headers"; export const metadata: Metadata = { title: "Canvas Manager 2.0", @@ -19,6 +20,7 @@ export default async function RootLayout({ const queryClient = getQueryClient(); await hydrateCourses(queryClient); const dehydratedState = dehydrate(queryClient); + cookies() // disables static page generation at build time return ( diff --git a/nextjs/src/services/axiosUtils.ts b/nextjs/src/services/axiosUtils.ts index a2f163b..f0c167c 100644 --- a/nextjs/src/services/axiosUtils.ts +++ b/nextjs/src/services/axiosUtils.ts @@ -17,14 +17,16 @@ if (!isServer) { } else { const token = process.env.CANVAS_TOKEN; if (!token) { - throw new Error("CANVAS_TOKEN not in environment"); + console.error("CANVAS_TOKEN not in environment") + // throw new Error("CANVAS_TOKEN not in environment"); + } else { + axiosClient.interceptors.request.use((config) => { + if (config.url && config.url.startsWith(canvasBaseUrl)) { + config.headers.set("Authorization", `Bearer ${token}`); + } + return config; + }); } - axiosClient.interceptors.request.use((config) => { - if (config.url && config.url.startsWith(canvasBaseUrl)) { - config.headers.set("Authorization", `Bearer ${token}`); - } - return config; - }); } axiosClient.interceptors.response.use(