Files
Podcast-Generator/Dockerfile-Web
hex2077 61d7a7f427 fix: 添加web/.env文件到Docker镜像中
确保环境变量文件被正确包含在构建过程中,以便应用能够读取必要的配置
2025-08-26 21:51:18 +08:00

45 lines
1.2 KiB
Plaintext

# Stage 1: Dependency Installation and Build
FROM node:20-alpine AS builder
# Set working directory
WORKDIR /app/web
# Copy package.json and package-lock.json to leverage Docker cache
COPY web/package.json web/package-lock.json ./
# Install dependencies
RUN npm install --frozen-lockfile \
&& npm install --cpu=x64 --os=linux --libc=musl @libsql/client@latest --foreground-scripts
# Copy the rest of the application code (web directory content)
COPY web .
# Build the Next.js application
# The `standalone` output mode creates a self-contained application
ENV NEXT_TELEMETRY_DISABLED 1
RUN npm run build
# Stage 2: Production Image
FROM node:20-alpine AS runner
WORKDIR /app
# Create output directory for web/server.js to use
RUN mkdir -p server/output
RUN npm install @libsql/linux-x64-musl
# Set production environment
ENV NODE_ENV production
COPY web/.env ./web/.env
COPY web/sqlite.db ./web/sqlite.db
# Copy standalone application and public assets from the builder stage
COPY --from=builder /app/web/.next/standalone ./web/
COPY --from=builder /app/web/.next/static ./web/.next/static
COPY --from=builder /app/web/public ./web/public
# Expose port (Next.js default port)
EXPOSE 3000
# Start the Next.js application
CMD ["node", "web/server.js"]