added build steps

This commit is contained in:
2024-09-24 08:33:11 -06:00
parent eb73b7217f
commit 6eaf48609e
6 changed files with 72 additions and 7 deletions

10
nextjs/.dockerignore Normal file
View File

@@ -0,0 +1,10 @@
.next/
node_modules/
storage/
temp/
.env
build.sh
run.sh
README.md

15
nextjs/Dockerfile Normal file
View File

@@ -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" ]

19
nextjs/build.sh Executable file
View File

@@ -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"

17
nextjs/docker-compose.yml Normal file
View File

@@ -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

View File

@@ -6,6 +6,7 @@ import { getQueryClient } from "./providersQueryClientUtils";
import { hydrateCourses } from "@/hooks/hookHydration"; import { hydrateCourses } from "@/hooks/hookHydration";
import { dehydrate, HydrationBoundary } from "@tanstack/react-query"; import { dehydrate, HydrationBoundary } from "@tanstack/react-query";
import { MyToaster } from "./MyToaster"; import { MyToaster } from "./MyToaster";
import { cookies } from "next/headers";
export const metadata: Metadata = { export const metadata: Metadata = {
title: "Canvas Manager 2.0", title: "Canvas Manager 2.0",
@@ -19,6 +20,7 @@ export default async function RootLayout({
const queryClient = getQueryClient(); const queryClient = getQueryClient();
await hydrateCourses(queryClient); await hydrateCourses(queryClient);
const dehydratedState = dehydrate(queryClient); const dehydratedState = dehydrate(queryClient);
cookies() // disables static page generation at build time
return ( return (
<html lang="en"> <html lang="en">

View File

@@ -17,14 +17,16 @@ if (!isServer) {
} else { } else {
const token = process.env.CANVAS_TOKEN; const token = process.env.CANVAS_TOKEN;
if (!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( axiosClient.interceptors.response.use(