Add Docker configuration and .dockerignore for Serena application
This commit is contained in:
parent
1485183443
commit
dab720ef1b
4 changed files with 322 additions and 1 deletions
65
Dockerfile
65
Dockerfile
|
@ -0,0 +1,65 @@
|
|||
# Multi-stage Dockerfile for Serena (Backend + Frontend)
|
||||
|
||||
# Stage 1: Build Frontend
|
||||
FROM node:18-alpine AS frontend-builder
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
# Copy package files
|
||||
COPY frontend/package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy frontend source
|
||||
COPY frontend/ ./
|
||||
|
||||
# Build frontend
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Build Backend
|
||||
FROM openjdk:21-jdk-slim AS backend-builder
|
||||
|
||||
WORKDIR /app/backend
|
||||
|
||||
# Copy Gradle wrapper and build files
|
||||
COPY backend/gradlew ./
|
||||
COPY backend/gradle/ ./gradle/
|
||||
COPY backend/build.gradle ./
|
||||
COPY backend/settings.gradle ./
|
||||
|
||||
# Copy source code
|
||||
COPY backend/src/ ./src/
|
||||
|
||||
# Make gradlew executable and build
|
||||
RUN chmod +x gradlew
|
||||
RUN ./gradlew build --no-daemon -x test
|
||||
|
||||
# Stage 3: Runtime
|
||||
FROM openjdk:21-jre-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install curl for health checks
|
||||
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy built backend JAR
|
||||
COPY --from=backend-builder /app/backend/build/libs/*.jar app.jar
|
||||
|
||||
# Copy built frontend (will be served by Spring Boot)
|
||||
COPY --from=frontend-builder /app/frontend/build/ /app/static/
|
||||
|
||||
# Create non-root user
|
||||
RUN groupadd -r serena && useradd -r -g serena serena
|
||||
RUN chown -R serena:serena /app
|
||||
USER serena
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8080
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
||||
CMD curl -f http://localhost:8080/actuator/health || exit 1
|
||||
|
||||
# Run the application
|
||||
ENTRYPOINT ["java", "-jar", "app.jar"]
|
Loading…
Add table
Add a link
Reference in a new issue