1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2025-04-12 08:15:45 +02:00

Add Dockerfile for building Agent and Server

This commit is contained in:
chylex 2022-10-20 03:21:49 +02:00
parent bcb53528b9
commit 663aa8fded
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548
2 changed files with 87 additions and 0 deletions

9
.dockerignore Normal file
View File

@ -0,0 +1,9 @@
# Ignore hidden files
.*
# Include .git for build version information
!.git
# Not needed for building
AddMigration.*
*.DotSettings.user

78
Dockerfile Normal file
View File

@ -0,0 +1,78 @@
# +---------------------------+
# | Prepare build environment |
# +---------------------------+
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS phantom-base-builder
ADD . /app
WORKDIR /app
RUN dotnet restore
# +---------------------+
# | Build Phantom Agent |
# +---------------------+
FROM phantom-base-builder AS phantom-agent-builder
RUN dotnet publish Agent/Phantom.Agent/Phantom.Agent.csproj -c Release -o /app/out
# +----------------------+
# | Build Phantom Server |
# +----------------------+
FROM phantom-base-builder AS phantom-server-builder
RUN dotnet publish Server/Phantom.Server.Web/Phantom.Server.Web.csproj -c Release -o /app/out
RUN dotnet publish Server/Phantom.Server/Phantom.Server.csproj -c Release -o /app/out
# +------------------------------+
# | Download older Java versions |
# +------------------------------+
FROM ubuntu:focal AS java-legacy
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y \
openjdk-8-jre-headless \
openjdk-16-jre-headless \
openjdk-17-jre-headless
# +------------------------------+
# | Finalize Phantom Agent image |
# +------------------------------+
FROM mcr.microsoft.com/dotnet/runtime:7.0-jammy AS phantom-agent
COPY --from=java-legacy /usr/lib/jvm/java-8-openjdk-amd64 /usr/lib/jvm/java-8-openjdk-amd64
COPY --from=java-legacy /usr/lib/jvm/java-16-openjdk-amd64 /usr/lib/jvm/java-16-openjdk-amd64
COPY --from=java-legacy /usr/lib/jvm/java-17-openjdk-amd64 /usr/lib/jvm/java-17-openjdk-amd64
COPY --from=phantom-agent-builder --chmod=755 /app/out /app
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y \
openjdk-18-jre-headless
RUN mkdir /data
RUN chmod 777 /data
WORKDIR /data
ENTRYPOINT ["dotnet", "/app/Phantom.Agent.dll"]
# +-------------------------------+
# | Finalize Phantom Server image |
# +-------------------------------+
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS phantom-server
COPY --from=phantom-server-builder --chmod=755 /app/out /app
RUN mkdir /data
RUN chmod 777 /data
WORKDIR /data
ENTRYPOINT ["dotnet", "/app/Phantom.Server.dll"]