Skip to content

Commit

Permalink
Merge pull request #850 from swagger-api/codegen-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 e4153e3 + e75cb7c commit a42e898
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 @@ -98,6 +98,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 src/main/resources/handlebars/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 a42e898

Please sign in to comment.