Skip to content

Commit

Permalink
Merge branch 'main' of github.com:friendsofgo/killgrave into acceptance
Browse files Browse the repository at this point in the history
  • Loading branch information
joanlopez committed Nov 7, 2024
2 parents 24bb26a + bca67fd commit 4265695
Show file tree
Hide file tree
Showing 18 changed files with 475 additions and 312 deletions.
25 changes: 20 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,36 @@ jobs:
GH_RELEASER: ${{ secrets.GH_RELEASER }}
docker-hub:
needs: release
name: Deploy to docker-hub
name: Deploy to DockerHub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Login to docker hub
uses: docker/login-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ github.repository }}
tags: |
type=ref,event=tag
- name: Build and push to docker registry
if: success()
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${GITHUB_REPOSITORY}:latest,${GITHUB_REPOSITORY}:${IMAGE_TAG}
tags: ${{ steps.meta.outputs.tags }}
11 changes: 7 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ builds:
- goos: freebsd
goarch: arm64
archives:
-
replacements:
386: i386
amd64: x86_64
-
name_template: >-
{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
format_overrides:
- goos: windows
format: zip
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
FROM golang:1.16-alpine AS build
FROM golang:1.21-alpine AS build

LABEL MAINTAINER = 'Friends of Go ([email protected])'

ARG TARGETOS=linux
ARG TARGETARCH=amd64

RUN apk add --update git
RUN apk add ca-certificates
WORKDIR /go/src/github.com/friendsofgo/killgrave
COPY . .
RUN go mod tidy && TAG=$(git describe --tags --abbrev=0) \
&& LDFLAGS=$(echo "-s -w -X github.com/friendsofgo/killgrave/internal/app/cmd._version="docker-$TAG) \
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o /go/bin/killgrave -ldflags "$LDFLAGS" cmd/killgrave/main.go
&& CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" go build -a -installsuffix cgo -o /go/bin/killgrave -ldflags "$LDFLAGS" cmd/killgrave/main.go

# Building image with the binary
FROM scratch
Expand Down
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ Killgrave is a simulator for HTTP-based APIs, in simple words a **Mock Server**,
![Github actions](https://github.com/friendsofgo/killgrave/actions/workflows/main.yaml/badge.svg?branch=main)
[![Version](https://img.shields.io/github/release/friendsofgo/killgrave.svg?style=flat-square)](https://github.com/friendsofgo/killgrave/releases/latest)
[![Go Report Card](https://goreportcard.com/badge/github.com/friendsofgo/killgrave)](https://goreportcard.com/report/github.com/friendsofgo/killgrave)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/friendsofgo/killgrave.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/friendsofgo/killgrave/alerts/)
[![FriendsOfGo](https://img.shields.io/badge/powered%20by-Friends%20of%20Go-73D7E2.svg)](https://friendsofgo.tech)

<p>
<a href="https://www.buymeacoffee.com/friendsofgo" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: 100px !important;" ></a>
</p>

# Table of Content
- [Overview](#overview)
- [Concepts](#concepts)
Expand Down Expand Up @@ -91,13 +86,13 @@ $ brew install friendsofgo/tap/killgrave
The application is also available through [Docker](https://hub.docker.com/r/friendsofgo/killgrave).

```bash
docker run -it --rm -p 3000:3000 -v $PWD/:/home -w /home friendsofgo/killgrave -host 0.0.0.0
docker run -it --rm -p 3000:3000 -v $PWD/:/home -w /home friendsofgo/killgrave --host 0.0.0.0
```

`-p 3000:3000` [publishes](https://docs.docker.com/engine/reference/run/#expose-incoming-ports) port 3000 (Killgrave's default port) inside the
container to port 3000 on the host machine.

`-host 0.0.0.0` is necessary to allow Killgrave to listen and respond to requests from outside the container (the default,
`--host 0.0.0.0` is necessary to allow Killgrave to listen and respond to requests from outside the container (the default,
`localhost`, will not capture requests from the host network).

### Compile by yourself
Expand Down
24 changes: 16 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
module github.com/friendsofgo/killgrave

go 1.16
go 1.21

require (
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/gorilla/mux v1.8.1
github.com/radovskyb/watcher v1.0.7
github.com/spf13/afero v1.6.0
github.com/spf13/cobra v1.0.0
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
github.com/xeipuuv/gojsonschema v1.2.0
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.7.0
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/tools v0.9.1
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 4265695

Please sign in to comment.