-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
42 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,44 @@ | ||
# Use an official Node.js 22 as a parent image | ||
FROM node:22-alpine | ||
# Use an official Node.js LTS version as a base image | ||
FROM node:20-alpine AS base | ||
|
||
WORKDIR /usr/src/app | ||
|
||
# ARG for build-time variable (GATEWAY_API_URL) | ||
ARG GATEWAY_API_URL | ||
|
||
# ENV for URL to be used in the app | ||
ENV NEXT_PUBLIC_API_GATEWAY_URL=${GATEWAY_API_URL} | ||
ENV PORT=80 | ||
|
||
# Copy package.json and package-lock.json (or yarn.lock) into the container | ||
# Set the working directory | ||
WORKDIR /usr/src/app | ||
|
||
# Install dependencies in a separate layer to optimize caching | ||
COPY package*.json ./ | ||
|
||
RUN npm install | ||
# Install dependencies | ||
RUN npm ci | ||
|
||
# Copy the rest of the application code | ||
COPY . . | ||
|
||
# Build the Next.js app | ||
RUN npm run build | ||
|
||
# Reduce the size of the final image by using a lighter base image | ||
FROM node:20-alpine AS runner | ||
|
||
# Set the working directory | ||
WORKDIR /usr/src/app | ||
|
||
# Copy only the necessary files from the build stage | ||
COPY --from=base /usr/src/app/.next ./.next | ||
COPY --from=base /usr/src/app/public ./public | ||
COPY --from=base /usr/src/app/package*.json ./ | ||
|
||
# Install production dependencies | ||
RUN npm ci --production | ||
|
||
|
||
# Set the environment variables | ||
ENV PORT=80 | ||
|
||
# Expose the port | ||
EXPOSE 80 | ||
CMD ["npm", "start"] | ||
|
||
# Start the application | ||
CMD ["npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
reactStrictMode: true, | ||
output: "export", | ||
// distDir should be "../api/static" in production but .next in development | ||
distDir: process.env.NODE_ENV === "development" ? ".next" : "../api/static", | ||
images: { | ||
unoptimized: true, | ||
}, | ||
// base path for static files should be "" in development but "/static" in production | ||
basePath: process.env.NODE_ENV === "development" ? "" : "/static", | ||
}; | ||
|
||
module.exports = nextConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters