forked from Raphael/SCHALE.GameServer
dockersss
This commit is contained in:
parent
de541051da
commit
7e022835ad
|
@ -0,0 +1,32 @@
|
||||||
|
# Include any files or directories that you don't want to be copied to your
|
||||||
|
# container here (e.g., local build artifacts, temporary files, etc.).
|
||||||
|
#
|
||||||
|
# For more help, visit the .dockerignore file reference guide at
|
||||||
|
# https://docs.docker.com/go/build-context-dockerignore/
|
||||||
|
|
||||||
|
**/.DS_Store
|
||||||
|
**/.classpath
|
||||||
|
**/.dockerignore
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
**/.project
|
||||||
|
**/.settings
|
||||||
|
**/.toolstarget
|
||||||
|
**/.vs
|
||||||
|
**/.vscode
|
||||||
|
**/*.*proj.user
|
||||||
|
**/*.dbmdl
|
||||||
|
**/*.jfm
|
||||||
|
**/bin
|
||||||
|
**/charts
|
||||||
|
**/docker-compose*
|
||||||
|
**/compose.y*ml
|
||||||
|
**/Dockerfile*
|
||||||
|
**/node_modules
|
||||||
|
**/npm-debug.log
|
||||||
|
**/obj
|
||||||
|
**/secrets.dev.yaml
|
||||||
|
**/values.dev.yaml
|
||||||
|
LICENSE
|
||||||
|
README.md
|
|
@ -0,0 +1,68 @@
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
# Comments are provided throughout this file to help you get started.
|
||||||
|
# If you need more help, visit the Dockerfile reference guide at
|
||||||
|
# https://docs.docker.com/go/dockerfile-reference/
|
||||||
|
|
||||||
|
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Learn about building .NET container images:
|
||||||
|
# https://github.com/dotnet/dotnet-docker/blob/main/samples/README.md
|
||||||
|
|
||||||
|
# Create a stage for building the application.
|
||||||
|
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
|
||||||
|
|
||||||
|
COPY . /source
|
||||||
|
|
||||||
|
WORKDIR /source/SCHALE.GameServer
|
||||||
|
|
||||||
|
# This is the architecture you’re building for, which is passed in by the builder.
|
||||||
|
# Placing it here allows the previous steps to be cached across architectures.
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
|
# Build the application.
|
||||||
|
# Leverage a cache mount to /root/.nuget/packages so that subsequent builds don't have to re-download packages.
|
||||||
|
# If TARGETARCH is "amd64", replace it with "x64" - "x64" is .NET's canonical name for this and "amd64" doesn't
|
||||||
|
# work in .NET 6.0.
|
||||||
|
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
|
||||||
|
dotnet publish -a ${TARGETARCH/amd64/x64} --use-current-runtime --self-contained false -p:DefineConstants=DOCKER_BUILD -p:InvariantGlobalization=false -o /app
|
||||||
|
|
||||||
|
# If you need to enable globalization and time zones:
|
||||||
|
# https://github.com/dotnet/dotnet-docker/blob/main/samples/enable-globalization.md
|
||||||
|
################################################################################
|
||||||
|
# Create a new stage for running the application that contains the minimal
|
||||||
|
# runtime dependencies for the application. This often uses a different base
|
||||||
|
# image from the build stage where the necessary files are copied from the build
|
||||||
|
# stage.
|
||||||
|
#
|
||||||
|
# The example below uses an aspnet alpine image as the foundation for running the app.
|
||||||
|
# It will also use whatever happens to be the most recent version of that tag when you
|
||||||
|
# build your Dockerfile. If reproducability is important, consider using a more specific
|
||||||
|
# version (e.g., aspnet:7.0.10-alpine-3.18),
|
||||||
|
# or SHA (e.g., mcr.microsoft.com/dotnet/aspnet@sha256:f3d99f54d504a21d38e4cc2f13ff47d67235efeeb85c109d3d1ff1808b38d034).
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS final
|
||||||
|
|
||||||
|
ENV \
|
||||||
|
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
|
||||||
|
LC_ALL=en_US.UTF-8 \
|
||||||
|
LANG=en_US.UTF-8
|
||||||
|
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
curl \
|
||||||
|
krb5-libs \
|
||||||
|
icu-data-full \
|
||||||
|
icu-libs
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy everything needed to run the app from the "build" stage.
|
||||||
|
COPY --from=build /app .
|
||||||
|
|
||||||
|
# Switch to a non-privileged user (defined in the base image) that the app will run under.
|
||||||
|
# See https://docs.docker.com/go/dockerfile-user-best-practices/
|
||||||
|
# and https://github.com/dotnet/dotnet-docker/discussions/4764
|
||||||
|
USER $APP_UID
|
||||||
|
|
||||||
|
ENTRYPOINT ["dotnet", "SCHALE.GameServer.dll"]
|
|
@ -6,7 +6,6 @@ using System.IO.Compression;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using Serilog;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace SCHALE.GameServer.Controllers.Api
|
namespace SCHALE.GameServer.Controllers.Api
|
||||||
|
@ -14,13 +13,13 @@ namespace SCHALE.GameServer.Controllers.Api
|
||||||
[Route("/api/[controller]")]
|
[Route("/api/[controller]")]
|
||||||
public class GatewayController : ControllerBase
|
public class GatewayController : ControllerBase
|
||||||
{
|
{
|
||||||
static JsonSerializerOptions jsonOptions = new() // ignore null or fields not set, if this breaks anything, remove it, idk if it does but it makes the pcap logs look more readable
|
private readonly static JsonSerializerOptions jsonOptions = new() // ignore null or fields not set, if this breaks anything, remove it, idk if it does but it makes the pcap logs look more readable
|
||||||
{
|
{
|
||||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault,
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault,
|
||||||
};
|
};
|
||||||
|
|
||||||
IProtocolHandlerFactory protocolHandlerFactory;
|
private readonly IProtocolHandlerFactory protocolHandlerFactory;
|
||||||
ILogger<GatewayController> logger;
|
private readonly ILogger<GatewayController> logger;
|
||||||
|
|
||||||
public GatewayController(IProtocolHandlerFactory _protocolHandlerFactory, ILogger<GatewayController> _logger)
|
public GatewayController(IProtocolHandlerFactory _protocolHandlerFactory, ILogger<GatewayController> _logger)
|
||||||
{
|
{
|
||||||
|
@ -96,7 +95,7 @@ namespace SCHALE.GameServer.Controllers.Api
|
||||||
protocolErrorRet:
|
protocolErrorRet:
|
||||||
return Results.Json(new
|
return Results.Json(new
|
||||||
{
|
{
|
||||||
packet = JsonSerializer.Serialize(new ErrorPacket() { Reason = "Protocol not implemented (Server Error)", ErrorCode = WebAPIErrorCode.InternalServerError }, jsonOptions),
|
packet = JsonSerializer.Serialize(new ErrorPacket() { Reason = "Protocol not implemented (Server Error)", ErrorCode = WebAPIErrorCode.ServerFailedToHandleRequest }, jsonOptions),
|
||||||
protocol = Protocol.Error.ToString()
|
protocol = Protocol.Error.ToString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ namespace SCHALE.GameServer
|
||||||
var config = new ConfigurationBuilder()
|
var config = new ConfigurationBuilder()
|
||||||
.SetBasePath(Path.GetDirectoryName(AppContext.BaseDirectory)!)
|
.SetBasePath(Path.GetDirectoryName(AppContext.BaseDirectory)!)
|
||||||
.AddJsonFile("appsettings.json")
|
.AddJsonFile("appsettings.json")
|
||||||
.AddJsonFile("appsettings.Local.json", true)
|
|
||||||
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", true)
|
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production"}.json", true)
|
||||||
|
.AddJsonFile("appsettings.Local.json", true)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"SQLServer": "data source=db;User=sa;Password=5CH41364M353rV3r;initial catalog=schale;trusted_connection=false;TrustServerCertificate=True"
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,9 +3,6 @@
|
||||||
"EndPoints": {
|
"EndPoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://0.0.0.0:80"
|
"Url": "http://0.0.0.0:80"
|
||||||
},
|
|
||||||
"Https": {
|
|
||||||
"Url": "https://0.0.0.0:443"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
# Comments are provided throughout this file to help you get started.
|
||||||
|
# If you need more help, visit the Docker Compose reference guide at
|
||||||
|
# https://docs.docker.com/go/compose-spec-reference/
|
||||||
|
|
||||||
|
# Here the instructions define your application as a service called "server".
|
||||||
|
# This service is built from the Dockerfile in the current directory.
|
||||||
|
# You can add other services your application may depend on here, such as a
|
||||||
|
# database or a cache. For examples, see the Awesome Compose repository:
|
||||||
|
# https://github.com/docker/awesome-compose
|
||||||
|
services:
|
||||||
|
server:
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Docker
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
target: final
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: mcr.microsoft.com/mssql/server
|
||||||
|
environment:
|
||||||
|
SA_PASSWORD: "5CH41364M353rV3r"
|
||||||
|
ACCEPT_EULA: "Y"
|
||||||
|
restart: always
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 5CH41364M353rV3r -Q 'SELECT 1' || exit 1"]
|
||||||
|
interval: 20s
|
||||||
|
retries: 10
|
||||||
|
start_period: 20s
|
||||||
|
timeout: 3s
|
||||||
|
|
||||||
|
# The commented out section below is an example of how to define a PostgreSQL
|
||||||
|
# database that your application can use. `depends_on` tells Docker Compose to
|
||||||
|
# start the database before your application. The `db-data` volume persists the
|
||||||
|
# database data between container restarts. The `db-password` secret is used
|
||||||
|
# to set the database password. You must create `db/password.txt` and add
|
||||||
|
# a password of your choosing to it before running `docker compose up`.
|
||||||
|
# depends_on:
|
||||||
|
# db:
|
||||||
|
# condition: service_healthy
|
||||||
|
# db:
|
||||||
|
# image: postgres
|
||||||
|
# restart: always
|
||||||
|
# user: postgres
|
||||||
|
# secrets:
|
||||||
|
# - db-password
|
||||||
|
# volumes:
|
||||||
|
# - db-data:/var/lib/postgresql/data
|
||||||
|
# environment:
|
||||||
|
# - POSTGRES_DB=example
|
||||||
|
# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
|
||||||
|
# expose:
|
||||||
|
# - 5432
|
||||||
|
# healthcheck:
|
||||||
|
# test: [ "CMD", "pg_isready" ]
|
||||||
|
# interval: 10s
|
||||||
|
# timeout: 5s
|
||||||
|
# retries: 5
|
||||||
|
# volumes:
|
||||||
|
# db-data:
|
||||||
|
# secrets:
|
||||||
|
# db-password:
|
||||||
|
# file: db/password.txt
|
||||||
|
|
Loading…
Reference in New Issue