mirror of
https://github.com/M4X809/list-of-lp.git
synced 2025-12-25 19:12:48 +00:00
Refactor Dockerfile for improved build process and configuration management
- Updated the Dockerfile to use the latest base image and streamline the multi-stage build process. - Enhanced dependency installation by copying additional configuration files and using the `--frozen-lockfile` option. - Set environment variables for production settings and localization. - Adjusted the command to start the application, ensuring it runs the correct entry point.
This commit is contained in:
parent
bdc5fbc8fd
commit
ddbd73fd3e
1 changed files with 30 additions and 21 deletions
51
Dockerfile
51
Dockerfile
|
|
@ -1,25 +1,33 @@
|
||||||
# Use bun as the base image
|
# Use bun as the base image
|
||||||
FROM oven/bun:1 AS base
|
FROM oven/bun:latest AS deps
|
||||||
|
|
||||||
# Install dependencies only when needed
|
# Install dependencies only when needed
|
||||||
FROM base AS deps
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy dependency files
|
COPY package.json bunfig.toml next.config.ts ./
|
||||||
COPY package.json ./
|
|
||||||
COPY bun.lock* ./
|
|
||||||
|
|
||||||
# Install dependencies including devDependencies
|
# Install dependencies including devDependencies
|
||||||
RUN bun install --production=false
|
RUN bun install --frozen-lockfile
|
||||||
|
|
||||||
# Build the application
|
# Build the application
|
||||||
FROM base AS builder
|
FROM oven/bun:latest AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy dependencies from deps stage
|
# Copy dependencies and config files
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
COPY --from=deps /app/package.json ./
|
||||||
|
COPY --from=deps /app/bunfig.toml ./
|
||||||
|
COPY --from=deps /app/next.config.js ./
|
||||||
|
|
||||||
|
# Copy source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
|
ENV SKIP_ENV_VALIDATION=1
|
||||||
|
ENV BETTER_AUTH_TELEMETRY=0
|
||||||
|
|
||||||
|
|
||||||
# Build Next.js application
|
# Build Next.js application
|
||||||
RUN bun run build
|
RUN bun run build
|
||||||
|
|
||||||
|
|
@ -29,25 +37,26 @@ WORKDIR /app
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
# Create a non-root user
|
|
||||||
RUN addgroup --system --gid 1001 nodejs
|
|
||||||
RUN adduser --system --uid 1001 nextjs
|
|
||||||
|
|
||||||
# Copy necessary files
|
# Copy Next.js build artifacts
|
||||||
COPY --from=builder /app/public ./public
|
|
||||||
COPY --from=builder /app/.next/standalone ./
|
COPY --from=builder /app/.next/standalone ./
|
||||||
COPY --from=builder /app/.next/static ./.next/static
|
COPY --from=builder /app/.next/static ./.next/static
|
||||||
|
COPY --from=builder /app/public ./public
|
||||||
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
|
COPY --from=builder /app/package.json ./
|
||||||
|
COPY --from=builder /app/src/env.js ./src/env.js
|
||||||
|
COPY --from=builder /app/next.config.js ./
|
||||||
|
COPY --from=builder /app/bunScripts ./bunScripts
|
||||||
|
|
||||||
# Set ownership to nextjs user
|
ENV TZ="CET"
|
||||||
RUN chown -R nextjs:nodejs /app
|
ENV LANG="de_DE.UTF-8"
|
||||||
|
ENV LANGUAGE="de_DE:de"
|
||||||
USER nextjs
|
ENV LC_ALL="de_DE.UTF-8"
|
||||||
|
ENV PORT=3000
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
ENV PORT=3000
|
|
||||||
ENV HOSTNAME="0.0.0.0"
|
|
||||||
|
|
||||||
# Start the application
|
# Start the application
|
||||||
CMD ["bun", "run", "start"]
|
CMD ["bun", "server.js"]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue