From 81d08834460d8a52d4977284427bda8f0a75e7b0 Mon Sep 17 00:00:00 2001 From: Mads Boddum Date: Fri, 18 Aug 2023 21:07:48 +0200 Subject: [PATCH] build: moved jlink build inside the Docker image build, so building the Docker image works on any host OS Problem was that jlink produces OS-specific artifacts, so you couldn't make a functional Docker image on Windows. Final Docker image size has also been reduced, roughly from 240MB to 170MB, by using Alpine as the new base image. Support for Debian Stretch ended on the 30th of June 2022. --- .dockerignore | 6 ++++++ .github/workflows/deploy.yml | 6 ------ Dockerfile | 12 +++++++++--- 3 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..9a7556afd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +.gradle +build +log +mongo_data +pswgcommon/build diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 35cdd0991..5093a36be 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,12 +13,6 @@ jobs: - uses: actions/checkout@v1 with: submodules: true - - name: Set up JDK 18 - uses: actions/setup-java@v1 - with: - java-version: 18 - - name: Build - run: ./gradlew --no-daemon clean test jlink - name: Docker Login run: docker login docker.pkg.github.com -u "${{ secrets.DOCKER_USER }}" -p "${{ secrets.DOCKER_PASS }}" - name: Docker Build & Push diff --git a/Dockerfile b/Dockerfile index 5624a44a8..18c027f14 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,21 @@ -FROM debian:stretch-slim +FROM eclipse-temurin:18.0.2.1_1-jdk-alpine AS builder +WORKDIR /holocore +ADD . /holocore + +RUN ./gradlew --no-daemon jlink + +FROM alpine:3.18.3 AS runner # Adds necessary Holocore files RUN mkdir /holocore -ADD build/holocore/ /holocore +COPY --from=builder /holocore/build/holocore/ /holocore ADD serverdata/ /holocore/serverdata # Sets up networking EXPOSE 44463/tcp # Sets up timezone - default timezone can be overridden by setting TZ environment variable. -RUN apt-get install -y tzdata +RUN apk add --no-cache tzdata ENV TZ=UTC # Sets up execution