Skip to content

Dockerfile, edits in lecture page #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Node stuff that will be (re)installed inside image
node_modules
npm-debug.log
yarn-error.log

# Build outputs / local dev artifacts
dist
/.astro
/.vercel
/.turbo

# Git metadata
.git
.gitignore

# Editor/OS cruft
.vscode/
*.swp
.DS_Store

# Local environment files (could contain secrets)
.env
.env.local
.env.*.local

# Logs
*.log

# Optional: if you have scripts or assets not needed in build context
tests/
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Step 1: Build the Astro site
FROM node:18-alpine AS build

# Set working directory
WORKDIR /app

# Install dependencies
COPY package*.json ./
RUN npm install

# Copy all files
COPY . .

# Expose default static site port
EXPOSE 10000

#run
# CMD ["npm", "run", "dev"]

# # update in future
# # Step 2: Use a lightweight image to serve the site
# FROM node:18-alpine

# # Install a static server (you could also use nginx here)
# RUN npm install -g serve

# # Set working directory
# WORKDIR /app

# # # Copy built files from previous stage
# COPY --from=build /app/dist .

# # # Start the static server
# CMD ["serve", "-s", ".", "-l", "10000"]


7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: '3.8'

services:
astro:
build: .
ports:
- "3000:10000"
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
},
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/js-yaml": "^4.0.9",
"@types/katex": "^0.16.7",
"@types/node": "^20.14.9",
"jest": "^29.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const question: MultipleChoiceQuestion = {
body: "If you flip a fair coin 4 times, what is the probability that the coin comes up heads exactly twice?",
options: [
{ label: "$1/{{4}\\choose{2}}$", correct: false },
{ label: "$2/2^{4}$", false: true },
{ label: "$2/2^{4}$", correct: true },// npm run build error due to false:true cahnged to correcT:true
{ label: "$2^{4}/{{4}\\choose{2}}$", correct: false },
{ label: "${{4}\\choose{2}}/2^{4}$", correct: true },
],
Expand Down
14 changes: 12 additions & 2 deletions src/pages/lectures.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ import fs from "fs";
import path from "path";
import yaml from "js-yaml";


//fixed type error in lectures
//downloaded js-yaml in package.json
interface Lecture{
course: string;
link: string;
title: string;
}


const filePath = path.resolve("src/data/lectures.yml");
const file = fs.readFileSync(filePath, "utf8");
const lectures = yaml.load(file);
const lectures:Lecture[] = yaml.load(file) as Lecture[];

const grouped = {};
const grouped: Record<string, Lecture[]> = {};
for (const lec of lectures) {
if (!grouped[lec.course]) grouped[lec.course] = [];
grouped[lec.course].push(lec);
Expand Down
Loading