{"id":26208780,"url":"https://github.com/amg262/netwebapi","last_synced_at":"2026-04-15T14:30:59.713Z","repository":{"id":229082251,"uuid":"635873699","full_name":"amg262/NetWebApi","owner":"amg262","description":"WebAPI project on .NET 7 using a MongoDB NoSQL","archived":false,"fork":false,"pushed_at":"2023-09-18T16:58:36.000Z","size":87,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-21T23:51:29.121Z","etag":null,"topics":["docker","dotnet-core","mongodb","nosql","webapi"],"latest_commit_sha":null,"homepage":"","language":"C#","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/amg262.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}},"created_at":"2023-05-03T16:29:36.000Z","updated_at":"2024-03-21T22:07:23.000Z","dependencies_parsed_at":"2024-03-22T00:25:35.039Z","dependency_job_id":"81fb4216-376e-4e70-8523-4829ba63f99e","html_url":"https://github.com/amg262/NetWebApi","commit_stats":null,"previous_names":["amg262/netwebapi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/amg262/NetWebApi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amg262%2FNetWebApi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amg262%2FNetWebApi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amg262%2FNetWebApi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amg262%2FNetWebApi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amg262","download_url":"https://codeload.github.com/amg262/NetWebApi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amg262%2FNetWebApi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31845442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T13:28:40.153Z","status":"ssl_error","status_checked_at":"2026-04-15T13:28:29.396Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["docker","dotnet-core","mongodb","nosql","webapi"],"created_at":"2025-03-12T06:29:56.740Z","updated_at":"2026-04-15T14:30:59.688Z","avatar_url":"https://github.com/amg262.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NetWebApiM\n\nWebAPI project on .NET 7 using a MongoDB NoSQL database\n\n## Installing MongoDB\n\n1. Install MongoDB from https://www.mongodb.com/try/download/community\n2. Install MongoDB Compass from https://www.mongodb.com/try/download/compass\n3. Run\n\n```dockerfile\ndocker run -d --rm --name mongo -p 27017:27017  -v C:\\ProgramData\\docker\\volumes\\mongodbdata:C:\\data\\db mongo\ndocker ps\ndocker stop mongo\n```\n\n### Code that fixed volume issue:\n\n```dockerfile\ndocker run -d --rm --name mongo -p 27017:27017  -v C:\\ProgramData\\docker\\volumes\\mongodbdata:C:\\data\\db mongo\n```\n\nThis worked for a separate D:\\ location and on Windows Server 2019\n\n### Code provided by example:\n\n```dockerfile\ndocker run -d --rm --name mongo -p 27017:27017  -v mongodbdata:data/db mongo\n-d --rm doesnt attach - and rm means its destoryed when you stop it.\n-p is opening a port to map to the container\n-v is volume, which is a way to persist data. mongodbdata is the name of the volume, and /data/db is the path inside the container\ndocker ps -- checks if its running\n```\n\n### New DB with auth\n\n```dockerfile\ndocker stop mongo\ndocker volume ls\ndocker volume rm mongodbdata\n```\n\nThis line works with a new volume for this Auth DB - while saving old one. Needed to move the 'mongo' to the very end of the line.\n\n```dockerfile\ndocker run -d --rm --name mongo -p 27017:27017  -v C:\\ProgramData\\docker\\volumes\\mongodbdataauth:C:\\data\\db -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=password mongo\n```\n\n### Initialize secrets:\n\nYou don't want to store the Password in appsettings.json - can use Command Line, .env, cloud to store the password in a secret store. We will use Secret Manager.\n\n```\ndotnet user-secrets init --project .\\Catalog\\\ndotnet user-secrets set MongoDbSettings:Password password\n```\n\n### Aysnchronous Programming\n\nhttps://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/\n\nAsync all the way from controller to repository to database\n\n### Health Checks\n\nhttps://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?view=aspnetcore-5.0\n\nWe can use health checks to monitor the health of our application. We can use this to monitor the health of our database.\n\nHealthChecks UI: https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks\n\n### Dockerfile\n\n```dockerfile\ndocker build -t catalog:v1 .\ndocker network create NetWebApi\ndocker network ls\n```\n\nAndrew-PC original docker desktop run command\n\n```dockerfile\ndocker run --hostname=f09e4723dab5 --env=MONGO_INITDB_ROOT_USERNAME=mongoadmin --env=MONGO_INITDB_ROOT_PASSWORD=password --env=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin --env=GOSU_VERSION=1.16 --env=JSYA\nML_VERSION=3.13.1 --env=MONGO_PACKAGE=mongodb-org --env=MONGO_REPO=repo.mongodb.org --env=MONGO_MAJOR=6.0 --env=MONGO_VERSION=6.0.5 --env=HOME=/data/db --volume=/data/configdb --volume=/data/db -p 27017:27017 --label='org.opencontainers.image.ref.name=ubuntu'\n--label='org.opencontainers.image.version=22.04' --runtime=runc -d mongo:latest\n\ndocker run -it --rm -p 433:80 -e MongoDbSettings:Host=mongo -e MongoDbSettings:Password=password --network=netwebapi catalog:v1\n```\n\nAndrew-PC new docker desktop run command to use container\n\n```dockerfile\ndocker run --hostname=f09e4723dab5 --env=MONGO_INITDB_ROOT_USERNAME=mongoadmin --env=MONGO_INITDB_ROOT_PASSWORD=password --env=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin --env=GOSU_VERSION=1.16 --env=JSYA\nML_VERSION=3.13.1 --env=MONGO_PACKAGE=mongodb-org --env=MONGO_REPO=repo.mongodb.org --env=MONGO_MAJOR=6.0 --env=MONGO_VERSION=6.0.5 --env=HOME=/data/db --volume=/data/configdb --volume=/data/db -p 27017:27017 --label='org.opencontainers.image.ref.name=ubuntu'\n--label='org.opencontainers.image.version=22.04' --runtime=runc -d --network=NetWebApi mongo:latest\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famg262%2Fnetwebapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famg262%2Fnetwebapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famg262%2Fnetwebapi/lists"}