Skip to content

Commit

Permalink
Merge pull request #18 from a0v0/a0v0-patch-1
Browse files Browse the repository at this point in the history
Dockerize  go-swagger3
  • Loading branch information
parvez3019 authored Apr 9, 2023
2 parents 60c9e86 + 182d306 commit 5a24e61
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
43 changes: 43 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Docker Build and Publish

on:
push:
tags:
- "*"

env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_USERNAME }}/go-swagger3
flavor: latest=true
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}

- name: Build and tag Docker image
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.ref_type == 'tag' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM golang:alpine
WORKDIR /go/src/main
RUN go install github.com/parvez3019/go-swagger3@latest

ENTRYPOINT ["go-swagger3"]
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ go install github.com/parvez3019/go-swagger3@latest


### 2. Documentation Generation

#### Using binary
Go to the folder where is main.go in

``` shell
Expand All @@ -53,6 +53,21 @@ Notes -

```
#### Using docker
``` shell
// go.mod and main file are in the same directory
docker run -t --rm -v $(pwd):/app -w /app parvez3019/go-swagger3:latest --module-path . --output oas.json --schema-without-pkg --generate-yaml true

// go.mod and main file are in the different directory
docker run -t --rm -v $(pwd):/app -w /app parvez3019/go-swagger3:latest --module-path . --main-file-path ./cmd/xxx/main.go --output oas.json --schema-without-pkg --generate-yaml true

Notes -
- Pass schema-without-pkg flag as true if you want to generate schemas without package names
- Pass generate-yaml as trus if you want to generate yaml spec file instead of json

```
## 3. Usage
Expand Down

0 comments on commit 5a24e61

Please sign in to comment.