Skip to content

Commit 514c43a

Browse files
committed
Add Dockerfiles to API and CLI projects
- Do not use WebHost.UseUrls so Docker can use ASPNETCORE_URLS environment variable
1 parent cd40f8d commit 514c43a

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

API/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Build stage
2+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
3+
WORKDIR /src
4+
COPY json-vb.sln ./
5+
COPY API/API.vbproj ./API/
6+
COPY JsonParser/JsonParser.vbproj ./JsonParser/
7+
RUN dotnet restore "API/API.vbproj"
8+
9+
COPY API/. ./API/
10+
COPY JsonParser/. ./JsonParser/
11+
RUN dotnet publish "API/API.vbproj" -c Release -o /app/publish
12+
13+
# Runtime stage
14+
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS final
15+
WORKDIR /app
16+
COPY --from=build /app/publish .
17+
EXPOSE 8000
18+
ENV ASPNETCORE_URLS=http://0.0.0.0:8000
19+
ENTRYPOINT ["dotnet", "API.dll"]

API/Program.vb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ Module Program
1515

1616
Sub Main(args As String())
1717
Dim builder = WebApplication.CreateBuilder(args)
18-
builder.WebHost.UseUrls("http://localhost:8000", "https://localhost:8001")
19-
Dim app = builder.Build()
2018

19+
Dim app = builder.Build()
2120
app.MapPost("/api/v1/parse", AddressOf HandleParseAsync)
22-
2321
app.Run()
2422
End Sub
2523

CLI/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Build stage
2+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
3+
WORKDIR /src
4+
COPY json-vb.sln ./
5+
COPY CLI/CLI.vbproj ./CLI/
6+
COPY JsonParser/JsonParser.vbproj ./JsonParser/
7+
RUN dotnet restore "CLI/CLI.vbproj"
8+
9+
COPY CLI/. ./CLI/
10+
COPY JsonParser/. ./JsonParser/
11+
RUN dotnet publish "CLI/CLI.vbproj" -c Release -o /app/publish
12+
13+
# Runtime stage
14+
FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine AS final
15+
WORKDIR /app
16+
COPY --from=build /app/publish .
17+
ENTRYPOINT ["dotnet", "CLI.dll"]

0 commit comments

Comments
 (0)