Skip to content

Commit

Permalink
Updated Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhinav-ark committed Oct 16, 2024
1 parent 4974219 commit 77c235b
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 20 deletions.
5 changes: 0 additions & 5 deletions .env.local

This file was deleted.

57 changes: 48 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,61 @@
FROM node:20-alpine
ARG NEXT_PUBLIC_IS_PRODUCTION
ARG NEXT_PUBLIC_PAY_U_KEY_TEST
ARG NEXT_PUBLIC_PAY_U_KEY_PROD

FROM node:20-alpine AS base

FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app

WORKDIR /anokha
# Install dependencies based on the preferred package manager
COPY package.json package-lock.json* ./
RUN npm i --force;

# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Set environment variables needed for build
ARG NEXT_PUBLIC_IS_PRODUCTION
ARG NEXT_PUBLIC_PAY_U_KEY_TEST
ARG NEXT_PUBLIC_PAY_U_KEY_PROD
# Pass them to the build process
ENV NEXT_PUBLIC_IS_PRODUCTION=${NEXT_PUBLIC_IS_PRODUCTION}
ENV NEXT_PUBLIC_PAY_U_KEY_TEST=${NEXT_PUBLIC_PAY_U_KEY_TEST}
ENV NEXT_PUBLIC_PAY_U_KEY_PROD=${NEXT_PUBLIC_PAY_U_KEY_PROD}

RUN npm run build;

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV=production

# Pass them to the build process
ENV NEXT_PUBLIC_IS_PRODUCTION=${NEXT_PUBLIC_IS_PRODUCTION}
ENV NEXT_PUBLIC_PAY_U_KEY_TEST=${NEXT_PUBLIC_PAY_U_KEY_TEST}
ENV NEXT_PUBLIC_PAY_U_KEY_PROD=${NEXT_PUBLIC_PAY_U_KEY_PROD}

RUN npm i --force
# Disable NextJS sending telemetry data to Vercel
ENV NEXT_TELEMETRY_DISABLED=1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3002

RUN npm run build
ENV PORT=3002

CMD ["npm","run","start"]
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
16 changes: 10 additions & 6 deletions src/app/_util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ const BASE_URL = "https://anokha.amrita.edu/api";
const HACKATHON_URL = "https://anokha.amrita.edu/api/intel";

export const payU_Key =
process.env.NEXT_PUBLIC_IS_PRODUCTION === "1"
? process.env.NEXT_PUBLIC_PAY_U_KEY_PROD
: process.env.NEXT_PUBLIC_PAY_U_KEY_TEST;
process.env.NEXT_PUBLIC_IS_PRODUCTION === "0"
? process.env.NEXT_PUBLIC_PAY_U_KEY_TEST
:
(
process.env.NEXT_PUBLIC_PAY_U_KEY_PROD ?? "ypfBaJ" // Dummy test Key
);
export const payU_Action =
process.env.NEXT_PUBLIC_IS_PRODUCTION === "1"
? "https://secure.payu.in/_payment"
: "https://test.payu.in/_payment";
process.env.NEXT_PUBLIC_IS_PRODUCTION === "0"
? "https://test.payu.in/_payment"
:"https://secure.payu.in/_payment";

export const ALL_TRANSACTION_URL = BASE_URL + "/user/getAllTransactions";
export const EDIT_PROFILE_URL = BASE_URL + "/user/editStudentProfile";
export const STUDENT_PROFILE_URL = BASE_URL + "/user/getStudentProfile";
Expand Down

0 comments on commit 77c235b

Please sign in to comment.