Skip to content

Commit 72b19e6

Browse files
committed
added docker file for go-server generator
1 parent 4209313 commit 72b19e6

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoServerCodegen.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public void processOpts() {
100100
* it will be processed by the template engine. Otherwise, it will be copied
101101
*/
102102
supportingFiles.add(new SupportingFile("swagger.mustache", "api", "swagger.yaml"));
103+
supportingFiles.add(new SupportingFile("Dockerfile", "", "Dockerfile"));
103104
supportingFiles.add(new SupportingFile("main.mustache", "", "main.go"));
104105
supportingFiles.add(new SupportingFile("routers.mustache", apiPath, "routers.go"));
105106
supportingFiles.add(new SupportingFile("logger.mustache", apiPath, "logger.go"));
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM golang:1.10 AS build
2+
WORKDIR /go/src
3+
COPY go ./go
4+
COPY main.go .
5+
6+
ENV CGO_ENABLED=0
7+
RUN go get -d -v ./...
8+
9+
RUN go build -a -installsuffix cgo -o swagger .
10+
11+
FROM scratch AS runtime
12+
COPY --from=build /go/src/swagger ./
13+
EXPOSE 8080/tcp
14+
ENTRYPOINT ["./swagger"]

0 commit comments

Comments
 (0)