Skip to content

Commit

Permalink
Merge pull request #10863 from swagger-api/issue-8320
Browse files Browse the repository at this point in the history
added docker file for go-server generator
  • Loading branch information
HugoMario authored Jan 20, 2021
2 parents 4209313 + 72b19e6 commit 3eab3a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void processOpts() {
* it will be processed by the template engine. Otherwise, it will be copied
*/
supportingFiles.add(new SupportingFile("swagger.mustache", "api", "swagger.yaml"));
supportingFiles.add(new SupportingFile("Dockerfile", "", "Dockerfile"));
supportingFiles.add(new SupportingFile("main.mustache", "", "main.go"));
supportingFiles.add(new SupportingFile("routers.mustache", apiPath, "routers.go"));
supportingFiles.add(new SupportingFile("logger.mustache", apiPath, "logger.go"));
Expand Down
14 changes: 14 additions & 0 deletions modules/swagger-codegen/src/main/resources/go-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM golang:1.10 AS build
WORKDIR /go/src
COPY go ./go
COPY main.go .

ENV CGO_ENABLED=0
RUN go get -d -v ./...

RUN go build -a -installsuffix cgo -o swagger .

FROM scratch AS runtime
COPY --from=build /go/src/swagger ./
EXPOSE 8080/tcp
ENTRYPOINT ["./swagger"]

0 comments on commit 3eab3a6

Please sign in to comment.