1

I am trying to setup Slack interactivity (handling the interactive elements click) on my backend. Of course, for this task I need to have a https:// endpoint, so ngRok is the best solution for this. I have previously worked with this tool and it is great, this is my old config for docker compose:

ngrok:
    image: ngrok/ngrok:latest
    restart: on-failure
    env_file: ./.env.dev
    command: tunnel --label edge=${NGROK_EDGE_GROUP} backend:8000
    ports:
      - 4040:4040
    environment:
      - NGROK_AUTHTOKEN=${NGROK_AUTHTOKEN}

But now I have a new project and now I am running the Linux shell using the docker-compose, and inside the shell I am running the command npm run dev to start my server inside the shell. I have tried to start my docke-compose using this Dockerfile setup:

RUN apt-get update && apt-get install -y wget \
    && wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip \
    && unzip ngrok-stable-linux-amd64.zip \
    && mv ngrok /usr/local/bin/ngrok \
    && rm ngrok-stable-linux-amd64.zip

COPY .env.docker /app/.env.docker

EXPOSE 3001
EXPOSE 4040

ENV NGROK_AUTHTOKEN=${NGROK_AUTHTOKEN}
ENV NGROK_EDGE_GROUP=${NGROK_EDGE_GROUP}

But unfortunately this attempt was a fail. Also I have tried to run this command ngrok tunnel --label edge=${NGROK_EDGE_GROUP} 8000 inside the shell directly, but got the error like 'Unknown command "tunnel"'. Will be very appreciated for the solution!

4
  • 1
    You missed RUN docker command to run ngrok. Try the next: RUN ngrok tunnel --label edge=${NGROK_EDGE_GROUP} http 8000 --authtoken=${NGROK_AUTHTOKEN}"] Commented Jun 5, 2024 at 7:46
  • 1
    Or even better - try ready-to-use scenario github.com/shkoliar/docker-ngrok Commented Jun 5, 2024 at 7:47
  • 1
    You can't RUN background processes in a Dockerfile. In most cases it's better to run only one process in a container (you should not need to manually run commands inside containers). Can you run the ngrok tunnel in a separate container alongside your main application container? Commented Jun 5, 2024 at 9:20
  • @DavidMaze I have tried to do this. This is a part of my docker compose: ngrok: image: ngrok/ngrok:latest restart: on-failure env_file: ./.env.docker command: tunnel --label edge=${NGROK_EDGE_GROUP} app:3001 ports: - 4040:4040 environment: - NGROK_AUTHTOKEN=${NGROK_AUTHTOKEN} networks: - local And it doesn't work Commented Jun 5, 2024 at 12:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.