Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DATABASE=OpenPlzApi
DBUSERNAME=plzuser
DBPASSWORD=qwertz
ENVIRONMENT=Development
TZ=Europe/Berlin
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,9 @@ FodyWeavers.xsd

# No development configurations
appsettings.Development.json

# No Docker environment configurations
.env

# No downloads
downloads/
56 changes: 56 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
services:
db:
image: postgres:18-alpine
container_name: openplz-db
restart: unless-stopped
shm_size: 256mb
volumes:
- pgdata:/var/lib/postgresql
environment:
POSTGRES_DB: ${DATABASE}
POSTGRES_USER: ${DBUSERNAME}
POSTGRES_PASSWORD: ${DBPASSWORD}

api:
image: openplzapi-webservice:latest
build:
context: ./src
dockerfile: ./webservice/dockerfile
container_name: openplz-api
restart: unless-stopped
depends_on:
- db
environment:
ASPNETCORE_ENVIRONMENT: ${ENVIRONMENT}
ASPNETCORE_HTTP_PORTS: 8080
Database__Server: db
Database__Database: ${DATABASE}
Database__Username: ${DBUSERNAME}
Database__Password: ${DBPASSWORD}
TZ: ${TZ:-Europe/Berlin}
ports:
- 8080:8080

cli:
image: openplzapi-cli:latest
build:
context: ./src
dockerfile: ./cli/dockerfile
container_name: openplz-cli
# uncomment the following line for initialization of the database, then comment it again for regular usage
# command: ["initdb","--import"]
restart: "no"
depends_on:
- db
environment:
ASPNETCORE_ENVIRONMENT: ${ENVIRONMENT}
Database__Server: db
Database__Database: ${DATABASE}
Database__Username: ${DBUSERNAME}
Database__Password: ${DBPASSWORD}
TZ: ${TZ:-Europe/Berlin}
volumes:
- ./downloads:/downloads

volumes:
pgdata:
3 changes: 2 additions & 1 deletion src/cli/OpenPlzApi.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<PackageReference Include="Enbrea.GuidFactory" Version="0.11.0" />
<PackageReference Include="Enbrea.Konsoli" Version="0.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.3" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="10.0.3" />
<PackageReference Include="OpenPlzApi.AGVCH" Version="0.2.0" />
Expand All @@ -35,7 +36,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\datalayer\OpenPlzAPI.DataLayer.csproj" />
<ProjectReference Include="..\datalayer\OpenPlzApi.DataLayer.csproj" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions src/cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static async Task<int> Main(string[] args)
.AddJsonFile("appsettings.json", optional: false)
.AddJsonFile("appsettings.Development.json", optional: true)
.AddJsonFile("appsettings.Production.json", optional: true)
.AddEnvironmentVariables()
.Build();

// Bind configuration
Expand Down
20 changes: 20 additions & 0 deletions src/cli/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /App

# Copy everything
COPY ./cli ./
COPY ./datalayer /datalayer
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/runtime:10.0
WORKDIR /App
COPY --from=build /App/out .
ENV Sources__RootFolderName=/downloads
RUN mkdir /downloads
ENTRYPOINT ["dotnet", "OpenPlzApi.CLI.dll"]
# Default to showing help when no command is provided; user can pass any subcommand
CMD ["-h"]
18 changes: 18 additions & 0 deletions src/webservice/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /App

# Copy everything
COPY ./webservice ./
COPY ./datalayer /datalayer
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /App
COPY --from=build /App/out .
EXPOSE 8080
USER $APP_UID
ENTRYPOINT ["dotnet", "OpenPlzApi.WebService.dll"]