C
C#9mo ago
Natro

ngrok - How to listen on webhook requests locally (docker)?

Hey, I have ASP.NET app that is listening on Slack webhook requests. How can I debug this locally? I know there is this thing called tunnels which exists in Visual Studio. This is my Dockerfile: My dockerfile:
# Used for docker-compose and running of app

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["./PyriteDocs.Api.csproj", "PyriteDocs.Api/"]
COPY ["../PyriteDocs.Shared/PyriteDocs.Shared.csproj", "PyriteDocs.Shared/"]

RUN dotnet restore "./PyriteDocs.Api/PyriteDocs.Api.csproj"

COPY . .
WORKDIR "/src/PyriteDocs.Api"
RUN dotnet build "./PyriteDocs.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./PyriteDocs.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "PyriteDocs.Api.dll"]
# Used for docker-compose and running of app

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["./PyriteDocs.Api.csproj", "PyriteDocs.Api/"]
COPY ["../PyriteDocs.Shared/PyriteDocs.Shared.csproj", "PyriteDocs.Shared/"]

RUN dotnet restore "./PyriteDocs.Api/PyriteDocs.Api.csproj"

COPY . .
WORKDIR "/src/PyriteDocs.Api"
RUN dotnet build "./PyriteDocs.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./PyriteDocs.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "PyriteDocs.Api.dll"]
4 Replies
Angius
Angius9mo ago
Ngrok would be easiest
Natro
NatroOP9mo ago
I managed to setup my ngrok: This is on https://{uid}.ngrok-free.app/swagger/index.html When I try to request https://{uid}.ngrok-free.app/Documentation/ping it doesn't work. When trying same endpoint on localhost or in my production environment it works fine. On my ngrok I keep getting 307 redirects:
No description
No description
Natro
NatroOP9mo ago
Any idea why this is happening? My docker-compose:
services:
pyritedocs.api:
container_name: pyritedocs.api
hostname: pyritedocs
image: ${DOCKER_REGISTRY-}pyritedocs.api
build:
context: src
dockerfile: PyriteDocs.Api/Dockerfile
environment:
- ...
ports:
- 8082:80
- 8084:443
depends_on:
grafana:
condition: service_healthy
prometheus:
condition: service_healthy
db:
condition: service_healthy

ngrok:
image: ngrok/ngrok:latest
container_name: ngrok_pyritedocs
restart: unless-stopped
environment:
- NGROK_AUTHTOKEN=${NGROK_AUTHTOKEN}
- BIND_TLS=true
- REGION=eu
command: 'http pyritedocs.api:80'
ports:
- 4040:4040
expose:
- '4040'
services:
pyritedocs.api:
container_name: pyritedocs.api
hostname: pyritedocs
image: ${DOCKER_REGISTRY-}pyritedocs.api
build:
context: src
dockerfile: PyriteDocs.Api/Dockerfile
environment:
- ...
ports:
- 8082:80
- 8084:443
depends_on:
grafana:
condition: service_healthy
prometheus:
condition: service_healthy
db:
condition: service_healthy

ngrok:
image: ngrok/ngrok:latest
container_name: ngrok_pyritedocs
restart: unless-stopped
environment:
- NGROK_AUTHTOKEN=${NGROK_AUTHTOKEN}
- BIND_TLS=true
- REGION=eu
command: 'http pyritedocs.api:80'
ports:
- 4040:4040
expose:
- '4040'
Natro
NatroOP9mo ago
Edit swagger pic*
No description
Want results from more Discord servers?
Add your server