From 2f212322de602d1e7bd3432de3374288a43d821c Mon Sep 17 00:00:00 2001 From: rick <1450685+LinuxSuRen@users.noreply.github.com> Date: Thu, 8 Jun 2023 16:47:15 +0800 Subject: [PATCH 1/2] feat: put atest-collector into the image --- .github/workflows/release.yaml | 2 ++ Dockerfile | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 31f3e427..8c953b87 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -4,6 +4,8 @@ on: push: tags: - '*' + branches: + - master env: REGISTRY: ghcr.io diff --git a/Dockerfile b/Dockerfile index f0e9d5df..863c33d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM golang:1.18 AS builder WORKDIR /workspace COPY cmd/ cmd/ COPY pkg/ pkg/ +COPY extensions/ extensions/ COPY sample/ sample/ COPY go.mod go.mod COPY go.sum go.sum @@ -12,6 +13,7 @@ COPY LICENSE LICENSE RUN go mod download RUN CGO_ENABLE=0 go build -ldflags "-w -s" -o atest . +RUN CGO_ENABLE=0 go build -ldflags "-w -s" -o atest-collector extensions/collector/main.go FROM ubuntu:23.04 @@ -27,6 +29,7 @@ LABEL "maintainer"="Rick " LABEL "Name"="API testing" COPY --from=builder /workspace/atest /usr/local/bin/atest +COPY --from=builder /workspace/atest /usr/local/bin/atest-collector COPY --from=builder /workspace/LICENSE /LICENSE COPY --from=builder /workspace/README.md /README.md From a0f573cb0e2a7fe19e9a86d0a6ea324a62dea456 Mon Sep 17 00:00:00 2001 From: rick <1450685+LinuxSuRen@users.noreply.github.com> Date: Thu, 8 Jun 2023 17:16:45 +0800 Subject: [PATCH 2/2] doc: add instructions about how to use in Docker --- Dockerfile | 4 +++- README.md | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 863c33d5..c0e56604 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,8 @@ COPY extensions/ extensions/ COPY sample/ sample/ COPY go.mod go.mod COPY go.sum go.sum +COPY go.work go.work +COPY go.work.sum go.work.sum COPY main.go main.go COPY README.md README.md COPY LICENSE LICENSE @@ -29,7 +31,7 @@ LABEL "maintainer"="Rick " LABEL "Name"="API testing" COPY --from=builder /workspace/atest /usr/local/bin/atest -COPY --from=builder /workspace/atest /usr/local/bin/atest-collector +COPY --from=builder /workspace/atest-collector /usr/local/bin/atest-collector COPY --from=builder /workspace/LICENSE /LICENSE COPY --from=builder /workspace/README.md /README.md diff --git a/README.md b/README.md index c6cb33a9..657599fb 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,23 @@ below is an example of the usage, and you could see the report as well: | GET https://gitlab.com/api/v4/projects/45088772 | 840.761064ms | 1.487285371s | 492.583066ms | 10 | 0 | consume: 1m2.153686448s +## Use in Docker + +Use `atest` as server mode in Docker: +``` +docker run -p 7070:7070 ghcr.io/linuxsuren/api-testing +``` + +Use `atest-collector` in Docker: +```shell +docker run -p 1234:8080 -v /var/tmp:/var/tmp \ + ghcr.io/linuxsuren/api-testing atest-collector \ + --filter-path /api \ + -o /var/tmp/sample.yaml +# you could find the test cases file from /var/tmp/sample +# cat /var/tmp/sample +``` + ## Template The following fields are templated with [sprig](http://masterminds.github.io/sprig/):