build error fixes
This commit is contained in:
31
DockerFile
31
DockerFile
@ -1,23 +1,36 @@
|
||||
FROM node:18-alpine
|
||||
# Stage 1: Build
|
||||
FROM node:18-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files and install dependencies
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm install
|
||||
RUN npm install --production
|
||||
|
||||
# Copy the rest of the code
|
||||
COPY . .
|
||||
|
||||
# Build Next.js
|
||||
# Build-time environment variable
|
||||
ARG NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com
|
||||
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Run
|
||||
FROM node:18-alpine AS runner
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/package.json ./
|
||||
COPY --from=builder /app/package-lock.json ./
|
||||
COPY --from=builder /app/.next ./.next
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/next.config.js ./next.config.js
|
||||
|
||||
RUN npm install --production
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
# Make sure Next.js binds to all interfaces
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com
|
||||
ENV HOST=0.0.0.0
|
||||
|
||||
# Optionally, set the API URL here if you want
|
||||
ENV NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com
|
||||
|
||||
CMD ["npm", "start"]
|
||||
|
||||
@ -2,14 +2,14 @@ version: "3.9"
|
||||
|
||||
services:
|
||||
nextjs:
|
||||
build: .
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
NEXT_PUBLIC_API_URL: https://cmcbackend.rootxwire.com
|
||||
container_name: cmc_nextjs_pro
|
||||
ports:
|
||||
- "9012:3000"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com
|
||||
NODE_ENV: production
|
||||
NEXT_PUBLIC_API_URL: https://cmcbackend.rootxwire.com
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- .:/app
|
||||
- /app/node_modules
|
||||
@ -52,7 +52,8 @@ export interface FacultyApiResponse {
|
||||
|
||||
// API service class
|
||||
export class FacultyService {
|
||||
private static baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:8080';
|
||||
private static baseUrl =
|
||||
process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080';
|
||||
|
||||
static async getAllFaculty(): Promise<TeamMember[]> {
|
||||
try {
|
||||
@ -63,9 +64,7 @@ export class FacultyService {
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
||||
|
||||
const data: FacultyApiResponse = await response.json();
|
||||
return this.transformProfessorsToTeamMembers(data.content);
|
||||
@ -77,8 +76,6 @@ export class FacultyService {
|
||||
|
||||
static async getFacultyById(id: number): Promise<TeamMember | null> {
|
||||
try {
|
||||
// Find by array index from getAllFaculty for now
|
||||
// In production, you might want a direct API call
|
||||
const allFaculty = await this.getAllFaculty();
|
||||
return allFaculty.find(member => member.id === id) || null;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user