diff --git a/Dockerfile b/Dockerfile index 22f3c933..3b8f1b85 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,9 @@ RUN apt-get update \ ENV PUPPETEER_EXECUTABLE_PATH "/usr/bin/google-chrome-stable" FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env + +ARG CONFIGURATION=Release + WORKDIR /SeaPublicWebsite # Copy everything @@ -30,7 +33,7 @@ RUN dotnet nuget add source /SeaPublicWebsite/Lib --name Local RUN dotnet restore # Build and publish a release -RUN dotnet publish -c Release -o out +RUN dotnet publish -c $CONFIGURATION -o out # Build runtime image FROM base diff --git a/SeaPublicWebsite/Controllers/HomeController.cs b/SeaPublicWebsite/Controllers/HomeController.cs index 8d8b72cb..dbaec02f 100644 --- a/SeaPublicWebsite/Controllers/HomeController.cs +++ b/SeaPublicWebsite/Controllers/HomeController.cs @@ -1,21 +1,17 @@ using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -namespace SeaPublicWebsite.Controllers +namespace SeaPublicWebsite.Controllers; + +public class HomeController : Controller { - public class HomeController : Controller + [HttpGet("/")] + public IActionResult Index() { - private readonly ILogger _logger; - - public HomeController(ILogger logger) - { - _logger = logger; - } - - [HttpGet("/")] - public IActionResult Index() - { - return Redirect("https://www.gov.uk/improve-energy-efficiency"); - } +#if DEBUG + return Redirect("energy-efficiency/new-or-returning-user"); +#endif +#pragma warning disable CS0162 // Unreachable code detected + return Redirect("https://www.gov.uk/improve-energy-efficiency"); +#pragma warning restore CS0162 } } \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 5c406c45..5c41fd20 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,12 @@ -version: '3.8' - -services: +services: sea: - build: . + build: + context: . + args: + # If running docker-compose via a run configuration in Rider, it will + # override this with whatever build configuration you have selected. + # This is clever and kind of it, but a bit surprising! + CONFIGURATION: "Debug" ports: - "5001:80" environment: @@ -11,6 +15,10 @@ services: volumes: # map the dotnet user-secret folder - $APPDATA/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro + depends_on: + db: + condition: service_healthy + restart: true db: image: postgres restart: unless-stopped @@ -19,4 +27,9 @@ services: POSTGRES_USER: postgres POSTGRES_DB: seadev ports: - - "5432:5432" \ No newline at end of file + - "5432:5432" + healthcheck: + test: [ "CMD-SHELL", "pg_isready -d $$POSTGRES_DB -U $$POSTGRES_USER" ] + interval: 10s + timeout: 5s + retries: 5