Skip to content

Commit 7f57534

Browse files
committed
build(backend): Fix exposed ports
The default port is changed. So we have to use env var to specify it. The old WebHost is replaced by Host as required.
1 parent 225cb87 commit 7f57534

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

backend/src/AcmStatisticsBackend.Web.Host/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ RUN apt-get update && apt-get install -y wait-for-it
2424
ENV WAIT_COMMAND true
2525
WORKDIR /app
2626
COPY --from=publish /app/publish .
27+
ENV ASPNETCORE_HTTP_PORTS 80
2728
CMD $WAIT_COMMAND && dotnet AcmStatisticsBackend.Web.Host.dll
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
using Microsoft.AspNetCore;
2-
using Microsoft.AspNetCore.Hosting;
1+
using Microsoft.AspNetCore.Hosting;
2+
using Microsoft.Extensions.Hosting;
33

44
namespace AcmStatisticsBackend.Web.Host.Startup
55
{
66
public class Program
77
{
88
public static void Main(string[] args)
99
{
10-
BuildWebHost(args).Run();
10+
CreateHostBuilder(args).Build().Run();
1111
}
1212

13-
public static IWebHost BuildWebHost(string[] args)
13+
public static IHostBuilder CreateHostBuilder(string[] args)
1414
{
15-
return WebHost.CreateDefaultBuilder(args)
16-
.UseStartup<Startup>()
17-
.Build();
15+
return Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args)
16+
.ConfigureWebHostDefaults(webHost => webHost.UseStartup<Startup>());
1817
}
1918
}
2019
}

build/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ services:
3636
- ACM_STATISTICS_CRAWLER_ENV__crawlers__vjudge__crawler_login_user="${VJUDGE_USERNAME}"
3737
- ACM_STATISTICS_CRAWLER_ENV__crawlers__vjudge__crawler_login_password="${VJUDGE_PASSWORD}"
3838
labels:
39+
- traefik.enable=true
3940
- traefik.http.routers.crawler-api-backend.rule=PathPrefix(`/api/crawlers`)
4041
- traefik.http.services.crawler-api-backend.loadbalancer.server.port=80
4142

@@ -57,7 +58,6 @@ services:
5758
ASPNETCORE_FORWARDEDHEADERS_ENABLED: 'true'
5859
labels:
5960
- traefik.http.routers.backend.rule=PathPrefix(`/api`)||PathPrefix(`/AntiForgery`)
60-
- traefik.http.routers.backend.priority=18
6161
- traefik.http.services.backend.loadbalancer.server.port=80
6262
volumes:
6363
- ./App_Data:/app/App_Data

ohunt/OHunt.Web/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ RUN apt-get update && apt-get install -y wait-for-it
2121
ENV WAIT_COMMAND true
2222
WORKDIR /app
2323
COPY --from=publish /app/publish .
24+
ENV ASPNETCORE_HTTP_PORTS 80
2425
CMD $WAIT_COMMAND && dotnet OHunt.Web.dll

0 commit comments

Comments
 (0)