Skip to content

Some tech notes

Deploy authelia on swarm

Intro I started using Docker Swarm in 2022 and am still very satisfied with it. I am currenyl using it as a one node swarm. This post assumes you deployed Swarm with a Traefik reverse proxy as described on DockerSwarm.rocksi, that all services are deployed under the doomain stored in the DOMAIN environment variable, and that the variable DOCKER_HOST is set correctly. I wanted to test authelia for protecting a web app to be deployed on a Docker Swarm, and I decided to test it on an existing Docker Swarm.

Edit a file on a docker swarm volume

Editing a file stored on a container volume in production is a very bad idea. You should not do it and pass all configuration through your container orchestrator. Using a single node Docker Swarm for test purposes, it can be a huge time saver though. Here’s how to do it. Ensure that your DOCKER_HOST environment is set such that running docker volume ls will show the volume storing the file you want to edit (let’s call this volume myvol).

Ddefine a f# function using reflection

#Intro I looked at this thinking it would be useful with WebSharper.Forms definition. I was wrong, but I want to keep a trace of this, so here is a blog post about it. This post is not meant to be pedagogical, but it can be useful as an example. We’ll work on an example DU type hypothetically used to describe form fields: type DataType = |String of name:string |Int of name:string |Choice of name:string * string list You can use this type to define forms.

Websharper Proxy Project

WebSharper lets you bring your FSharp code to the client-side. For types in your WebSharper project to be used at both server and client sides, you annotate them with [<JavaScript>]. For types that were compiled without WebSharper, you need to define a proxy type, which will be compiled to javascript and be used in place of the compiled type. This is done easily, as this example from the official documentation shows:

Sending Mails In Aspnetcore

This post is part of series starting here. Here’s how I configure my mailers in a ASP.Net Core project developed in F#. I define an interface: type IMailer = // to * subject * body abstract Send: string * string * string -> unit of which I have 2 implementation. The first one is for development as it simply prints the mail on the server’s standard output: type ConsoleMailer() = interface IMailer with member _.

Passwordless Login Sending Login Mail Websharper

This post is part of series starting here. Sending the mail Sending the mail is not hard, but will show how code running at the client side can call RPC functions provided by the server. These calls are totally transparent. For the login page, we add an endpoint: | [<EndPoint "/l">] Login and map it to a function all as seen earlier: Application.MultiPage (fun ctx endpoint -> match endpoint with | EndPoint.

Passwordless Login With Websharper

Intro I had the need recently to provide some admin access to a web application, but adding password management in that application was not worth the trouble. It was much easier to allow users to request a authentication link by email, as this post will show. The web app is dveloped in WebSharper. If you’re a F# developed, you should really check it out! I like that I can develop client and server in one integrated code base, all in F#.

Docker Swarm in 2022

Going with Docker Swarm in 2022 TL;DR: Docker Swarm is probably good enough in a lot of cases. See the update for 2023 Having worked professionally on setting up, customising and deploying Kubernetes (but without pretending to be a specialist), I didn’t want to go down that path for my personal infrastructure, even if using Jsonnet was of great help (see my Jsonnet course here). I tried Nomad which worked fine, but getting it to do what I wanted was taking more time than I hoped.