更新dockerfile

This commit is contained in:
2026-03-24 22:53:03 +08:00
parent d09a0487ae
commit a2c835049f
7 changed files with 141 additions and 23 deletions

View File

@@ -15,7 +15,7 @@ RUN pnpm install --frozen-lockfile
# Copy frontend source
COPY web/ ./
# Build frontend
# Build frontend (SSR with adapter-node)
RUN pnpm build
# Stage 2: Build backend
@@ -29,14 +29,12 @@ RUN dart pub get
# Copy app source code and compile
COPY bin/ ./bin/
COPY --from=frontend-build /app/web/build ./web/build/
RUN dart compile exe bin/server.dart -o bin/server
# Stage 3: Runtime image with libvips
FROM debian:bookworm-slim AS runtime
# Stage 3: Runtime image with Node.js, libvips and Dart runtime
FROM node:22-bookworm-slim AS runtime
# Install libvips and ca-certificates
# Install libvips, ca-certificates and other dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libvips42 \
ca-certificates \
@@ -45,21 +43,32 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
WORKDIR /app
# Copy the AOT runtime and compiled server from build stage
# Copy Dart AOT runtime from build stage
COPY --from=backend-build /runtime/ /
COPY --from=backend-build /app/bin/server /app/bin/
COPY --from=backend-build /app/web/build /app/web/build
# Copy the compiled Dart server
COPY --from=backend-build /app/bin/server /app/bin/server
# Copy the built frontend (Node.js SSR app)
COPY --from=frontend-build /app/web/build /app/web/build
# Create data and cache directories
RUN mkdir -p /app/data /app/cache
# Copy startup script
COPY docker/entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Set environment variables (can be overridden at runtime)
ENV PORT=8080 \
HOST=0.0.0.0 \
DATA_DIR=/app/data \
CACHE_DIR=/app/cache
CACHE_DIR=/app/cache \
BACKEND_URL=http://127.0.0.1:8081 \
NODE_ENV=production
# Expose port
# Expose port (frontend serves on this port)
EXPOSE 8080
# Start server
CMD ["/app/bin/server"]
# Start both services using entrypoint script
ENTRYPOINT ["/app/entrypoint.sh"]