Skip to content

Commit

Permalink
fix: unsetting default Region in AWS config to allow AWS_REGION envir…
Browse files Browse the repository at this point in the history
…onment variable to work properly. Allowing ASPNETCORE_URLS to define port application is listening on.
  • Loading branch information
alex-tsbk committed Sep 13, 2024
1 parent e2247be commit 96f208e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN dotnet publish -a $TARGETARCH \
./src/$PROJECT_NAME/$PROJECT_NAME.csproj

# Build the runtime image
FROM ${RUNTIME_IMAGE_BASE} as final
FROM ${RUNTIME_IMAGE_BASE} AS final

# Install curl for health checks
RUN apk --no-cache add curl
Expand All @@ -42,8 +42,7 @@ WORKDIR /app
# Only 2 files are needed to run the app: the binary and the appsettings.json
COPY --from=build /app/out/CloudMapEcsPrometheusDiscovery* .
COPY --from=build /app/out/appsettings.json .
# Should be enough to prevent port conflicts
EXPOSE 9001

ENTRYPOINT ["./CloudMapEcsPrometheusDiscovery"]

# Usage:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ private static WebApplicationBuilder AddLogging(this WebApplicationBuilder build
/// </remarks>
private static WebApplicationBuilder AddKestrelUrlsSupport(this WebApplicationBuilder builder)
{
builder.WebHost.UseUrls();
var urls = Environment.GetEnvironmentVariable("ASPNETCORE_URLS") ?? "http://*:9001";
builder.WebHost.UseUrls(urls.Split(";"));

return builder;
}

Expand Down Expand Up @@ -126,8 +128,8 @@ private static WebApplicationBuilder AddCentralizedErrorHandling(this WebApplica
internal static WebApplicationBuilder AddInfrastructure(this WebApplicationBuilder builder)
{
return builder
.AddKestrelUrlsSupport()
.AddConfiguration()
.AddKestrelUrlsSupport()
.AddLogging()
.AddHealthChecks()
.AddCaching()
Expand Down
8 changes: 0 additions & 8 deletions src/Apptality.CloudMapEcsPrometheusDiscovery/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,6 @@
"RelabelConfigurations": "",
},
"AWS": {
"Region": "us-west-2"
},
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://*:9001"
}
}
},
"Serilog": {
"Using": [
Expand Down

0 comments on commit 96f208e

Please sign in to comment.