-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (49 loc) · 2.34 KB
/
Dockerfile
File metadata and controls
64 lines (49 loc) · 2.34 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
# -----------------------------------------------------------------------------
# Build stage
# -----------------------------------------------------------------------------
FROM eclipse-temurin:21-jdk-ubi10-minimal AS build
# Install required build utilities
RUN microdnf update -y --refresh --best --nodocs --noplugins --setopt=install_weak_deps=0 \
&& microdnf install -y findutils which \
&& microdnf clean all
WORKDIR /app
# Copy Gradle configuration files first for better caching
COPY gradle/ /app/gradle/
COPY build.gradle settings.gradle gradlew gradlew.bat /app/
RUN chmod +x ./gradlew
# Copy source code
COPY src/ /app/src/
# Build the application with Gradle cache mount
RUN --mount=type=cache,target=/root/.gradle \
./gradlew clean bootJar --no-daemon --console=plain
# -----------------------------------------------------------------------------
# Runtime stage
# -----------------------------------------------------------------------------
FROM eclipse-temurin:21-jre-ubi10-minimal
# Update base image packages to patch security vulnerabilities
RUN microdnf update -y --refresh --best --nodocs --noplugins --setopt=install_weak_deps=0 \
&& microdnf remove -y binutils binutils-gold
# Set the location for the Python Virtual Environment
ENV VIRTUAL_ENV=/opt/venv/sharing-service
ENV PYTHON_INTERPRETER_PATH="${VIRTUAL_ENV}/bin/python3"
WORKDIR /app
# install uv for Python management
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/
# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1
# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy
# install Python and dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
uv venv --python 3.13 "${VIRTUAL_ENV}" && \
uv pip install nbformat
# Copy the built JAR from the build stage
ENV PYTHON_SCRIPT_PATH=/app/scripts/validate_notebook.py
COPY --from=build /app/build/libs/sharing-service-*.jar /app/sharing-service.jar
COPY --chmod=0755 src/main/java/org/jupytereverywhere/script/validate_notebook.py ${PYTHON_SCRIPT_PATH}
COPY --chmod=0755 entrypoint.sh /app/entrypoint.sh
EXPOSE 8080
# JVM memory configuration to prevent OutOfMemoryError with large notebooks
# Configure via environment variables (see entrypoint.sh for available settings)
# Defaults are optimized for 2GB App Runner instances processing notebooks up to 10MB
ENTRYPOINT ["/app/entrypoint.sh"]