Skip to content

Commit

Permalink
Merge pull request #319 from UKGovernmentBEIS/local-dev-redirect
Browse files Browse the repository at this point in the history
Redirect base URL to start page when running locally
  • Loading branch information
jdgage authored Jan 3, 2025
2 parents f9b1b0e + c8ecdfb commit fc3b37f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
26 changes: 11 additions & 15 deletions SeaPublicWebsite/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -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<HomeController> _logger;

public HomeController(ILogger<HomeController> 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
}
}
23 changes: 18 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand All @@ -19,4 +27,9 @@ services:
POSTGRES_USER: postgres
POSTGRES_DB: seadev
ports:
- "5432:5432"
- "5432:5432"
healthcheck:
test: [ "CMD-SHELL", "pg_isready -d $$POSTGRES_DB -U $$POSTGRES_USER" ]
interval: 10s
timeout: 5s
retries: 5

0 comments on commit fc3b37f

Please sign in to comment.