Skip to content

Commit

Permalink
docker-compose fix for console
Browse files Browse the repository at this point in the history
+ some other changes for the view-returns
  • Loading branch information
Kretchen001 committed Mar 8, 2024
1 parent 927221c commit 98daf30
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 32 deletions.
4 changes: 3 additions & 1 deletion code/AmIVulnerable/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ README.md
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
!.git/refs/heads/**
**/bin/Debug/net8.0/raw
**/bin/Debug/net8.0/rawAnalyze
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ViewController : Controller {
[HttpGet]
[Route("json-ld")]
public IActionResult JsonLd () {
string path = Path.Combine(Directory.GetCurrentDirectory() + @"\Controllers\Views", "json-ld.html");
string path = Path.Combine(Directory.GetCurrentDirectory() + @"/Controllers/Views", "json-ld.html");

return Content(System.IO.File.ReadAllText(path), "text/html");
}
Expand Down
39 changes: 24 additions & 15 deletions code/AmIVulnerable/AmIVulnerable/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
# Modells
WORKDIR /src/Modells
COPY Modells/Modells.csproj .
RUN dotnet restore Modells.csproj

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
# LiteDbLib
WORKDIR /src/LiteDbLib
COPY LiteDbLib/LiteDbLib.csproj .
RUN dotnet restore LiteDbLib.csproj

# API
WORKDIR /src/AmIVulnerable
COPY AmIVulnerable/AmIVulnerable.csproj .
RUN dotnet restore AmIVulnerable.csproj

# API build
WORKDIR /src
COPY ["AmIVulnerable/AmIVulnerable.csproj", "AmIVulnerable/"]
RUN dotnet restore "./AmIVulnerable/./AmIVulnerable.csproj"
COPY . .
WORKDIR "/src/AmIVulnerable"
RUN dotnet build "./AmIVulnerable.csproj" -c $BUILD_CONFIGURATION -o /app/build
RUN dotnet build AmIVulnerable/AmIVulnerable.csproj -c Release -o /app/build

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

FROM base AS final
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
WORKDIR /app
COPY AmIVulnerable/Controllers/Views /app/Controllers/Views
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "AmIVulnerable.dll"]
ENTRYPOINT ["dotnet", "AmIVulnerable.dll"]

EXPOSE 80
EXPOSE 443
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7203;http://localhost:5283"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
Expand Down
24 changes: 17 additions & 7 deletions code/AmIVulnerable/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
version: '3.4'

networks:
amivulnerable:
# networks:
# amivulnerable:

# services:
# amivulnerable:
# networks:
# - amivulnerable
# container_name: api
# image: amivulnerable:latest
# build:
# context: .
# dockerfile: AmIVulnerable/Dockerfile
# ports:
# - "8080:80"
# - "8443:443"

services:
amivulnerable:
networks:
- amivulnerable
container_name: api
image: amivulnerable:latest
build:
context: .
dockerfile: AmIVulnerable/Dockerfile
ports:
- "8080:80"
- "8443:443"
- 8080:80
- 8443:443

0 comments on commit 98daf30

Please sign in to comment.