fix(admin-service): 修复uploads目录权限问题

This commit is contained in:
hailin 2026-01-09 02:14:37 -08:00
parent d1a52e74a0
commit d79fd9273b
1 changed files with 9 additions and 2 deletions

View File

@ -43,8 +43,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create app directory with correct ownership
RUN mkdir -p /app && chown nestjs:nodejs /app
# Create app directory and uploads directory with correct ownership
RUN mkdir -p /app /app/uploads && chown -R nestjs:nodejs /app
WORKDIR /app
# Switch to non-root user before installing dependencies
@ -61,6 +61,13 @@ RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate
# Copy built files
COPY --chown=nestjs:nodejs --from=builder /app/dist ./dist
# Create uploads directory with correct ownership (before volume mount)
# This ensures the directory exists and has correct ownership
# Note: When a named volume is mounted, if it's empty, Docker will copy the container's directory content to it
USER root
RUN mkdir -p /app/uploads && chown -R nestjs:nodejs /app/uploads
USER nestjs
# Create startup script that runs migrations before starting the app
RUN printf '%s\n' \
'#!/bin/sh' \