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
13 changes: 13 additions & 0 deletions crud-app/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bin/
obj/
.vs/
.vscode/
*.user
*.suo
*.sln.docstates
keploy/
img/
*.md
docker-compose.yml
.gitignore
dotnet-install.sh
23 changes: 23 additions & 0 deletions crud-app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# ---- Build Stage ----
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src

# Copy csproj and restore dependencies first (layer caching)
COPY simpleAPI_v1.csproj ./
RUN dotnet restore simpleAPI_v1.csproj

# Copy the rest of the source code and build
COPY . ./
RUN dotnet publish simpleAPI_v1.csproj -c Release -o /app/publish

# ---- Runtime Stage ----
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app

COPY --from=build /app/publish .

# .NET 8 defaults to port 8080
EXPOSE 8080
ENV ASPNETCORE_URLS=http://+:8080

ENTRYPOINT ["dotnet", "simpleAPI_v1.dll"]
39 changes: 29 additions & 10 deletions crud-app/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
version: "3.9"
services:
postgres:
image: postgres:10.5
container_name: postgresDb
restart: always
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
ports:
- '5432:5432'
image: postgres:10.5
container_name: postgresDb
restart: always
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5

app:
build:
context: .
dockerfile: Dockerfile
container_name: crud-app
restart: on-failure
ports:
- "5249:8080"
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ConnectionStrings__DefaultConnection=Host=postgres;Port=5432;Database=postgres;Username=postgres;Password=password
depends_on:
postgres:
condition: service_healthy