mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2024-11-25 07:42:58 +01:00
Compare commits
2 Commits
d2e7fcd823
...
8911a2257a
Author | SHA1 | Date | |
---|---|---|---|
8911a2257a | |||
a1dec2f117 |
@ -81,7 +81,7 @@ sealed record LaunchInstanceProcedure(InstanceConfiguration Configuration, IServ
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.SetStatus(InstanceStatus.Running);
|
context.SetStatus(InstanceStatus.Running);
|
||||||
context.ReportEvent(InstanceEvent.LaunchSucceded);
|
context.ReportEvent(InstanceEvent.LaunchSucceeded);
|
||||||
return launchSuccess.Process;
|
return launchSuccess.Process;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Phantom.Common.Data.Web.EventLog;
|
namespace Phantom.Common.Data.Web.EventLog;
|
||||||
|
|
||||||
public enum EventLogEventType {
|
public enum EventLogEventType {
|
||||||
InstanceLaunchSucceded,
|
InstanceLaunchSucceeded,
|
||||||
InstanceLaunchFailed,
|
InstanceLaunchFailed,
|
||||||
InstanceCrashed,
|
InstanceCrashed,
|
||||||
InstanceStopped,
|
InstanceStopped,
|
||||||
@ -12,7 +12,7 @@ public enum EventLogEventType {
|
|||||||
|
|
||||||
public static class EventLogEventTypeExtensions {
|
public static class EventLogEventTypeExtensions {
|
||||||
private static readonly Dictionary<EventLogEventType, EventLogSubjectType> SubjectTypes = new () {
|
private static readonly Dictionary<EventLogEventType, EventLogSubjectType> SubjectTypes = new () {
|
||||||
{ EventLogEventType.InstanceLaunchSucceded, EventLogSubjectType.Instance },
|
{ EventLogEventType.InstanceLaunchSucceeded, EventLogSubjectType.Instance },
|
||||||
{ EventLogEventType.InstanceLaunchFailed, EventLogSubjectType.Instance },
|
{ EventLogEventType.InstanceLaunchFailed, EventLogSubjectType.Instance },
|
||||||
{ EventLogEventType.InstanceCrashed, EventLogSubjectType.Instance },
|
{ EventLogEventType.InstanceCrashed, EventLogSubjectType.Instance },
|
||||||
{ EventLogEventType.InstanceStopped, EventLogSubjectType.Instance },
|
{ EventLogEventType.InstanceStopped, EventLogSubjectType.Instance },
|
||||||
|
@ -4,7 +4,7 @@ using Phantom.Common.Data.Backups;
|
|||||||
namespace Phantom.Common.Data.Instance;
|
namespace Phantom.Common.Data.Instance;
|
||||||
|
|
||||||
[MemoryPackable]
|
[MemoryPackable]
|
||||||
[MemoryPackUnion(0, typeof(InstanceLaunchSuccededEvent))]
|
[MemoryPackUnion(0, typeof(InstanceLaunchSucceededEvent))]
|
||||||
[MemoryPackUnion(1, typeof(InstanceLaunchFailedEvent))]
|
[MemoryPackUnion(1, typeof(InstanceLaunchFailedEvent))]
|
||||||
[MemoryPackUnion(2, typeof(InstanceCrashedEvent))]
|
[MemoryPackUnion(2, typeof(InstanceCrashedEvent))]
|
||||||
[MemoryPackUnion(3, typeof(InstanceStoppedEvent))]
|
[MemoryPackUnion(3, typeof(InstanceStoppedEvent))]
|
||||||
@ -14,7 +14,7 @@ public partial interface IInstanceEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MemoryPackable(GenerateType.VersionTolerant)]
|
[MemoryPackable(GenerateType.VersionTolerant)]
|
||||||
public sealed partial record InstanceLaunchSuccededEvent : IInstanceEvent {
|
public sealed partial record InstanceLaunchSucceededEvent : IInstanceEvent {
|
||||||
public void Accept(IInstanceEventVisitor visitor) {
|
public void Accept(IInstanceEventVisitor visitor) {
|
||||||
visitor.OnLaunchSucceeded(this);
|
visitor.OnLaunchSucceeded(this);
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ public sealed partial record InstanceBackupCompletedEvent([property: MemoryPackO
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class InstanceEvent {
|
public static class InstanceEvent {
|
||||||
public static readonly IInstanceEvent LaunchSucceded = new InstanceLaunchSuccededEvent();
|
public static readonly IInstanceEvent LaunchSucceeded = new InstanceLaunchSucceededEvent();
|
||||||
public static readonly IInstanceEvent Crashed = new InstanceCrashedEvent();
|
public static readonly IInstanceEvent Crashed = new InstanceCrashedEvent();
|
||||||
public static readonly IInstanceEvent Stopped = new InstanceStoppedEvent();
|
public static readonly IInstanceEvent Stopped = new InstanceStoppedEvent();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Phantom.Common.Data.Instance;
|
namespace Phantom.Common.Data.Instance;
|
||||||
|
|
||||||
public interface IInstanceEventVisitor {
|
public interface IInstanceEventVisitor {
|
||||||
void OnLaunchSucceeded(InstanceLaunchSuccededEvent e);
|
void OnLaunchSucceeded(InstanceLaunchSucceededEvent e);
|
||||||
void OnLaunchFailed(InstanceLaunchFailedEvent e);
|
void OnLaunchFailed(InstanceLaunchFailedEvent e);
|
||||||
void OnCrashed(InstanceCrashedEvent e);
|
void OnCrashed(InstanceCrashedEvent e);
|
||||||
void OnStopped(InstanceStoppedEvent e);
|
void OnStopped(InstanceStoppedEvent e);
|
||||||
|
@ -24,8 +24,8 @@ sealed partial class EventLogManager {
|
|||||||
this.instanceGuid = instanceGuid;
|
this.instanceGuid = instanceGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnLaunchSucceeded(InstanceLaunchSuccededEvent e) {
|
public void OnLaunchSucceeded(InstanceLaunchSucceededEvent e) {
|
||||||
eventLogManager.EnqueueItem(eventGuid, utcTime, agentGuid, EventLogEventType.InstanceLaunchSucceded, instanceGuid.ToString());
|
eventLogManager.EnqueueItem(eventGuid, utcTime, agentGuid, EventLogEventType.InstanceLaunchSucceeded, instanceGuid.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnLaunchFailed(InstanceLaunchFailedEvent e) {
|
public void OnLaunchFailed(InstanceLaunchFailedEvent e) {
|
||||||
|
96
Dockerfile
96
Dockerfile
@ -1,63 +1,27 @@
|
|||||||
# +---------------------------+
|
# +---------------+
|
||||||
# | Prepare build environment |
|
# | Prepare build |
|
||||||
# +---------------------------+
|
# +---------------+
|
||||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/nightly/sdk:8.0-preview AS phantom-base-builder
|
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/nightly/sdk:8.0 AS phantom-builder
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
|
|
||||||
ADD . /app
|
ADD . /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN dotnet publish PhantomPanel.sln \
|
||||||
|
/p:DebugType=None \
|
||||||
|
/p:DebugSymbols=false \
|
||||||
|
--arch "$TARGETARCH" \
|
||||||
|
--configuration Release
|
||||||
|
|
||||||
|
RUN find .artifacts/publish/*/* -maxdepth 0 -execdir mv '{}' 'release' \;
|
||||||
|
|
||||||
|
|
||||||
|
# +---------------------+
|
||||||
|
# | Phantom Agent image |
|
||||||
|
# +---------------------+
|
||||||
|
FROM mcr.microsoft.com/dotnet/nightly/runtime:8.0 AS phantom-agent
|
||||||
|
|
||||||
RUN mkdir /data && chmod 777 /data
|
RUN mkdir /data && chmod 777 /data
|
||||||
RUN dotnet restore --arch "$TARGETARCH"
|
|
||||||
|
|
||||||
|
|
||||||
# +---------------------+
|
|
||||||
# | Build Phantom Agent |
|
|
||||||
# +---------------------+
|
|
||||||
FROM phantom-base-builder AS phantom-agent-builder
|
|
||||||
|
|
||||||
RUN dotnet publish Agent/Phantom.Agent/Phantom.Agent.csproj \
|
|
||||||
/p:DebugType=None \
|
|
||||||
/p:DebugSymbols=false \
|
|
||||||
--no-restore \
|
|
||||||
--arch "$TARGETARCH" \
|
|
||||||
--configuration Release \
|
|
||||||
--output /app/out
|
|
||||||
|
|
||||||
|
|
||||||
# +--------------------------+
|
|
||||||
# | Build Phantom Controller |
|
|
||||||
# +--------------------------+
|
|
||||||
FROM phantom-base-builder AS phantom-controller-builder
|
|
||||||
|
|
||||||
RUN dotnet publish Controller/Phantom.Controller/Phantom.Controller.csproj \
|
|
||||||
/p:DebugType=None \
|
|
||||||
/p:DebugSymbols=false \
|
|
||||||
--no-restore \
|
|
||||||
--arch "$TARGETARCH" \
|
|
||||||
--configuration Release \
|
|
||||||
--output /app/out
|
|
||||||
|
|
||||||
|
|
||||||
# +-------------------+
|
|
||||||
# | Build Phantom Web |
|
|
||||||
# +-------------------+
|
|
||||||
FROM phantom-base-builder AS phantom-controller-builder
|
|
||||||
|
|
||||||
RUN dotnet publish Web/Phantom.Web/Phantom.Web.csproj \
|
|
||||||
/p:DebugType=None \
|
|
||||||
/p:DebugSymbols=false \
|
|
||||||
--no-restore \
|
|
||||||
--arch "$TARGETARCH" \
|
|
||||||
--configuration Release \
|
|
||||||
--output /app/out
|
|
||||||
|
|
||||||
|
|
||||||
# +------------------------------+
|
|
||||||
# | Finalize Phantom Agent image |
|
|
||||||
# +------------------------------+
|
|
||||||
FROM mcr.microsoft.com/dotnet/nightly/runtime:8.0-preview AS phantom-agent
|
|
||||||
|
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
|
|
||||||
COPY --from=eclipse-temurin:8-jre /opt/java/openjdk /opt/java/8
|
COPY --from=eclipse-temurin:8-jre /opt/java/openjdk /opt/java/8
|
||||||
@ -74,30 +38,32 @@ RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \
|
|||||||
apt-get install -y \
|
apt-get install -y \
|
||||||
zstd
|
zstd
|
||||||
|
|
||||||
COPY --from=phantom-agent-builder --chmod=755 /app/out /app
|
COPY --from=phantom-builder --chmod=755 /app/.artifacts/publish/Phantom.Agent/release /app
|
||||||
|
|
||||||
ENTRYPOINT ["dotnet", "/app/Phantom.Agent.dll"]
|
ENTRYPOINT ["dotnet", "/app/Phantom.Agent.dll"]
|
||||||
|
|
||||||
|
|
||||||
# +-----------------------------------+
|
# +--------------------------+
|
||||||
# | Finalize Phantom Controller image |
|
# | Phantom Controller image |
|
||||||
# +-----------------------------------+
|
# +--------------------------+
|
||||||
FROM mcr.microsoft.com/dotnet/nightly/runtime:8.0-preview AS phantom-controller
|
FROM mcr.microsoft.com/dotnet/nightly/runtime:8.0 AS phantom-controller
|
||||||
|
|
||||||
|
RUN mkdir /data && chmod 777 /data
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
|
|
||||||
COPY --from=phantom-controller-builder --chmod=755 /app/out /app
|
COPY --from=phantom-builder --chmod=755 /app/.artifacts/publish/Phantom.Controller/release /app
|
||||||
|
|
||||||
ENTRYPOINT ["dotnet", "/app/Phantom.Controller.dll"]
|
ENTRYPOINT ["dotnet", "/app/Phantom.Controller.dll"]
|
||||||
|
|
||||||
|
|
||||||
# +----------------------------+
|
# +-------------------+
|
||||||
# | Finalize Phantom Web image |
|
# | Phantom Web image |
|
||||||
# +----------------------------+
|
# +-------------------+
|
||||||
FROM mcr.microsoft.com/dotnet/nightly/aspnet:8.0-preview AS phantom-web
|
FROM mcr.microsoft.com/dotnet/nightly/aspnet:8.0 AS phantom-web
|
||||||
|
|
||||||
|
RUN mkdir /data && chmod 777 /data
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
|
|
||||||
COPY --from=phantom-web-builder --chmod=755 /app/out /app
|
COPY --from=phantom-builder --chmod=755 /app/.artifacts/publish/Phantom.Web/release /app
|
||||||
|
|
||||||
ENTRYPOINT ["dotnet", "/app/Phantom.Web.dll"]
|
ENTRYPOINT ["dotnet", "/app/Phantom.Web.dll"]
|
||||||
|
Loading…
Reference in New Issue
Block a user