-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (50 loc) · 2.19 KB
/
Dockerfile
File metadata and controls
69 lines (50 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# ============================================
# Dockerfile for GreenhouseAdmin (Kotlin Multiplatform - WASM)
# Multi-stage build for optimized production image
# ============================================
# Stage 1: Build the WASM application
FROM gradle:8.10-jdk21 AS builder
# Build argument for API URL (passed from CI/CD)
ARG API_BASE_URL
ENV API_BASE_URL=${API_BASE_URL}
# CRÍTICO: Instalar libatomic1 para Node.js v25+ (requerido por Kotlin/WASM)
# Ver: https://github.com/nodejs/node/issues/issues - Node.js v25 requiere libatomic
USER root
RUN apt-get update && apt-get install -y --no-install-recommends \
libatomic1 \
&& rm -rf /var/lib/apt/lists/*
USER gradle
WORKDIR /app
# Configurar memoria para JVM/Gradle
ENV GRADLE_OPTS="-Dorg.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m"
# Copy Gradle configuration files first (for better caching)
COPY --chown=gradle:gradle gradle/ gradle/
COPY --chown=gradle:gradle gradlew gradlew.bat settings.gradle.kts build.gradle.kts gradle.properties ./
# Copy the compose app module
COPY --chown=gradle:gradle composeApp/ composeApp/
# Make gradlew executable
RUN chmod +x gradlew
# Create local.properties with API_BASE_URL from build argument
RUN echo "API_BASE_URL=${API_BASE_URL}" > local.properties && \
echo "Created local.properties with API_BASE_URL"
# Upgrade Yarn lock files (required after dependency changes)
RUN ./gradlew kotlinUpgradeYarnLock kotlinWasmUpgradeYarnLock --no-daemon
# Build the WASM distribution
RUN ./gradlew :composeApp:wasmJsBrowserDistribution --no-daemon --stacktrace
# Stage 2: Serve with Nginx
FROM nginx:alpine
# Install required packages for WASM MIME types
RUN apk add --no-cache tzdata
# Copy custom nginx configuration
COPY nginx.conf /etc/nginx/nginx.conf
# Copy the built WASM application
COPY --from=builder /app/composeApp/build/dist/wasmJs/productionExecutable/ /usr/share/nginx/html/
# Create a simple health check endpoint
RUN echo "OK" > /usr/share/nginx/html/health
# Expose port 80
EXPOSE 80
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost/health || exit 1
# Start Nginx
CMD ["nginx", "-g", "daemon off;"]