-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
34 lines (27 loc) · 1.29 KB
/
Dockerfile
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
# Required build contexts:
# - the default build context should be in the root of the Games project.
# - the `server` build context should point to the root of the Server project.
# Use the following command from the root of the project to build the image:
# docker build --build-context=server=../Server .
# Build the server and publish it to the local maven repository
FROM docker.io/library/gradle:8.6-jdk21 as build-server
COPY --from=server . /work
WORKDIR /work
RUN --mount=type=cache,target=/home/gradle/.gradle \
/usr/bin/gradle --console=plain --info --stacktrace --no-daemon publishToMavenLocal
# Build the lobby and the specified game
FROM docker.io/library/gradle:8.6-jdk21 as build-games
ARG GAME
# Receive the built server from the previous step
COPY --from=build-server /root/.m2/repository/com/bluedragonmc /root/.m2/repository/com/bluedragonmc
COPY . /work
WORKDIR /work
RUN --mount=type=cache,target=/home/gradle/.gradle \
/usr/bin/gradle --console=plain --info --stacktrace --no-daemon build
FROM docker.io/library/eclipse-temurin:21-jdk
ARG GAME
# Copy the final artifacts from both steps
COPY --from=build-server /work/build/libs/*-all.jar /server/server.jar
COPY --from=build-games /work/build/all-jars/*.jar /server/games/
WORKDIR /server
ENTRYPOINT ["java", "-jar", "server.jar"]