From a4f23a17f0732f1a5309f4ba582147db457bba18 Mon Sep 17 00:00:00 2001 From: Christopher Sanden Date: Sun, 29 Mar 2026 15:25:18 +0200 Subject: [PATCH] Adding docker and caddy files --- .dockerignore | 7 +++++++ Caddyfile | 3 +++ Dockerfile | 19 +++++++++++++++++++ docker-compose.yml | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 .dockerignore create mode 100644 Caddyfile create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f817ef1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +bin/ +obj/ +.git/ +.vs/ +.vscode/ + + diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..8e41b89 --- /dev/null +++ b/Caddyfile @@ -0,0 +1,3 @@ +:80 { + reverse_proxy web:8080 +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b2533ca --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env +WORKDIR /app + +COPY Example.csproj ./ +RUN dotnet restore + +COPY . . +RUN dotnet publish -c Release -o out + +FROM mcr.microsoft.com/dotnet/aspnet:8.0 + +WORKDIR /app + +COPY --from=build-env /app/out . + +ENV ASPNETCORE_URLS=http://+:8080 +EXPOSE 8080 + +ENTRYPOINT ["dotnet", "Example.dll"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..caf6a05 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,41 @@ +services: + web: + build: + context: . + dockerfile: Dockerfile + container_name: web + environment: + ASPNETCORE_ENVIRONMENT: Production + depends_on: + - db + expose: + - "8080" + + db: + image: postgres:16 + container_name: db + environment: + POSTGRES_DB: db + POSTGRES_USER: user + POSTGRES_PASSWORD: password + volumes: + - postgres_data:/var/lib/postgresql/data + expose: + - "5432" + + proxy: + image: caddy:2 + container_name: proxy + depends_on: + - web + ports: + - "80:80" + - "443:443" + volumes: + - ./Caddyfile:/etc/caddy/Caddyfile + - caddy_data:/data + - caddy_config:/config +volumes: + postgres_data: + caddy_data: + caddy_config: \ No newline at end of file