diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..872d92f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ + +FROM node:18-alpine + +WORKDIR /app + +COPY package.json ./ + +RUN npm install + +RUN npm install --save-dev + +# Build the Next.js app +RUN npm run build + +# Expose the port the app will run on +EXPOSE 3000 + +COPY . . + +CMD ["npm", "run", "dev"] \ No newline at end of file diff --git a/app/favicon.ico b/app/favicon.ico index 04fa867..c2a2a04 100644 Binary files a/app/favicon.ico and b/app/favicon.ico differ diff --git a/components/Aboutus/AboutusContent.tsx b/components/Aboutus/AboutusContent.tsx index 612a8ca..0f04680 100644 --- a/components/Aboutus/AboutusContent.tsx +++ b/components/Aboutus/AboutusContent.tsx @@ -13,7 +13,7 @@ const AboutusContent = ({ aboutus }: { aboutus: AboutusProps[] }) => {
Course Image { {item.description}

*/}
@@ -54,7 +54,7 @@ const AboutusContent = ({ aboutus }: { aboutus: AboutusProps[] }) => {
Course Image {
Course Image { {item.description}

*/}
diff --git a/components/Aboutus/Map.tsx b/components/Aboutus/Map.tsx index 35ab2d4..90d1ca1 100644 --- a/components/Aboutus/Map.tsx +++ b/components/Aboutus/Map.tsx @@ -47,7 +47,7 @@ const Map = ({ settings }: { settings: SettingsProps }) => {

{"地址"}

- diff --git a/components/Course/Collapse.tsx b/components/Course/Collapse.tsx index 9b5dc90..b252342 100644 --- a/components/Course/Collapse.tsx +++ b/components/Course/Collapse.tsx @@ -13,7 +13,7 @@ interface CollapseProps { className?: string info?: boolean info_images?: Array - + } @@ -113,7 +113,7 @@ const Collapse: React.FC = ({ title, children, className, info, i {info_images.map((image, index) => (
{`Course @@ -128,7 +128,7 @@ const Collapse: React.FC = ({ title, children, className, info, i
{`Course diff --git a/components/Course/CourseImagesSilder.tsx b/components/Course/CourseImagesSilder.tsx index 3f20327..025869d 100644 --- a/components/Course/CourseImagesSilder.tsx +++ b/components/Course/CourseImagesSilder.tsx @@ -107,7 +107,7 @@ const CourseImagesSilder = ({ courseData }: { courseData: CoursesProps }) => { {courseData.images.map((image, index) => (
{`Course @@ -127,7 +127,7 @@ const CourseImagesSilder = ({ courseData }: { courseData: CoursesProps }) => {
{`Course diff --git a/components/Course/LongDesc.tsx b/components/Course/LongDesc.tsx index 3447b3f..b266df5 100644 --- a/components/Course/LongDesc.tsx +++ b/components/Course/LongDesc.tsx @@ -8,7 +8,7 @@ const LongDesc = ({ courseData }: { courseData: CoursesProps }) => { {courseData.title}

diff --git a/components/CoursesSilder.tsx b/components/CoursesSilder.tsx index dc7ac45..25fdb91 100644 --- a/components/CoursesSilder.tsx +++ b/components/CoursesSilder.tsx @@ -49,7 +49,7 @@ const CoursesSilder = ({ courses }: { courses: CoursesProps[] }) => {
Course Image {
Course Image diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7ea57ee --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,35 @@ +services: + app: + build: + context: . + dockerfile: Dockerfile + container_name: docker-next + + env_file: + - .env + ports: + - '3000:3000' + volumes: + - .:/app + - /app/node_modules + labels: + - traefik.enable=true + - traefik.docker.network=traefik-public + - traefik.constraint-label=traefik-public + + - traefik.http.services.${STACK_NAME?Variable not set}-frontend.loadbalancer.server.port=80 + + - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`) + - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.entrypoints=http + + - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`) + - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.entrypoints=https + - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.tls=true + - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.tls.certresolver=le + + # Enable www redirection for HTTP and HTTPS + - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.middlewares=${STACK_NAME?Variable not set}-www-redirect + - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.middlewares=https-redirect,${STACK_NAME?Variable not set}-www-redirect + networks: + - traefik-public + - default \ No newline at end of file diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..c2a2a04 Binary files /dev/null and b/favicon.ico differ diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..c2a2a04 Binary files /dev/null and b/public/favicon.ico differ diff --git a/utils/index.ts b/utils/index.ts index 166146d..ae353d3 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -11,7 +11,7 @@ export async function postMessage(data: MessageProps) { }; const body = JSON.stringify(data); - const url = `http://localhost/api/v1/messages/`; + const url = `${process.env.NEXT_PUBLIC_API_URL}messages/`; try { const response = await fetch(url, { @@ -41,7 +41,7 @@ export async function fetchAboutus() { const headers: HeadersInit = { accept: "application/json" }; - const url = `${process.env.api_url}aboutUs`; + const url = `${process.env.NEXT_PUBLIC_API_URL}aboutUs/`; console.log('Fetching from URL:', url); try { const response = await fetch(url, { headers }); @@ -67,7 +67,7 @@ export async function fetchCourses() { accept: "application/json" }; - const url = `${process.env.api_url}course/?skip=0&limit=100`; + const url = `${process.env.NEXT_PUBLIC_API_URL}course/?skip=0&limit=100`; console.log('Fetching from URL:', url); try { @@ -83,7 +83,11 @@ export async function fetchCourses() { info_images: course?.info_images?.sort((a: any, b: any) => a.index - b.index), })); - return coursesArray; + const sortedCoursesArray = coursesArray.sort((a, b) => + new Date(a.created_at).getTime() - new Date(b.created_at).getTime() + ); + + return sortedCoursesArray; } catch (error) { console.error('Fetch error:', error); throw error; @@ -95,7 +99,7 @@ export async function fetchCourse(id: string) { accept: "application/json" }; - const url = `${process.env.api_url}course/${id}`; + const url = `${process.env.NEXT_PUBLIC_API_URL}course/${id}/`; console.log('Fetching from URL:', url); try { @@ -120,7 +124,7 @@ export async function fetchSettings() { const headers: HeadersInit = { accept: "application/json" }; - const url = `${process.env.api_url}setting`; + const url = `${process.env.NEXT_PUBLIC_API_URL}setting/`; console.log('Fetching from URL:', url); try { const response = await fetch(url, { headers });