{"id":18658590,"url":"https://github.com/cboudereau/dotnetlinux","last_synced_at":"2025-07-02T11:39:13.370Z","repository":{"id":89756999,"uuid":"218811218","full_name":"cboudereau/dotnetlinux","owner":"cboudereau","description":"dotnetcore3.0 console app demo on linux, mysql, aspnet in fsharp","archived":false,"fork":false,"pushed_at":"2020-05-25T15:59:50.000Z","size":88,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-27T15:28:05.251Z","etag":null,"topics":["asp-net-core","demo","docker","fsharp","giraffe","linux","mysql","sqlprovider"],"latest_commit_sha":null,"homepage":"","language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cboudereau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-31T16:31:50.000Z","updated_at":"2020-09-17T02:03:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"ecbe98b7-d846-40fa-b7a5-0888101aba27","html_url":"https://github.com/cboudereau/dotnetlinux","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cboudereau%2Fdotnetlinux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cboudereau%2Fdotnetlinux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cboudereau%2Fdotnetlinux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cboudereau%2Fdotnetlinux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cboudereau","download_url":"https://codeload.github.com/cboudereau/dotnetlinux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239475962,"owners_count":19645041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net-core","demo","docker","fsharp","giraffe","linux","mysql","sqlprovider"],"created_at":"2024-11-07T07:33:44.381Z","updated_at":"2025-02-18T12:56:19.413Z","avatar_url":"https://github.com/cboudereau.png","language":"F#","readme":"# dotnetlinux (a bad named repo...)\r\n\r\nThis repo contains a sample app which connects on a local mysql to make basic select and insert operations exposed as a simple http api.\r\n\r\nThe setup part contains the demo env with centos 6 + mysql. Please do not do that in prod, this config is only for dev.\r\n\r\n## Features\r\n - A ready to use dev environment : a windows desktop with a fully compatible linux env based on docker.\r\n - mysql client with fsharp type provider : [SQLProvider](https://github.com/fsprojects/SQLProvider/tree/master/tests/SqlProvider.Core.Tests/MySql)\r\n - webserver : [Giraffe](https://github.com/giraffe-fsharp/Giraffe)\r\n - dotnetcore : an app compatible for windows (locally) and for linux (with dotnet publish)\r\n - Deploy locally database and app in a legacy context by executing run.cmd (thanks to docker-compose) but also run the app locally by pressing F5 in vs code.\r\n - App code is available into a single file main.fs which contains for the first part the SQL part and at the end of file, the giraffe web api demo.\r\n\r\n## Setup Docker Desktop\r\n### Normal version\r\n\r\nYou can install docker desktop for windows here https://www.docker.com/products/docker-desktop.\r\n\r\nIt works out of the box but this version is using a HyperV VM (MobyLinuxVM) which performance cannot be adjusted dynamically and really slower than the new WSL2 based version.\r\n\r\n### Edge version (really fast! But only for testing now)\r\nThe edge version of docker desktop increases performance by at least 5x thanks to Microsoft wsl 2 optimisations.\r\n\r\nAt this time, wsl2 is only available on the slow ring of the windows insider program. You have to subscribe to windows insider then update your windows, activate wsl2, download edge version of Docker desktop then select the wsl 2 option from docker desktop\r\n\r\n1. Subcribe to Windows Insider\r\nOpen Windows Settings \u003e Update \u0026 Security \u003e Windows Insider \u003e Subscribe\r\nWhen it works, you can select the ring (for wsl2 at least slow is ok) and the restart screen appears. In my case I tried several times in 3 days to get those screen.\r\nYou can check the Windows Insider Program in Windows Update \u0026 Security.\r\n\r\n2. Install wsl2\r\nBecarefull if you previously installed wsl1 or docker desktop. In my case, I used the docker export command to backup one really important container (I am migrating this big container into smaller one). In my case the underlying VM was still there and I did not really lost anything.\r\n\r\nI removed wsl1 to have less problems but you can try directly if it works.\r\n\r\nFollow the instructions from this page : https://docs.microsoft.com/en-us/windows/wsl/wsl2-install\r\n\r\n3. Configure wsl2\r\n    wsl --set-default-version 2\r\n\r\n4. Install Docker Desktop Edge\r\nDownload the last Docker Desktop Edge which is a technical preview here : https://docs.docker.com/docker-for-windows/edge-release-notes/\r\nWhen it is installed, you can switch to wsl2 back and forth in the general settings (Enable the experimental WSL 2 based engine)\r\nFor further details, follow those instructions : https://docs.docker.com/docker-for-windows/wsl-tech-preview/\r\n\r\n5. Configure\r\nWhen wsl2 is configured through Docker Desktop Edge it is possible to check the runtime \r\n    wsl -l -v\r\n\r\n      NAME                   STATE           VERSION\r\n    * Ubuntu                 Running         2\r\n      docker-desktop-data    Running         2\r\n      docker-desktop         Running         2\r\n\r\n6. Fix for older system\r\nCreate a .wslconfig in order to run older os like centos 6\r\n\r\n   %userprofile%\\.wslconfig\r\n\r\n   [wsl2]\r\n   kernelCommandLine = vsyscall=emulate\r\n\r\nIn my case, I have the Ubuntu one and the 2 dockers\r\nWhen you restart Windows Terminal, you can run ubuntu commands directly!\r\n\r\n### (Optional) Install docker cli on Ubuntu WSL 2\r\nIf already have configured an ubuntu distrib running on wsl 2.\r\nIn the docker desktop settings \u003e Resources \u003e WSL Integration, activate the ubuntu distro to have the docker cli installed\r\n\r\n## Setup local dev environment (Install the localdb mysql container and dependencies for SQLProvider (lib folder))\r\n    setup.cmd\r\n\r\n## VsCode (settings.json)\r\n### Extensions\r\n - Install Ionide extension \r\n### FSharp configuration for dotnet core\r\n    {\r\n      \"FSharp.msbuildHost\": \".net core\",\r\n      \"FSharp.useSdkScripts\": true\r\n    }\r\n## VsCode tasks\r\nVsCode tasks is used to run the app locally by just pressing F5 in vscode which run a docker-compose to setup the database for the build.cmd process.\r\nThe tasks.json is available in the .vscode folder where the build.cmd is used to run in debug the app locally.\r\n\r\n## Build (the type provider will connect to the localdb container to build)\r\n    build.cmd\r\n  \r\n## Deploy/Run (mount the app folder which contains the poc and run the db and giraffe service)\r\n    docker-compose up\r\n  \r\n## Clean\r\n    docker-compose down \u0026\u0026 git clean -fxd\r\n\r\n## Run\r\n    run.cmd\r\n\r\n## Test\r\n1. Insert into mysql \"clem\"\r\n    iwr -Method Post -Body '{\"name\":\"hel\"}' -Uri http://localhost:5000/person\r\n2. List the person table\r\n    curl http://localhost:5000/persons\r\n\r\n## Known issues\r\n- SQLProvider with dotnetcore 3 and MySql : https://github.com/fsprojects/SQLProvider/tree/master/tests/SqlProvider.Core.Tests/MySql (see the installdeps.cmd script)\r\n- Fix globalization (this is why I use DOTNET_SYSTEM_GLOBALIZATION_INVARIANT env var)\r\n- Fix the PublishTrimmed which run for a very long time consuming 25% of CPU. \r\n\r\n## TODO\r\n- create a dotnet template new mysql with in parameter the name of the target os\r\n- Use FAKE to save schema config and avoid preparing mysql dependencies on build.\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcboudereau%2Fdotnetlinux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcboudereau%2Fdotnetlinux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcboudereau%2Fdotnetlinux/lists"}