Skip to content

Commit

Permalink
Add Docker Image and CircleCI (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlysan authored Jun 7, 2021
1 parent e8474c1 commit 6ea2cf7
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 6 deletions.
27 changes: 27 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# .circleci/config.yml
version: 2.1
workflows:
main:
jobs:
- release:
# Only run this job on git tag pushes
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
jobs:
release:
docker:
- image: circleci/golang:1.16
steps:
- checkout
- setup_remote_docker:
version: 19.03.13
- run: echo "$DOCKER_TOKEN" | docker login --username $DOCKER_USERNAME --password-stdin
# Generate binaries for Github
- run: curl -sL https://git.io/goreleaser | bash
# Generate Docker Image
- run: docker build -t charlysan/gidm:$CIRCLE_TAG .
- run: docker tag charlysan/gidm:$CIRCLE_TAG charlysan/gidm:latest
- run: docker push charlysan/gidm
5 changes: 5 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dockers:
- goarch: arm64
- goos: linux
- image_templates:
- charlysan/gidm
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ARG GO_VERSION=1.15
ARG ALPINE_VERSION=3.13.0

FROM golang:${GO_VERSION}-alpine AS builder

RUN mkdir -p /app
ADD . /app
WORKDIR /app

RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /gidm main.go

# Create alpine runtime image
FROM alpine:${ALPINE_VERSION} as app

COPY --from=builder /gidm /gidm

USER 1000

ENTRYPOINT ["/gidm"]
46 changes: 40 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,34 @@ Simple http proxy man-in-the-middle tool

`gidm` is a minimalist http proxy that can be used as "man-in-the-middle" tool capable of manipulating requests and responses.

## Requirements
## Installation

`GO v1.15` or greater
### Build from source

## Installation
[GO v1.15](https://golang.org/doc/go1.15) or greater is required. Just clone this repo and build as usual:

```
go build
```

Just clone this repo and build & install as usual:
Or build & install:

```
go install
```

### Download release binaries

You can also download Linux and MacOS pre-built binaries from [releases section](https://github.com/charlysan/gidm/releases).

### Docker Image

Docker image is also available from [DockerHub](https://hub.docker.com/repository/docker/charlysan/gidm). You will find some examples in [Examples Section](#run-using-docker).


## Usage

You can run the tool with `--help` option to get a list of supported commands:
You can run the tool along with `--help` option to get a list of supported commands:

```bash
$ ./gidm --help
Expand Down Expand Up @@ -48,7 +61,7 @@ GLOBAL OPTIONS:

### Inject Request Headers

Listen on port `8081` and forward to `http://localhost:9000`; show debug information and inject the following headers:
Listen on port `8081` and forward to `http://localhost:9000`, show debug information and inject the following headers:
- `x-custom-flag: true`
- `x-custom-id: 12345`

Expand Down Expand Up @@ -149,3 +162,24 @@ And the proxy should show the following log:
Response Body string replacers updated
ok -> WRONG!!
```

## Run using Docker

Grab Docker image from [DockerHub](https://hub.docker.com/repository/docker/charlysan/gidm):

```
docker pull charlysan/gidm
```

Run and add the proper port-forwarding:

```
docker run \
-p 8081:8080 \
-p 9090:9090 \
charlysan/gidm \
-u https://api.chucknorris.io \
-resb "/Chuck Norris/John Doe/" \
-i 9090 \
-d
```

0 comments on commit 6ea2cf7

Please sign in to comment.