wernight / docker-ngrok

An Ngrok v2 container based on wizardapps/ngrok and fnichol/ngrok
https://hub.docker.com/r/wernight/ngrok/
MIT License
456 stars 143 forks source link

Feature request NGROK_CONFIG #33

Open lcherone opened 5 years ago

lcherone commented 5 years ago

Then can just pass the config path and run it, this way can run multiple tunnels.

aaabramov commented 5 years ago

This will help also expose 4040 port to debug requests remotely without port forwarding.

ghost commented 3 years ago

yes, this would be awesome.

lcherone commented 3 years ago

A solution I used, ill share here in case anyone is interested in doing/needing the same.

Make a folder called ngrok and put in the following files:

Dockerfile

FROM alpine:3.9

RUN set -x && \
    apk add --no-cache -t .deps ca-certificates && \
    # Install glibc on Alpine (required by docker-compose) from
    # https://github.com/sgerrand/alpine-pkg-glibc
    # See also https://github.com/gliderlabs/docker-alpine/issues/11
    wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
    wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.29-r0/glibc-2.29-r0.apk && \
    apk add glibc-2.29-r0.apk && \
    rm glibc-2.29-r0.apk && \
    apk del --purge .deps

RUN set -x \
    # Install ngrok (latest official stable from https://ngrok.com/download).
    && apk add --no-cache curl \
    && curl -Lo /ngrok.zip https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip \
    && unzip -o /ngrok.zip -d /bin \
    && rm -f /ngrok.zip \
    # Create non-root user.
    && adduser -h /home/ngrok -D -u 6737 ngrok

RUN  ngrok --version

# Add config script.
COPY --chown=ngrok ngrok.yml /home/ngrok/.ngrok2/
COPY entrypoint.sh /

USER ngrok
ENV USER=ngrok

EXPOSE 4040

ENTRYPOINT ["/entrypoint.sh"]

entrypoint.sh

#!/bin/sh -e

if [ -n "$@" ]; then
  exec "$@"
fi

ARGS="ngrok start --all -config=/home/ngrok/.ngrok2/ngrok.yml"

set -x
exec $ARGS

Then your ngrok.yml config, which you could mount in with a volume to override (/home/ngrok/.ngrok2/ngrok.yml), or this file is the default.

authtoken: ...
#region: eu
web_addr: 0.0.0.0:4040
tunnels:
    app:
        proto: http
        addr: app:8080
        inspect: true

Then in docker-compose.yml, its just:

  ngrok:
    build: ./ngrok
    container_name: ngrok
    # example overide above with config from home
    #volumes:
    #  - ~/ngrok.yml:/home/ngrok/.ngrok2/ngrok.yml
    ports:
      - 4040:4040
    links: # prob not needed in > v2
      - app

app being, your app and would obviously be changed to suit your setup.

Hope it helps