update
This commit is contained in:
parent
4ec4be1ecd
commit
bf14e3946b
4 changed files with 196 additions and 0 deletions
32
Dockerfile
Normal file
32
Dockerfile
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
FROM alpine as ngrok
|
||||||
|
|
||||||
|
RUN apk add --no-cache --virtual .bootstrap-deps ca-certificates && \
|
||||||
|
wget -O /tmp/ngrok.zip https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip && \
|
||||||
|
unzip -o /tmp/ngrok.zip -d / && \
|
||||||
|
apk del .bootstrap-deps && \
|
||||||
|
rm -rf /tmp/* && \
|
||||||
|
rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
|
FROM busybox:glibc
|
||||||
|
|
||||||
|
LABEL org.opencontainers.image.description="Ngrok" \
|
||||||
|
org.opencontainers.image.authors="HHF Technology (https://forum.hhf.technology/)" \
|
||||||
|
org.opencontainers.image.url="https://git.hhf.technology/hhf/docker-ngrok" \
|
||||||
|
org.opencontainers.image.documentation="https://git.hhf.technology/hhf/docker-ngrok" \
|
||||||
|
org.opencontainers.image.source="https://git.hhf.technology/hhf/docker-ngrok"
|
||||||
|
|
||||||
|
COPY --from=ngrok /ngrok /bin/ngrok
|
||||||
|
COPY start.sh /
|
||||||
|
|
||||||
|
RUN mkdir -p /home/ngrok /home/ngrok/.ngrok2 && \
|
||||||
|
printf 'web_addr: 0.0.0.0:4551' > /home/ngrok/.ngrok2/ngrok.yml && \
|
||||||
|
addgroup -g 4551 -S ngrok && \
|
||||||
|
adduser -u 4551 -S ngrok -G ngrok -h /home/ngrok -s /bin/ash && \
|
||||||
|
chown -R ngrok:ngrok /home/ngrok && \
|
||||||
|
chmod +x /start.sh
|
||||||
|
|
||||||
|
USER ngrok:ngrok
|
||||||
|
|
||||||
|
EXPOSE 4551
|
||||||
|
|
||||||
|
ENTRYPOINT ["/start.sh"]
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Dmitry Shkoliar
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
90
README.md
90
README.md
|
@ -0,0 +1,90 @@
|
||||||
|
# Docker Ngrok
|
||||||
|
|
||||||
|
A Docker image for [ngrok](https://ngrok.com) service to expose a local docker environment or any other local server to the public internet over secure tunnels. The image is built using official [busybox:glibc](https://hub.docker.com/_/busybox) docker image, so no third party libraries are used, only official busybox and ngrok binary.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Command-line
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
The example below assumes that you have running web server docker container named `dev_web_1` with exposed port `80`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -it --link dev_web_1 hhftechnologies/ngrok http dev_web_1:80
|
||||||
|
```
|
||||||
|
|
||||||
|
With command line usage, ngrok session is active until it won't be terminated by `Ctrl+C` combination.
|
||||||
|
|
||||||
|
#### Command details
|
||||||
|
|
||||||
|
**Using ngrok parameters**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -it --link <web-container-name> [--net <default-netowrk-name>] hhftechnologies/ngrok <ngrok-parameters> <web-container-name>:<port>
|
||||||
|
```
|
||||||
|
|
||||||
|
For information about ngrok parameters, please refer to [ngrok documentation](https://ngrok.com/docs).
|
||||||
|
|
||||||
|
**Passing parameters to ngrok via env variables**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -it --link <web-container-name> [--net <default-netowrk-name>] --env DOMAIN=<web-container-name> --env PORT=<port> hhftechnologies/ngrok
|
||||||
|
```
|
||||||
|
|
||||||
|
Available env variables can be found below, at [environment variables](#environment-variables) section.
|
||||||
|
|
||||||
|
#### Troubleshooting
|
||||||
|
|
||||||
|
_If you are getting an error like_
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker: Error response from daemon: Cannot link to /dev_web_1, as it does not belong to the default network.
|
||||||
|
```
|
||||||
|
|
||||||
|
_You need to specify default docker network, for example_
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -it --link dev_web_1 --net dev_default hhftechnologies/ngrok http dev_web_1:80
|
||||||
|
```
|
||||||
|
|
||||||
|
### As part of docker-compose.yml file
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
ngrok:
|
||||||
|
image: hhftechnologies/ngrok:latest
|
||||||
|
ports:
|
||||||
|
- 4551:4551
|
||||||
|
links:
|
||||||
|
- web
|
||||||
|
environment:
|
||||||
|
- DOMAIN=web
|
||||||
|
- PORT=80
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `web` in example above is a web server service name of this docker-compose.yml file.
|
||||||
|
|
||||||
|
If ngrok container is created as part of docker-compose.yml file, ngrok session is active while container is running. To restart or stop session, you will need to restart or stop container respectively.
|
||||||
|
Ngrok web interface available at `http://localhost:4551`.
|
||||||
|
|
||||||
|
## Environment variables
|
||||||
|
|
||||||
|
List of available environment variables to configure ngrok in command line usage or as part of docker-compose.yml file.
|
||||||
|
|
||||||
|
| Name | Values | Default | Information |
|
||||||
|
| :---------- | :------------------------- | :-------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| PROTOCOL | http, tls, tcp | http | Ngrok tunneling protocol. |
|
||||||
|
| DOMAIN | \* | localhost | Hostname or docker container, service name which is referred to by ngrok. |
|
||||||
|
| PORT | \* | 80 | Port which is referred to by ngrok. |
|
||||||
|
| REGION | us, eu, ap, au, sa, jp, in | us | Region where the ngrok client will connect to host its tunnels. |
|
||||||
|
| HOST_HEADER | \* | | Optional, rewrite incoming HTTP requests with a modified Host header. e.g. `HOST_HEADER=localdev.test` |
|
||||||
|
| BIND_TLS | true, false | | Optional, forward only HTTP or HTTPS traffic, but not both. By default, when ngrok runs an HTTP tunnel, it opens endpoints for both HTTP and HTTPS traffic. |
|
||||||
|
| SUBDOMAIN | \* | | Optional, specifies the subdomain to use with ngrok, if unspecified ngrok with generate a unique subdomain on each start. |
|
||||||
|
| AUTH_TOKEN | \* | | Optional, token used to authorise your subdomain with ngrok. |
|
||||||
|
| DEBUG | true | | Optional, write logs to stdout. |
|
||||||
|
| PARAMS | \* | | Pass all ngrok parameters by one string. When specified, any other env variables are skipped (Except AUTH_TOKEN).|
|
||||||
|
|
||||||
|
For more information about ngrok parameters, please refer to [ngrok documentation](https://ngrok.com/docs).
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT](../../blob/master/LICENSE)
|
53
start.sh
Normal file
53
start.sh
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
CMD="ngrok"
|
||||||
|
|
||||||
|
$CMD authtoken ${AUTH_TOKEN:-''} > /dev/null
|
||||||
|
|
||||||
|
PARAMS=${PARAMS:-$(echo $@)}
|
||||||
|
|
||||||
|
if [[ -n "$PARAMS" ]]; then
|
||||||
|
if [[ "$PARAMS" == "$CMD "* ]]; then
|
||||||
|
CMD="$PARAMS"
|
||||||
|
else
|
||||||
|
CMD="$CMD $PARAMS"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
PROTOCOL=${PROTOCOL:-http}
|
||||||
|
PORT=${PORT:-80}
|
||||||
|
|
||||||
|
CMD="$CMD $PROTOCOL"
|
||||||
|
|
||||||
|
if [[ -n "$REGION" ]]; then
|
||||||
|
CMD="$CMD -region=$REGION"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$HOST_HEADER" ]]; then
|
||||||
|
CMD="$CMD -host-header=$HOST_HEADER"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$BIND_TLS" ]]; then
|
||||||
|
CMD="$CMD -bind-tls=$BIND_TLS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$SUBDOMAIN" ]]; then
|
||||||
|
CMD="$CMD -subdomain=$SUBDOMAIN"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$BASICAUTH" ]]; then
|
||||||
|
CMD="$CMD --auth=$BASICAUTH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$DEBUG" ]]; then
|
||||||
|
CMD="$CMD -log stdout"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$DOMAIN" ]]; then
|
||||||
|
CMD="$CMD $DOMAIN:$PORT"
|
||||||
|
else
|
||||||
|
CMD="$CMD $PORT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -x
|
||||||
|
exec $CMD
|
Loading…
Reference in a new issue