Merge pull request #6 from aykhans/feat/add-dockerfile

Add Dockerfile
This commit is contained in:
Aykhan Shahsuvarov 2024-07-26 00:09:08 +04:00 committed by GitHub
commit 0ab6ca098d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 53 additions and 3 deletions

10
.dockerignore Normal file
View File

@ -0,0 +1,10 @@
.github
assets
binaries
dodo
.git
.gitignore
README.md
LICENSE
config.json
build.sh

20
Dockerfile Normal file
View File

@ -0,0 +1,20 @@
FROM golang:1.22.5-alpine AS builder
WORKDIR /dodo
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -o dodo
RUN echo "{}" > config.json
FROM gcr.io/distroless/static-debian12:latest
WORKDIR /dodo
COPY --from=builder /dodo/dodo /dodo/dodo
COPY --from=builder /dodo/config.json /dodo/config.json
ENTRYPOINT ["./dodo", "-c", "/dodo/config.json"]
CMD []

View File

@ -4,10 +4,19 @@
</p> </p>
## Installation ## Installation
### With Docker (Recommended)
Pull the Dodo image from Docker Hub:
```sh
docker pull aykhans/dodo:latest
```
If you use Dodo with Docker and a config file, you must provide the config.json file as a volume to the Docker run command (not as the "-c config.json" argument), as shown in the examples in the [usage](#usage) section.
### With Binary File
You can grab binaries in the [releases](https://github.com/aykhans/dodo/releases) section. You can grab binaries in the [releases](https://github.com/aykhans/dodo/releases) section.
### Build from Source ### Build from Source
To build Dodo from source, you need to have [Go1.22+](https://golang.org/dl/) installed. Follow the steps below: To build Dodo from source, you need to have [Go1.22+](https://golang.org/dl/) installed. <br>
Follow the steps below to build dodo:
1. **Clone the repository:** 1. **Clone the repository:**
@ -38,6 +47,10 @@ Send 1000 GET requests to https://example.com with 10 parallel dodos (threads) a
```sh ```sh
dodo -u https://example.com -m GET -d 10 -r 1000 -t 2000 dodo -u https://example.com -m GET -d 10 -r 1000 -t 2000
``` ```
With Docker:
```sh
docker run --rm aykhans/dodo -u https://example.com -m GET -d 10 -r 1000 -t 2000
```
### 2. JSON config file ### 2. JSON config file
You can find an example config structure in the [config.json](https://github.com/aykhans/dodo/blob/main/config.json) file: You can find an example config structure in the [config.json](https://github.com/aykhans/dodo/blob/main/config.json) file:
@ -69,6 +82,10 @@ Send 1000 GET requests to https://example.com with 5 parallel dodos (threads) an
```sh ```sh
dodo -c /path/config.json dodo -c /path/config.json
``` ```
With Docker:
```sh
docker run --rm -v ./path/config.json:/dodo/config.json -i aykhans/dodo
```
### 3. Both (CLI & JSON) ### 3. Both (CLI & JSON)
Override the config file arguments with CLI arguments: Override the config file arguments with CLI arguments:
@ -76,6 +93,10 @@ Override the config file arguments with CLI arguments:
```sh ```sh
dodo -c /path/config.json -u https://example.com -m GET -d 10 -r 1000 -t 2000 dodo -c /path/config.json -u https://example.com -m GET -d 10 -r 1000 -t 2000
``` ```
With Docker:
```sh
docker run --rm -v ./path/config.json:/dodo/config.json -i aykhans/dodo -u https://example.com -m GET -d 10 -r 1000 -t 2000
```
## CLI and JSON Config Parameters ## CLI and JSON Config Parameters
| Parameter | JSON config file | CLI Flag | CLI Short Flag | Type | Description | Default | | Parameter | JSON config file | CLI Flag | CLI Short Flag | Type | Description | Default |
@ -94,4 +115,3 @@ dodo -c /path/config.json -u https://example.com -m GET -d 10 -r 1000 -t 2000
## Examples ## Examples
![dodo_example](https://raw.githubusercontent.com/aykhans/dodo/main/assets/dodo-example.gif) ![dodo_example](https://raw.githubusercontent.com/aykhans/dodo/main/assets/dodo-example.gif)