Docker
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Saturn" Version="0.16.1" />
|
<PackageReference Include="Saturn" Version="0.16.1" />
|
||||||
|
<PackageReference Include="Thoth.Json.Giraffe" Version="6.0.0" />
|
||||||
<PackageReference Include="Thoth.Json.Net" Version="11.0.0" />
|
<PackageReference Include="Thoth.Json.Net" Version="11.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@@ -27,6 +28,9 @@
|
|||||||
<None Include="wwwroot\scripts\htmx.min.js">
|
<None Include="wwwroot\scripts\htmx.min.js">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="wwwroot\images\loading.svg">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Include="wwwroot\scripts\index.js">
|
<None Include="wwwroot\scripts\index.js">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ module Controller
|
|||||||
open System
|
open System
|
||||||
open System.Net.Http
|
open System.Net.Http
|
||||||
open System.Text.RegularExpressions
|
open System.Text.RegularExpressions
|
||||||
|
open Giraffe
|
||||||
open Giraffe.ViewEngine.HtmlElements
|
open Giraffe.ViewEngine.HtmlElements
|
||||||
open Types
|
open Types
|
||||||
open System.Text
|
open System.Text
|
||||||
|
open System.Net
|
||||||
open Thoth.Json.Net
|
open Thoth.Json.Net
|
||||||
|
|
||||||
|
|
||||||
let parseUsername (username: string) =
|
let parseUsername (username: string) =
|
||||||
let pattern = @"https?://(?:www\.)?my\.flightradar24\.com/([^/?#]+)"
|
let pattern = @"https?://(?:www\.)?my\.flightradar24\.com/([^/?#]+)"
|
||||||
let matches = Regex.Match(username, pattern)
|
let matches = Regex.Match(username, pattern)
|
||||||
@@ -24,12 +25,19 @@ let getJsonResult result =
|
|||||||
|
|
||||||
let makePostRequest<'x> (url: string) payload =
|
let makePostRequest<'x> (url: string) payload =
|
||||||
async {
|
async {
|
||||||
use httpClient = new HttpClient()
|
use handler = new HttpClientHandler()
|
||||||
|
handler.AutomaticDecompression <- DecompressionMethods.GZip ||| DecompressionMethods.Deflate
|
||||||
|
use httpClient = new HttpClient(handler)
|
||||||
|
|
||||||
let content = new StringContent(payload, Encoding.UTF8, "application/x-www-form-urlencoded")
|
let content = new StringContent(payload, Encoding.UTF8, "application/x-www-form-urlencoded")
|
||||||
let request = new HttpRequestMessage(HttpMethod.Post, url)
|
let request = new HttpRequestMessage(HttpMethod.Post, url)
|
||||||
request.Content <- content
|
request.Content <- content
|
||||||
|
request.Headers.Add("User-Agent", "Mozilla/5.0") // mimic browser
|
||||||
|
request.Headers.Add("Accept", "application/json")
|
||||||
|
|
||||||
let! response = httpClient.SendAsync(request) |> Async.AwaitTask
|
let! response = httpClient.SendAsync(request) |> Async.AwaitTask
|
||||||
let! responseContent = response.Content.ReadAsStringAsync() |> Async.AwaitTask
|
let! responseContent = response.Content.ReadAsStringAsync() |> Async.AwaitTask
|
||||||
|
|
||||||
return responseContent
|
return responseContent
|
||||||
}
|
}
|
||||||
|> Async.RunSynchronously
|
|> Async.RunSynchronously
|
||||||
@@ -106,6 +114,7 @@ let processAirports (alphabet: char[]) (allAirports: Airport[]) =
|
|||||||
let RenderAirportList (user: usernameQuery) =
|
let RenderAirportList (user: usernameQuery) =
|
||||||
let username = parseUsername user.fr24user
|
let username = parseUsername user.fr24user
|
||||||
let alphabet = [|'A'..'Z'|]
|
let alphabet = [|'A'..'Z'|]
|
||||||
|
|
||||||
let airports =
|
let airports =
|
||||||
$"username={username}&listType={user.searchType}&order=no&limit=0"
|
$"username={username}&listType={user.searchType}&order=no&limit=0"
|
||||||
|> makePostRequest<AirportResponseData> "https://my.flightradar24.com/public-scripts/profileToplist"
|
|> makePostRequest<AirportResponseData> "https://my.flightradar24.com/public-scripts/profileToplist"
|
||||||
|
|||||||
@@ -2,10 +2,14 @@ open Microsoft.AspNetCore.Http
|
|||||||
open Microsoft.Extensions.DependencyInjection
|
open Microsoft.Extensions.DependencyInjection
|
||||||
open Saturn
|
open Saturn
|
||||||
open Giraffe
|
open Giraffe
|
||||||
open Types
|
|
||||||
|
|
||||||
|
open Types
|
||||||
|
open Thoth.Json.Giraffe
|
||||||
|
open System
|
||||||
open System.Net
|
open System.Net
|
||||||
open System.Net.Sockets
|
open System.Net.Sockets
|
||||||
|
open System.IO
|
||||||
|
|
||||||
|
|
||||||
module Program =
|
module Program =
|
||||||
|
|
||||||
@@ -23,6 +27,7 @@ module Program =
|
|||||||
|
|
||||||
let ServiceConfig (services: IServiceCollection) =
|
let ServiceConfig (services: IServiceCollection) =
|
||||||
// Get the server IP address
|
// Get the server IP address
|
||||||
|
services.AddSingleton<Json.ISerializer>(ThothSerializer()) |> ignore
|
||||||
let serverIpAddress =
|
let serverIpAddress =
|
||||||
match Dns.GetHostEntry(Dns.GetHostName()).AddressList |> Array.tryFind(fun ip -> ip.AddressFamily = AddressFamily.InterNetwork) with
|
match Dns.GetHostEntry(Dns.GetHostName()).AddressList |> Array.tryFind(fun ip -> ip.AddressFamily = AddressFamily.InterNetwork) with
|
||||||
| Some ip -> ip.ToString()
|
| Some ip -> ip.ToString()
|
||||||
@@ -40,8 +45,8 @@ module Program =
|
|||||||
let app =
|
let app =
|
||||||
application {
|
application {
|
||||||
use_mime_types [(".woff", "application/font-woff")]
|
use_mime_types [(".woff", "application/font-woff")]
|
||||||
use_static "wwwroot"
|
|
||||||
use_router router
|
use_router router
|
||||||
|
use_static (Path.Combine(AppContext.BaseDirectory, "wwwroot"))
|
||||||
use_developer_exceptions
|
use_developer_exceptions
|
||||||
service_config ServiceConfig
|
service_config ServiceConfig
|
||||||
url "http://0.0.0.0:5001"
|
url "http://0.0.0.0:5001"
|
||||||
|
|||||||
29
AirportAlphabetGame/dockerfile
Normal file
29
AirportAlphabetGame/dockerfile
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Use a full Ubuntu image
|
||||||
|
FROM ubuntu:24.04 AS base
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install dependencies: ICU, CA certs, curl (optional for debugging)
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
libicu-dev \
|
||||||
|
ca-certificates \
|
||||||
|
curl \
|
||||||
|
unzip \
|
||||||
|
wget \
|
||||||
|
git \
|
||||||
|
tzdata && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Copy published .NET app
|
||||||
|
COPY bin/Release/net8.0/linux-x64/publish/ ./
|
||||||
|
|
||||||
|
# Expose port
|
||||||
|
EXPOSE 5001
|
||||||
|
|
||||||
|
# Set timezone (optional, avoids TZ issues)
|
||||||
|
ENV TZ=Australia/Brisbane
|
||||||
|
|
||||||
|
# Set entrypoint
|
||||||
|
ENTRYPOINT ["./AirportAlphabetGame"]
|
||||||
Reference in New Issue
Block a user