{"id":17001311,"url":"https://github.com/jpalomaki/nim-app","last_synced_at":"2026-04-20T10:02:35.869Z","repository":{"id":200449033,"uuid":"609305708","full_name":"jpalomaki/nim-app","owner":"jpalomaki","description":"Sample Nim application on AWS App Runner","archived":false,"fork":false,"pushed_at":"2023-03-17T18:19:04.000Z","size":47,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-22T08:48:36.234Z","etag":null,"topics":["aws","cloudflare","docker","nim"],"latest_commit_sha":null,"homepage":"","language":"Nim","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jpalomaki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-03T20:26:43.000Z","updated_at":"2024-06-12T14:22:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"b57f5c8d-86f7-4387-b47d-e00f1ee17872","html_url":"https://github.com/jpalomaki/nim-app","commit_stats":null,"previous_names":["jpalomaki/nim-app"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jpalomaki/nim-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpalomaki%2Fnim-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpalomaki%2Fnim-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpalomaki%2Fnim-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpalomaki%2Fnim-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpalomaki","download_url":"https://codeload.github.com/jpalomaki/nim-app/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpalomaki%2Fnim-app/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32042293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["aws","cloudflare","docker","nim"],"created_at":"2024-10-14T04:24:33.549Z","updated_at":"2026-04-20T10:02:35.800Z","avatar_url":"https://github.com/jpalomaki.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nim-app\n\nContainerized sample [Nim](https://nim-lang.org/) application powered by [Prologue](https://github.com/planety/prologue).\n\nWe deploy the application to AWS App Runner and proxy traffic to it via Cloudflare.\n\n## Build and run locally\n\n```sh\ndocker build -t nim-app:v1 .\ndocker run --init -it -p 8080:8080 --rm nim-app:v1\n```\n\n## Host the app with AWS App Runner (public endpoint)\n\n:warning: This guide is a work in progress, and may be incomplete\n\n:information_source: This requires an [AWS account](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/) and will incur some [App Runner](https://aws.amazon.com/apprunner/pricing/) and [ECR](https://aws.amazon.com/ecr/pricing/) costs.\n\n1. Create AWS ECR repository to host the container images\n\n    :information_source: We configure ECR image tags as MUTABLE, to leverage the App Runner autodeployment feature\n\n    ```sh\n    aws cloudformation deploy --template-file aws/ecr-repo.yml --stack-name nim-app-ecr --parameter-overrides Name=nim-app\n    ecr_repository=\"$(aws cloudformation describe-stacks --stack-name nim-app-ecr | jq -r '.Stacks[0].Outputs[] | select(.OutputKey == \"Uri\") | .OutputValue')\"\n    ecr_registry=\"${ecr_repository%%/nim-app}\"\n    ```\n\n2. Build, tag and push the docker image to the ECR repository\n\n    ```sh\n    aws ecr get-login-password | docker login --username AWS --password-stdin $ecr_registry\n    docker build -t nim-app:v1 .\n    docker tag nim-app:v1 $ecr_repository:v1\n    docker push $ecr_repository:v1\n    ```\n\n3. Deploy the app as AWS App Runner service\n\n    :information_source: We create the autoscaling configuration using AWS CLI, because [CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_AppRunner.html) does not yet support this functionality\n\n    ```sh\n    autoscaling_config_arn=\"$(aws apprunner create-auto-scaling-configuration --auto-scaling-configuration-name nim-app \\\n        --max-concurrency 100 --min-size 1 --max-size 2 | jq -r '.AutoScalingConfiguration.AutoScalingConfigurationArn')\"\n    aws cloudformation deploy --template-file aws/app-runner.yml --capabilities CAPABILITY_NAMED_IAM \\\n        --stack-name nim-app-runner --parameter-overrides Image=\"$ecr_repository:v1\" AutoScalingConfigArn=$autoscaling_config_arn\n    service_arn=\"$(aws cloudformation describe-stacks --stack-name nim-app-runner | jq -r '.Stacks[0].Outputs[] | select(.OutputKey == \"Arn\") | .OutputValue')\"\n    echo \"Service URL: https://$(aws cloudformation describe-stacks --stack-name nim-app-runner | jq -r '.Stacks[0].Outputs[] | select(.OutputKey == \"Url\") | .OutputValue')\"\n    ```\n\n4. Try changing the `hello` handler code in [src/app.nim](src/app.nim), then build, tag and push the `v1` image again, and observe result\n\n## Proxy traffic to the App Runner service through Cloudflare\n\nThis requires a [Cloudflare](https://dash.cloudflare.com/sign-up) account and website.\n\n1. Associate custom DNS domain (e.g. `app.example.com`) to the App Runner service\n\n    :information_source: We use AWS CLI here, because [CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_AppRunner.html) does not yet support this functionality\n\n    ```sh\n    aws apprunner associate-custom-domain --service-arn $service_arn --domain-name \u003cdomain\u003e --no-enable-www-subdomain\n    aws apprunner describe-custom-domains --service-arn $service_arn | jq -r '.CustomDomains[0].CertificateValidationRecords[]'\n    ```\n\n2. Create DNS records in Cloudflare DNS and configure SSL/TLS\n    - Login to [Cloudflare dashboard](https://dash.cloudflare.com)\n    - Navigate to `\u003cwebsite\u003e` → DNS → Records\n    - Select `Add record` and create a `DNS Only` CNAME record for all the validation records from step 1\n    - Select `Add record` and create a `Proxied` (orange clouded) CNAME record for `\u003cdomain\u003e`, pointing to the App Runner service URL\n    - Navigate to `\u003cwebsite\u003e` → SSL/TLS → Overview\n    - Ensure that encryption mode is `Full (strict)`\n \n3. Test the app at `https://\u003cdomain`\n\n## Tear down all resources\n\n1. Delete Cloudflare DNS records\n\n   - Login to [Cloudflare dashboard](https://dash.cloudflare.com)\n   - Navigate to `\u003cwebsite\u003e` → DNS → Records\n   - Delete the associated certificate validation and proxy CNAME records\n\n2. Remove AWS resources\n\n    ```sh\n    aws cloudformation delete-stack --stack-name nim-app-runner\n    aws cloudformation wait stack-delete-complete --stack-name nim-app-runner\n    aws apprunner delete-auto-scaling-configuration --auto-scaling-configuration-arn $autoscaling_config_arn\n    for digest in $(aws ecr list-images --repository-name nim-app | jq -r '.imageIds[].imageDigest'); do\n        aws ecr batch-delete-image --repository-name nim-app --image-ids imageDigest=$digest\n    done\n    aws cloudformation delete-stack --stack-name nim-app-ecr\n    aws cloudformation wait stack-delete-complete --stack-name nim-app-ecr\n    ```\n\n## TODOs\n\n- Explore use of [AWS C++ SDK](https://aws.amazon.com/sdk-for-cpp/) from Nim (calling e.g. DynamoDB)\n  - \u003chttps://nim-lang.org/docs/manual.html#implementation-specific-pragmas-importcpp-pragma\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpalomaki%2Fnim-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpalomaki%2Fnim-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpalomaki%2Fnim-app/lists"}