Fix(docker): optimize pnpm build and explicitly set image tag

- Update Dockerfile:
  - Add `package-import-method copy` to pnpm config to resolve EAGAIN errors during build.
  - Optimize pnpm network concurrency settings.
- Update docker-compose.yml:
  - Explicitly set `image: hotwa/bttoxin-app:latest` for services.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
zly
2026-01-21 00:40:34 +08:00
parent c75c85c53b
commit 452e15c806
2 changed files with 19 additions and 11 deletions

View File

@@ -30,6 +30,7 @@ services:
- frontend
bttoxin:
image: hotwa/bttoxin-app:latest
build:
context: .
dockerfile: docker/dockerfiles/Dockerfile.traefik
@@ -76,6 +77,7 @@ services:
- "traefik.http.middlewares.redirect-to-https.redirectscheme.permanent=true"
worker:
image: hotwa/bttoxin-app:latest
build:
context: .
dockerfile: docker/dockerfiles/Dockerfile.traefik

View File

@@ -28,32 +28,38 @@ RUN pixi shell-hook -e webbackend > /shell-hook.sh && \
# ===========================
# Stage 2: Frontend Builder
# ===========================
FROM docker.m.daocloud.io/library/node:20 AS frontend-builder
FROM node:20 AS frontend-builder
WORKDIR /app
ENV CI=true
# Copy only frontend source
# Optimization: Copy package files first to leverage Docker cache
COPY frontend/package.json frontend/pnpm-lock.yaml* ./
# Optimization: Limit concurrency to avoid EAGAIN errors
RUN npm install -g pnpm && \
pnpm config set registry https://registry.npmmirror.com && \
pnpm config set network-concurrency 1 && \
pnpm config set package-import-method copy && \
pnpm install --no-frozen-lockfile
# Copy remaining source code
COPY frontend/ .
RUN npm install -g pnpm && \
pnpm install --no-frozen-lockfile && \
pnpm build
RUN pnpm build
# ===========================
# Stage 3: Production (Runtime)
# ===========================
FROM docker.m.daocloud.io/library/ubuntu:20.04 AS production
FROM ghcr.io/prefix-dev/pixi:latest AS production
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
RUN apt-get clean && \
apt-get update -o Acquire::CompressionTypes::Order::=gz -o Acquire::http::No-Cache=True -o Acquire::http::Pipeline-Depth=0 && \
apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy pixi executable
COPY --from=builder /usr/local/bin/pixi /usr/local/bin/pixi
RUN chmod +x /usr/local/bin/pixi
# Copy entire prepared application directory (Code + Environment + Data)
COPY --from=builder /app /app