7
This commit is contained in:
parent
98c52e5525
commit
4a2c6a83e6
@ -3,9 +3,9 @@ FROM fascinated/docker-images:nodejs_20_with_pnpm AS base
|
|||||||
# Install dependencies and build the app
|
# Install dependencies and build the app
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json* pnpm-lock.yaml* ./
|
COPY ./backend/package.json* ./backend/pnpm-lock.yaml* ./
|
||||||
RUN pnpm install --frozen-lockfile --quiet
|
RUN pnpm install --frozen-lockfile --quiet
|
||||||
COPY . .
|
COPY ./backend .
|
||||||
RUN pnpm run build
|
RUN pnpm run build
|
||||||
|
|
||||||
# Final stage to run the app
|
# Final stage to run the app
|
||||||
|
@ -6,8 +6,8 @@ FROM base AS deps
|
|||||||
RUN apk add --no-cache python3 make g++ gcc pkgconfig pixman cairo-dev libjpeg-turbo-dev pango-dev giflib-dev
|
RUN apk add --no-cache python3 make g++ gcc pkgconfig pixman cairo-dev libjpeg-turbo-dev pango-dev giflib-dev
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy frontend package and lock files only
|
# Copy website package and lock files only
|
||||||
COPY ./frontend/package.json* ./frontend/pnpm-lock.yaml* ./
|
COPY ./website/package.json* ./website/pnpm-lock.yaml* ./
|
||||||
RUN pnpm install --frozen-lockfile --quiet
|
RUN pnpm install --frozen-lockfile --quiet
|
||||||
|
|
||||||
# Build stage
|
# Build stage
|
||||||
@ -17,15 +17,13 @@ WORKDIR /app
|
|||||||
# Copy node_modules from deps stage
|
# Copy node_modules from deps stage
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
|
||||||
# Copy all necessary files from both ./frontend and ./
|
COPY ./website ./website
|
||||||
# This ensures you have access to both frontend code and shared types in root
|
|
||||||
COPY ./frontend ./frontend
|
|
||||||
|
|
||||||
# Install runtime dependencies
|
# Install runtime dependencies
|
||||||
RUN apk add --no-cache cairo pango libjpeg-turbo giflib
|
RUN apk add --no-cache cairo pango libjpeg-turbo giflib
|
||||||
|
|
||||||
# Build the frontend app
|
# Build the website app
|
||||||
WORKDIR /app/frontend
|
WORKDIR /app/website
|
||||||
RUN pnpm run build
|
RUN pnpm run build
|
||||||
|
|
||||||
# Final stage for running the app
|
# Final stage for running the app
|
||||||
@ -44,15 +42,15 @@ RUN addgroup --system --gid 1001 nodejs
|
|||||||
RUN adduser --system --uid 1001 nextjs
|
RUN adduser --system --uid 1001 nextjs
|
||||||
|
|
||||||
# Ensure necessary directories exist and are writable
|
# Ensure necessary directories exist and are writable
|
||||||
RUN mkdir /app/frontend/.next
|
RUN mkdir /app/website/.next
|
||||||
RUN chown nextjs:nodejs /app/frontend/.next
|
RUN chown nextjs:nodejs /app/website/.next
|
||||||
|
|
||||||
# Copy built files from the builder stage
|
# Copy built files from the builder stage
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/frontend/node_modules ./frontend/node_modules
|
COPY --from=builder --chown=nextjs:nodejs /app/website/node_modules ./website/node_modules
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/frontend/.next ./frontend/.next
|
COPY --from=builder --chown=nextjs:nodejs /app/website/.next ./website/.next
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/frontend/public ./frontend/public
|
COPY --from=builder --chown=nextjs:nodejs /app/website/public ./website/public
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/frontend/package.json ./frontend/package.json
|
COPY --from=builder --chown=nextjs:nodejs /app/website/package.json ./website/package.json
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/frontend/next.config.mjs ./frontend/next.config.mjs
|
COPY --from=builder --chown=nextjs:nodejs /app/website/next.config.mjs ./website/next.config.mjs
|
||||||
|
|
||||||
# Switch to non-root user
|
# Switch to non-root user
|
||||||
USER nextjs
|
USER nextjs
|
||||||
|
Reference in New Issue
Block a user