aboutsummaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2023-09-03 23:43:41 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2023-09-03 23:43:41 +0200
commit5337f46fbeacd8e188605eaf0af62b651c5f8517 (patch)
tree3f25c2cddf468bcb30f298daac83674101c4cae9 /docker
parentfeat(frontend): hide object scopes by default (diff)
downloadrefinery-5337f46fbeacd8e188605eaf0af62b651c5f8517.tar.gz
refinery-5337f46fbeacd8e188605eaf0af62b651c5f8517.tar.zst
refinery-5337f46fbeacd8e188605eaf0af62b651c5f8517.zip
build: add Dockerfile
Diffstat (limited to 'docker')
-rw-r--r--docker/Dockerfile46
-rwxr-xr-xdocker/build.sh38
2 files changed, 84 insertions, 0 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 00000000..ac164cb7
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,46 @@
1# SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/>
2#
3# SPDX-License-Identifier: EPL-2.0
4
5FROM docker.io/eclipse-temurin:17-jammy AS jlink
6# Disable HotSpot C1 compilation, because it causes spurious
7# NullPointerException instances to be thrown when running in
8# qemu-aarch64-static for image cross-building.
9ENV _JAVA_OPTIONS="-XX:CompilationMode=high-only"
10# We need to manually add jdk.zipfs to the list of modules output by jdeps to
11# enable serving static assets from the refinery-language-web-VERSION.jar,
12# because the dependency doesn't get picked up by static analysis.
13RUN jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules \
14 java.base,java.compiler,java.desktop,java.instrument,java.management,java.naming,java.rmi,java.security.jgss,java.sql,jdk.unsupported,jdk.zipfs \
15 --output /jlink
16
17FROM docker.io/debian:12-slim AS base
18# The first layer contains the slimmed down JRE.
19COPY --link --from=jlink /jlink /usr/lib/java
20ENV JAVA_HOME="/usr/lib/java" PATH="/usr/lib/java/bin:${PATH}"
21# Layer with platform-independent dependencies, slow changing.
22ADD --link lib /app/lib
23
24FROM base AS refinery-amd64
25# Layer with platform-dependent dependencies, slow changing.
26ADD --link lib_amd64 /app/lib
27# Layer with platform-dependent startup script containing references to all
28# dependency version.
29ADD --link app_amd64_bin /app/bin
30
31FROM base AS refinery-arm64
32# Layer with platform-dependent dependencies, slow changing.
33ADD --link lib_arm64 /app/lib
34# Layer with platform-dependent startup script containing references to all
35# dependency version.
36ADD --link app_arm64_bin /app/bin
37
38FROM refinery-$TARGETARCH
39# Layer with platform-independent application jars.
40ADD --link app_lib /app/lib
41# Common settings added on top.
42ENV LISTEN_ADDRESS=0.0.0.0 LISTEN_PORT=8888 PUBLIC_HOST=localhost PUBLIC_PORT=8888
43EXPOSE 8888
44USER 1000
45WORKDIR /app
46ENTRYPOINT /app/bin/refinery-language-web
diff --git a/docker/build.sh b/docker/build.sh
new file mode 100755
index 00000000..a8c2aeaa
--- /dev/null
+++ b/docker/build.sh
@@ -0,0 +1,38 @@
1#!/usr/bin/env bash
2
3# SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/>
4#
5# SPDX-License-Identifier: EPL-2.0
6
7set -euo pipefail
8
9refinery_version="$(grep '^version=' ../gradle.properties | cut -d'=' -f2)"
10distribution_name="refinery-language-web-${refinery_version}"
11rm -rf "${distribution_name}" dist app_lib app_{amd64,arm64}_bin lib lib_{amd64,arm64}
12
13tar -xf "../subprojects/language-web/build/distributions/${distribution_name}.tar"
14mv "${distribution_name}" dist
15mkdir -p app_lib app_{amd64,arm64}_bin lib lib_{amd64,arm64}
16
17# Move architecture-specific jars to their repsective directories.
18mv dist/lib/ortools-linux-x86-64-*.jar lib_amd64
19mv dist/lib/ortools-linux-aarch64-*.jar lib_arm64
20rm dist/lib/ortools-{darwin,win32}-*.jar
21# Move the applications jars for the dependencies into a separate Docker layer
22# to enable faster updates.
23mv dist/lib/refinery-* app_lib
24mv dist/lib/* lib
25# Omit references to jars not present for the current architecture from the
26# startup scripts.
27sed 's/:\$APP_HOME\/lib\/ortools-\(darwin\|win32\|linux-aarch64\)[^:]\+\.jar//g' dist/bin/refinery-language-web > app_amd64_bin/refinery-language-web
28sed 's/:\$APP_HOME\/lib\/ortools-\(darwin\|win32\|linux-x86-64\)[^:]\+\.jar//g' dist/bin/refinery-language-web > app_arm64_bin/refinery-language-web
29chmod a+x app_{amd64,arm64}_bin/refinery-language-web
30rm -rf dist
31
32docker buildx build . \
33 --platform linux/amd64,linux/arm64 \
34 --output "type=image,name=ghcr.io/graphs4value/refinery:${refinery_version},push=true,annotation-index.org.opencontainers.image.source=https://github.com/graphs4value/refinery,annotation-index.org.opencontainers.image.description=Refinery: an efficient graph solver for generating well-formed models,annotation-index.org.opencontainers.image.licenses=EPL-2.0" \
35 --label 'org.opencontainers.image.source=https://github.com/graphs4value/refinery' \
36 --label 'org.opencontainers.image.description=Refinery: an efficient graph solver for generating well-formed models' \
37 --label 'org.opencontainers.image.licenses=EPL-2.0' \
38 --push