diff --git a/Dockerfile b/Dockerfile index 8eb6849..9a47435 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,33 @@ # Use bun as the base image -FROM oven/bun:1 AS base - +FROM oven/bun:latest AS deps # Install dependencies only when needed -FROM base AS deps WORKDIR /app -# Copy dependency files -COPY package.json ./ -COPY bun.lock* ./ +COPY package.json bunfig.toml next.config.ts ./ # Install dependencies including devDependencies -RUN bun install --production=false +RUN bun install --frozen-lockfile # Build the application -FROM base AS builder +FROM oven/bun:latest AS builder WORKDIR /app -# Copy dependencies from deps stage +# Copy dependencies and config files 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 . . + +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 +ENV SKIP_ENV_VALIDATION=1 +ENV BETTER_AUTH_TELEMETRY=0 + + # Build Next.js application RUN bun run build @@ -29,25 +37,26 @@ WORKDIR /app 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 --from=builder /app/public ./public +# Copy Next.js build artifacts COPY --from=builder /app/.next/standalone ./ 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 -RUN chown -R nextjs:nodejs /app - -USER nextjs +ENV TZ="CET" +ENV LANG="de_DE.UTF-8" +ENV LANGUAGE="de_DE:de" +ENV LC_ALL="de_DE.UTF-8" +ENV PORT=3000 EXPOSE 3000 -ENV PORT=3000 -ENV HOSTNAME="0.0.0.0" # Start the application -CMD ["bun", "run", "start"] +CMD ["bun", "server.js"]