diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 68b6832..4d81b9d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,3 +29,4 @@ Please do not use issue identifiers as scopes. - `tooling`: changes to development tooling like dotnet tools - `deps`: changes to dependencies, such as updating dependencies or removing unused dependencies - `renovate`: changes to the Renovate configuration +- `docker`: changes to the Dockerfile or docker-compose files diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7d37ece --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER $APP_UID +WORKDIR /app +EXPOSE 8080 +EXPOSE 8081 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["ZenithInfo.csproj", "./"] +RUN dotnet restore "ZenithInfo.csproj" +COPY . . +WORKDIR "/src/" +RUN dotnet build "ZenithInfo.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "ZenithInfo.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "ZenithInfo.dll"] diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..305883b --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,13 @@ +services: + zenithinfo-dev: + container_name: zenithinfo + extends: + service: zenithinfo + file: ./docker-compose.yml + build: + context: . + environment: + CONFIGURATION__AUTHTOKEN: 'hi' + CONFIGURATION__DATABASETYPE: 'Memory' + LOGGING__LOGLEVEL_DEFAULT: 'Trace' + CONFIGURATION__USESENTRY: false diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3ab6b62 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,57 @@ +services: + zenithinfo: + image: www.coastalcommits.com/zenith/zenithinfo:latest + ports: + - 8000:8000 + environment: + # All of the environment variables present here use double underscores (__), NOT single underscores (_). + # The only exception is the `ASPNETCORE_URLS` environment variable, which uses single underscores. + + # This is used to push data into Zenith Info from the game. + # `openssl rand -hex 64` is a good way to generate a random value. DO NOT CHECK THIS INTO GIT! + CONFIGURATION__AUTHTOKEN: 'CHANGE-ME' + + # This is used to configure the IP address and port that the application will listen on. + # 0.0.0.0 is used to listen on all available IP addresses. + # Alternatively, you can specify localhost or 127.0.0.1 to listen on only the local machine. + # Multiple IP address / port combinations can be specified, separated by semicolons. + # Example: http://0.0.0.0:8000;http://127.0.0.1:8000 - Listen on all available IP addresses on port 8000, as well as only on the local machine on port 8000. (Redundant) + ASPNETCORE_URLS: 'http://0.0.0.0:8000' + + # Valid values are `Memory` or `PostgresSQL`. This is used to determine which database to use. + # `Memory` is used for development and testing, and is not recommended for production, as data is not persistent. + CONFIGURATION__DATABASETYPE: 'PostgresSQL' + CONFIGURATION__DATABASECONNECTIONSTRING: 'postgres://zenithinfo:zenithinfo@postgres:5432/zenithinfo' + + # Determines the log level for the application's default logger. + # Valid values are `Trace`, `Debug`, `Information`, `Warning`, `Error`, and `Critical`. + # `Trace` is the most verbose, and is recommended for development. + # `Information` is the default, and is recommended for production. + LOGGING__LOGLEVEL__DEFAULT: 'Information' + + # This is used to log requests to the application. + # If you are concerned about security or privacy, you should disable this. + CONFIGURATION__LOGREQUESTS: true + + # Using Sentry will send errors to my personal Sentry instance, https://sentry.csw.im/ + # This is not required for the application to run, but it is recommended for debugging purposes. + CONFIGURATION__USESENTRY: true + + # This is used to enable Swagger API Documentation for the application. + # If enabled, you can access the API documentation at the /swagger/index.html endpoint. + CONFIGURATION__USESWAGGER: true + + database: + image: postgres:15.4 + restart: always + environment: + POSTGRES_USER: zenithinfo + POSTGRES_PASSWORD: zenithinfo + POSTGRES_DB: zenithinfo + ports: + - 5433:5432 + volumes: + - postgres-data:/var/lib/postgresql/data + +volumes: + postgres-data: