Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Makefile #36

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.DS_Store
.DS_Store

# local environment
.env
47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
include .env
export


# Operating with simple Docker container
# --------------------------------------

run:
docker run -d -p ${TOR_ENTRY_PORT}:5566 -p ${HAPROXY_PORT}:4444 --env tors=${TOR_INSTANCES} --name ${CONTAINER_NAME} ${IMAGE_NAME}

ps:
docker ps -a | grep "${CONTAINER_NAME}"

log:
docker logs ${CONTAINER_NAME}

flog:
docker logs --follow ${CONTAINER_NAME}

stop:
docker stop ${CONTAINER_NAME}

rm:
docker rm ${CONTAINER_NAME}

remove:
make stop
make rm


# Operating with Docker service
# -----------------------------

service:
docker service create -p ${TOR_ENTRY_PORT}:5566 -p ${HAPROXY_PORT}:4444 --env tors=${TOR_INSTANCES} --name ${SERVICE_NAME} ${IMAGE_NAME}

service-ls:
docker service ls | grep "${SERVICE_NAME}"

service-log:
docker service logs ${SERVICE_NAME}

service-flog:
docker service logs --follow ${SERVICE_NAME}

service-rm:
docker service rm ${SERVICE_NAME}
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ curl --proxy 127.0.0.1:5566 http://header.jsontest.com
http://127.0.0.1:4444/haproxy?stats
```

Usage with make
---------------

1. Install `make` command line utility

2. Copy `example.env` as `.env` and edit settings

3. Use `make` commands
```bash
# start docker container
make run

# stop and remove container
make remove

# Alternatively, using Docker Service
make service
```

See `Makefile` for full list of available shortcuts.

Further Readings
----------------
Expand Down
18 changes: 18 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

# Docker image name
IMAGE_NAME=mattes/rotating-proxy

# Docker container name
CONTAINER_NAME=rotating-proxy

# Docker service name
SERVICE_NAME=rotating-proxy

# How many parallel Tor instances to create
TOR_INSTANCES=16

# Entry port for Tor (http proxy)
TOR_ENTRY_PORT=5566

# Haproxy monitoring port
HAPROXY_PORT=4444