skillhub/server/Dockerfile
wowo-zZ d631b0e20a fix(ops): resolve storage permission and audit log JSONB type issues
Fixes two critical issues when deploying with runtime.sh:

1. Storage Permission Error
   - Problem: AccessDeniedException when publishing skills
   - Root cause: /var/lib/skillhub/storage owned by root, but app runs as 'app' user
   - Solution: Pre-create storage directory with correct permissions in Dockerfile

2. Audit Log JSONB Type Error
   - Problem: PostgreSQL JSONB type mismatch when recording audit logs
   - Root cause: Missing type mapping annotation in AuditLog entity
   - Solution: Add @JdbcTypeCode(SqlTypes.JSON) annotation and V7 migration

Changes:
- server/Dockerfile: Add storage directory creation and permission setup
- server/skillhub-domain/.../AuditLog.java: Add @JdbcTypeCode annotation
- server/skillhub-app/.../V7__fix_audit_log_jsonb_type.sql: Migration for existing data

Impact:
- New deployments: Issues resolved automatically
- Existing deployments: Flyway auto-applies V7 migration on upgrade
2026-03-14 11:23:19 +08:00

37 lines
1,011 B
Docker

# ---- Build Stage ----
FROM eclipse-temurin:21-jdk-alpine AS build
WORKDIR /app
# Cache dependencies
COPY pom.xml .
COPY skillhub-domain/pom.xml skillhub-domain/
COPY skillhub-auth/pom.xml skillhub-auth/
COPY skillhub-search/pom.xml skillhub-search/
COPY skillhub-infra/pom.xml skillhub-infra/
COPY skillhub-storage/pom.xml skillhub-storage/
COPY skillhub-app/pom.xml skillhub-app/
COPY mvnw .
COPY .mvn .mvn
RUN ./mvnw dependency:go-offline -B
COPY . .
RUN ./mvnw package -DskipTests -B
# ---- Runtime Stage ----
FROM eclipse-temurin:21-jre-alpine
RUN addgroup -S app && adduser -S app -G app
WORKDIR /app
COPY --from=build /app/skillhub-app/target/*.jar app.jar
# Create storage directory and set permissions
RUN mkdir -p /var/lib/skillhub/storage && \
chown -R app:app /app /var/lib/skillhub/storage
USER app
EXPOSE 8080
HEALTHCHECK --interval=10s --timeout=3s \
CMD wget -qO- http://localhost:8080/actuator/health || exit 1
ENTRYPOINT ["java", "-XX:MaxRAMPercentage=75.0", "-jar", "app.jar"]