Skip to content

Commit

Permalink
Dockerfiles for auth/web, deployment scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
PJB3005 committed May 23, 2024
1 parent 1d98ccd commit 6ecfa67
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 4 deletions.
8 changes: 4 additions & 4 deletions SS14.Auth/SS14.Auth.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand All @@ -10,10 +10,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="8.0.0" />
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="2.1.0" />
<PackageReference Include="prometheus-net" Version="7.0.0" />
<PackageReference Include="prometheus-net.AspNetCore" Version="7.0.0" />
<PackageReference Include="prometheus-net" Version="8.2.1" />
<PackageReference Include="prometheus-net.AspNetCore" Version="8.2.1" />
</ItemGroup>


Expand Down
2 changes: 2 additions & 0 deletions SS14.Web.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ProjectSection(SolutionItems) = preProject
deploy.sh = deploy.sh
build.sh = build.sh
.dockerignore = .dockerignore
auth.Dockerfile = auth.Dockerfile
web.Dockerfile = web.Dockerfile
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{569B190C-2FE6-44FA-B282-E0E7ACE64226}"
Expand Down
24 changes: 24 additions & 0 deletions auth.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
RUN mkdir /repo && chown $APP_UID /repo
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 ["SS14.Auth/SS14.Auth.csproj", "SS14.Auth/"]
RUN dotnet restore "SS14.Auth/SS14.Auth.csproj"
COPY . .
WORKDIR "/src/SS14.Auth"
RUN dotnet build "SS14.Auth.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "SS14.Auth.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SS14.Auth.dll"]
17 changes: 17 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -e

to_build=$1

if [ "$to_build" == hub ]; then
docker build . -f hub.Dockerfile -t ss14_serverhub
fi

if [ "$to_build" == web ]; then
docker build . -f web.Dockerfile -t ss14_web
fi

if [ "$to_build" == auth ]; then
docker build . -f auth.Dockerfile -t ss14_auth
fi
22 changes: 22 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -e

to_build=$1

if [ "$to_build" == hub ]; then
docker image save ss14_serverhub | gzip | ssh pebbles podman load &
docker image save ss14_serverhub | gzip | ssh nsh podman load &
fi

if [ "$to_build" == auth ]; then
docker image save ss14_auth | gzip | ssh pebbles podman load &
docker image save ss14_auth | gzip | ssh nsh podman load &
fi

if [ "$to_build" == web ]; then
docker image save ss14_web | gzip | ssh pebbles podman load &
docker image save ss14_web | gzip | ssh nsh podman load &
fi

wait $(jobs -p)
24 changes: 24 additions & 0 deletions web.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
RUN mkdir /repo && chown 1654 /repo
USER 1654
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["SS14.Web/SS14.Web.csproj", "SS14.Web/"]
RUN dotnet restore "SS14.Web/SS14.Web.csproj"
COPY . .
WORKDIR "/src/SS14.Web"
RUN dotnet build "SS14.Web.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "SS14.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SS14.Web.dll"]

0 comments on commit 6ecfa67

Please sign in to comment.