-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
78 lines (65 loc) · 3.08 KB
/
Copy pathDockerfile
File metadata and controls
78 lines (65 loc) · 3.08 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
70
71
72
73
74
75
76
77
78
# ISC Steam - production image (API + built client + Scala/Java build toolchain)
# ---- Stage 1: build the React client ----
FROM node:20-bookworm-slim AS client-build
WORKDIR /app
COPY package.json package-lock.json ./
COPY client/package.json client/
COPY server/package.json server/
RUN npm ci
COPY client client
RUN npm run build -w client
# ---- Stage 2: runtime ----
FROM node:20-bookworm-slim
ENV NODE_ENV=production
ARG SCALA_VERSION=2.13.14
# Linux JDK and Windows jmods MUST be the exact same version:
# jlink refuses to link a java.base jmod from a different JDK build.
ARG JDK_VERSION=21.0.5+11
ARG JAVAFX_VERSION=17.0.13
RUN apt-get update \
&& apt-get install -y --no-install-recommends git curl ca-certificates unzip \
&& rm -rf /var/lib/apt/lists/*
# Linux JDK (Temurin) - runs scalac, jlink, and the API's build pipeline
RUN JDK_ENC=$(echo "${JDK_VERSION}" | sed 's/+/%2B/') \
&& curl -fsSL "https://api.adoptium.net/v3/binary/version/jdk-${JDK_ENC}/linux/x64/jdk/hotspot/normal/eclipse" -o /tmp/jdk.tar.gz \
&& mkdir -p /opt/jdk \
&& tar -xzf /tmp/jdk.tar.gz -C /opt/jdk --strip-components=1 \
&& rm /tmp/jdk.tar.gz
# Windows JDK jmods (same version) - used by jlink to cross-build the Windows
# Java runtime bundled with each game package
RUN JDK_ENC=$(echo "${JDK_VERSION}" | sed 's/+/%2B/') \
&& curl -fsSL "https://api.adoptium.net/v3/binary/version/jdk-${JDK_ENC}/windows/x64/jdk/hotspot/normal/eclipse" -o /tmp/winjdk.zip \
&& unzip -q /tmp/winjdk.zip -d /tmp/winjdk \
&& mkdir -p /opt/windows-jdk \
&& mv /tmp/winjdk/*/jmods /opt/windows-jdk/jmods \
&& rm -rf /tmp/winjdk /tmp/winjdk.zip
# JavaFX Windows jmods - for games with "javafx": true in isc.json
RUN curl -fsSL "https://download2.gluonhq.com/openjfx/${JAVAFX_VERSION}/openjfx-${JAVAFX_VERSION}_windows-x64_bin-jmods.zip" -o /tmp/jfx.zip \
&& unzip -q /tmp/jfx.zip -d /tmp/jfx \
&& mv "/tmp/jfx/javafx-jmods-${JAVAFX_VERSION}" /opt/javafx-jmods \
&& rm -rf /tmp/jfx /tmp/jfx.zip
# JavaFX Linux jmods - for the Linux game package variant
RUN curl -fsSL "https://download2.gluonhq.com/openjfx/${JAVAFX_VERSION}/openjfx-${JAVAFX_VERSION}_linux-x64_bin-jmods.zip" -o /tmp/jfxl.zip \
&& unzip -q /tmp/jfxl.zip -d /tmp/jfxl \
&& mv "/tmp/jfxl/javafx-jmods-${JAVAFX_VERSION}" /opt/javafx-jmods-linux \
&& rm -rf /tmp/jfxl /tmp/jfxl.zip
# Scala (compiles student games)
RUN curl -fsSL "https://github.com/scala/scala/releases/download/v${SCALA_VERSION}/scala-${SCALA_VERSION}.tgz" \
| tar -xz -C /opt \
&& ln -s "/opt/scala-${SCALA_VERSION}" /opt/scala
ENV JAVA_HOME=/opt/jdk \
PATH="/opt/jdk/bin:/opt/scala/bin:${PATH}" \
SCALA_LIBRARY_JAR=/opt/scala/lib/scala-library.jar \
WINDOWS_JDK_JMODS=/opt/windows-jdk/jmods \
LINUX_JDK_JMODS=/opt/jdk/jmods \
JAVAFX_JMODS=/opt/javafx-jmods \
JAVAFX_JMODS_LINUX=/opt/javafx-jmods-linux \
JAVAFX_VERSION=${JAVAFX_VERSION}
WORKDIR /app
COPY package.json package-lock.json ./
COPY server/package.json server/
RUN npm ci --omit=dev -w server
COPY server server
COPY --from=client-build /app/client/dist client/dist
EXPOSE 5174
CMD ["node", "server/src/index.js"]