Skip to content

Commit

Permalink
Update to .NET 8 (#2)
Browse files Browse the repository at this point in the history
* chore: replace Giraffe master branch references by main branch

* feat: update F# project to .NET 8

* chore: update dockerfile to use .NET 8 SDK image

* chore: start using .NET 8 in CI

* chore: update RELEASE_NOTES

* add ASPNETCORE_HTTP_PORTS to Dockerfile so we can keep listening at port 80

* revert container port to use the default 5000

* revert the Program.fs links to use the master branch

* update RELEASE_NOTES.md
  • Loading branch information
64J0 authored Jul 19, 2024
1 parent cd01756 commit e61f849
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 5.x
dotnet-version: 8.x
- name: Restore
run: dotnet restore src/Giraffe.Website/Giraffe.Website.fsproj
- name: Build
Expand Down
6 changes: 6 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release Notes
=============

## 1.6.0

- [Minor CSS change](https://github.com/giraffe-fsharp/giraffe-website/pull/3) - Credits @m-rinaldi
- [(CI) GitHub actions version update](https://github.com/giraffe-fsharp/giraffe-website/pull/5) - Credits @64J0
- [Update to .NET 8](https://github.com/giraffe-fsharp/giraffe-website/pull/2) - Credits @64J0

## 1.5.0

CSS changes.
Expand Down
8 changes: 4 additions & 4 deletions src/Giraffe.Website/Common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ module NetworkExtensions =
type IApplicationBuilder with
member this.UseTrailingSlashRedirection() =
this.Use(
fun ctx next ->
fun (ctx: HttpContext) (next: RequestDelegate) ->
let hasTrailingSlash =
ctx.Request.Path.HasValue
&& ctx.Request.Path.Value.EndsWith "/"
Expand All @@ -229,13 +229,13 @@ module NetworkExtensions =
let url = Microsoft.AspNetCore.Http.Extensions.UriHelper.GetEncodedUrl ctx.Request
ctx.Response.Redirect(url, true)
Threading.Tasks.Task.CompletedTask
| false -> next.Invoke())
| false -> next.Invoke(ctx))

member this.UseHttpsRedirection (isEnabled : bool, domainName : string) =
match isEnabled with
| true ->
this.Use(
fun ctx next ->
fun (ctx: HttpContext) (next: RequestDelegate) ->
let host = ctx.Request.Host.Host
// Only HTTPS redirect for the chosen domain:
let mustUseHttps =
Expand All @@ -246,7 +246,7 @@ module NetworkExtensions =
if not mustUseHttps then
ctx.Request.Scheme <- "https"
ctx.Request.IsHttps <- true
next.Invoke())
next.Invoke(ctx))
.UseHttpsRedirection()
| false -> this

Expand Down
8 changes: 6 additions & 2 deletions src/Giraffe.Website/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build

ARG version=0.0.0-undefined

Expand All @@ -9,7 +9,11 @@ COPY src/ ./
RUN dotnet publish /p:Version=$version Giraffe.Website/Giraffe.Website.fsproj -c Release -o published

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine AS runtime
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS runtime

# Change the HTTP port that the server process is listening
# https://learn.microsoft.com/en-us/dotnet/core/compatibility/containers/8.0/aspnet-port
ENV ASPNETCORE_HTTP_PORTS=5000

WORKDIR /app
COPY --from=build /app/published .
Expand Down
7 changes: 3 additions & 4 deletions src/Giraffe.Website/Giraffe.Website.fsproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RollForward>Major</RollForward>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
<RunWorkingDirectory>$(MSBuildThisFileDirectory)</RunWorkingDirectory>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Giraffe" Version="5.0.0" />
<PackageReference Include="Giraffe.ViewEngine" Version="1.3.*" />
<PackageReference Include="Ply" Version="0.3.*" />
<PackageReference Include="Giraffe" Version="6.4.0" />
<PackageReference Include="Giraffe.ViewEngine" Version="1.4.0" />
<PackageReference Include="Logfella" Version="7.1.*" />
<PackageReference Include="Sentry.AspNetCore" Version="2.1.*" />
<PackageReference Include="Markdig" Version="0.22.*" />
Expand Down
1 change: 0 additions & 1 deletion src/Giraffe.Website/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ module WebApp =
open System.Net.Http
open Microsoft.Extensions.Logging
open Microsoft.Net.Http.Headers
open FSharp.Control.Tasks
open Giraffe
open Giraffe.EndpointRouting
open Giraffe.ViewEngine
Expand Down

0 comments on commit e61f849

Please sign in to comment.