Skip to content

Instantly share code, notes, and snippets.

@varpa89
Last active February 6, 2018 14:01
Show Gist options
  • Save varpa89/f6844af6f9401fa2548618816877a15b to your computer and use it in GitHub Desktop.
Save varpa89/f6844af6f9401fa2548618816877a15b to your computer and use it in GitHub Desktop.
Dockerfile for Fn Project java runtime
FROM arm32v7/openjdk:9-slim
COPY target/runtime-*.jar target/dependency/*.jar /function/runtime/
# UseCGroupMemoryLimitForHeap looks up /sys/fs/cgroup/memory/memory.limit_in_bytes inside the container to determine
# what the heap should be set to. This is an experimental feature at the moment, thus we need to unlock to use it.
#
# MaxRAMFraction is used modify the heap size and it is used as a denominator where the numerator is phys_mem.
# It seems that this value is a uint in the JVM code, thus can only specify 1 => 100%, 2 => 50%, 3 => 33.3%, 4 => 25%
# and so on.
#
# SerialGC is used here as it's likely that we'll be running many JVMs on the same host machine and it's also likely
# that the number of JVMs will outnumber the number of available processors.
#
# The max memory value obtained with these args seem to be okay for most memory limits. The exception is when the
# memory limit is set to 128MiB, in which case maxMemory returns roughly half.
ENTRYPOINT [ "/usr/bin/java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-XX:MaxRAMFraction=2", "-XX:+UseSerialGC", "-Xshare:off", "-cp", "/function/app/*:/function/runtime/*", "com.fnproject.fn.runtime.EntryPoint" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment