Skip to content
Merged
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
25 changes: 10 additions & 15 deletions 3 - PB/MVP/src/compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
services:
# next.js frontend
# nextapp:
# container_name: nextapp
# image: nextapp:1.0.0
# build:
# context: ./frontend
# dockerfile: next.dockerfile
# ports:
# - 3000:3000
# environment:
# - NODE_ENV=development
# - WATCHPACK_POLLING=true
# - NEXT_PUBLIC_API_URL=http://localhost:4000
# depends_on:
# - flaskapp
nextapp:
container_name: nextapp
image: nextapp:1.0.0
build:
context: ./frontend
dockerfile: next.dockerfile
ports:
- 3000:3000
depends_on:
- flaskapp

# flask backend
flaskapp:
Expand Down Expand Up @@ -63,7 +59,6 @@ services:
volumes:
- pgdata:/var/lib/postgresql/data


secrets:
aws_access_key_id:
file: ./secrets/aws_access_key_id.txt
Expand Down
7 changes: 7 additions & 0 deletions 3 - PB/MVP/src/frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git
3 changes: 2 additions & 1 deletion 3 - PB/MVP/src/frontend/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
output: 'standalone',
images: {
remotePatterns: [
{
Expand All @@ -23,4 +24,4 @@ const nextConfig = {
},
}

export default nextConfig
export default nextConfig
68 changes: 68 additions & 0 deletions 3 - PB/MVP/src/frontend/next.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
FROM node:21-alpine AS base

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app

RUN npm install -g node-gyp;
RUN apk add --no-cache \
build-base \
g++ \
cairo-dev \
jpeg-dev \
pango-dev \
giflib-dev

# Install dependencies based on the preferred package manager
COPY package.json package-lock.json* ./
RUN npm ci;


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

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN npm run build;

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

ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# 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

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT 3000
ENV HOSTNAME "0.0.0.0"
ENV API_URL "http://172.19.0.3:4000"

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD ["node", "server.js"]
Loading