add deployment configurations

This commit is contained in:
Jonas Seiler 2025-04-03 14:02:09 +02:00
parent 975dfb2086
commit bdb52d9faf
3 changed files with 154 additions and 0 deletions

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS base
WORKDIR /src
COPY ["PTV-Street.sln","./"]
COPY ["src/PTV-Street.csproj", "PTV-Street/"]
RUN dotnet restore "PTV-Street/PTV-Street.csproj"
COPY . .
WORKDIR "/src/"
RUN dotnet publish src -c Release -o /PTV-Street/publish
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS ports
WORKDIR /PTV-Street
EXPOSE 8080
FROM base AS final
WORKDIR /PTV-Street
COPY --from=base /PTV-Street/publish .
ENTRYPOINT ["dotnet", "PTV-Street.dll"]

59
docker-compose.yml Normal file
View File

@ -0,0 +1,59 @@
services:
postgis-db:
image: postgis/postgis:13-3.1
container_name: postgis-db
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: streets_db
networks:
- DB-Network
streets-1:
build:
context: .
dockerfile: Dockerfile
container_name: Streets-1
environment:
ASPNETCORE_ENVIRONMENT: Production
CONNECTION_STRING: "Host=postgis-db;Port=5432;Username=postgres;Password=password;Database=streets_db;"
ports:
- "5001:8080"
depends_on:
- postgis-db
networks:
- DB-Network
streets-2:
build:
context: .
dockerfile: Dockerfile
container_name: Streets-2
environment:
ASPNETCORE_ENVIRONMENT: Production
CONNECTION_STRING: "Host=postgis-db;Port=5432;Username=postgres;Password=password;Database=streets_db;"
ports:
- "5002:8080"
depends_on:
- postgis-db
networks:
- DB-Network
streets-3:
build:
context: .
dockerfile: Dockerfile
container_name: Streets-3
environment:
ASPNETCORE_ENVIRONMENT: Production
CONNECTION_STRING: "Host=postgis-db;Port=5432;Username=postgres;Password=password;Database=streets_db;"
ports:
- "5003:8080"
depends_on:
- postgis-db
networks:
- DB-Network
networks:
DB-Network:
driver: bridge

78
k8s.yaml Normal file
View File

@ -0,0 +1,78 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: streets
spec:
replicas: 3
selector:
matchLabels:
app: streets
template:
metadata:
labels:
app: streets
spec:
containers:
- name: streets
image: # This needs to be filled in
ports:
- containerPort: 80
env:
- name: ASPNETCORE_ENVIRONMENT
value: "Production"
- name: CONNECTION_STRING
value: "Host=postgis-db-service;Port=5432;Username=postgres;Password=password;Database=streets_db;"
---
apiVersion: v1
kind: Service
metadata:
name: streets-1
spec:
selector:
app: streets
ports:
- protocol: TCP
port: 5001
targetPort: 8080
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgis-db
spec:
replicas: 1
selector:
matchLabels:
app: postgis-db
template:
metadata:
labels:
app: postgis-db
spec:
containers:
- name: postgis-db
image: postgis/postgis:13-3.1
env:
- name: POSTGRES_USER
value: "postgres"
- name: POSTGRES_PASSWORD
value: "password"
- name: POSTGRES_DB
value: "streets_db"
ports:
- containerPort: 5432
---
apiVersion: v1
kind: Service
metadata:
name: postgis-db-service
spec:
selector:
app: postgis-db
ports:
- protocol: TCP
port: 5432
targetPort: 5432