wernight / docker-ngrok

An Ngrok v2 container based on wizardapps/ngrok and fnichol/ngrok

Home Page:https://hub.docker.com/r/wernight/ngrok/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request NGROK_CONFIG

lcherone opened this issue · comments

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

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

yes, this would be awesome.

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