From 1b450c08a2e79e631e56c674d6a584533d776fc5 Mon Sep 17 00:00:00 2001 From: ycc Date: Wed, 18 Oct 2023 15:24:57 +0200 Subject: [PATCH] dockerfile with swagger integration --- Dockerfile | 7 +++++++ docker-compose.yml | 10 ++++++++++ main.go | 8 ++++---- 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index 276971b..9072371 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,12 @@ COPY . . RUN apk add git +RUN go get github.com/beego/bee/v2 && go install github.com/beego/bee/v2@master + +RUN timeout 15 bee run -gendoc=true -downdoc=true -runmode=dev || : + +RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' swagger/index.html + RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" . RUN ls /app @@ -15,6 +21,7 @@ FROM scratch WORKDIR /app COPY --from=builder /app/oc-discovery /usr/bin/ +COPY --from=builder /app/swagger /app/swagger COPY peers.json /app/ COPY identity.json /app/ COPY docker_discovery.json /etc/oc/discovery.json diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..06251bd --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.4' + +services: + ocdiscovery: + image: 'ocdiscovery:latest' + ports: + - 8088:8080 + container_name: ocdiscovery + + \ No newline at end of file diff --git a/main.go b/main.go index 4e316b6..fb5809f 100644 --- a/main.go +++ b/main.go @@ -49,9 +49,9 @@ func main() { models.GetConfig().Defaultpeers = o.GetStringDefault("defaultpeers", "./peers.json") // Normal beego init - if beego.BConfig.RunMode == "dev" { - beego.BConfig.WebConfig.DirectoryIndex = true - beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger" - } + //if beego.BConfig.RunMode == "dev" { + beego.BConfig.WebConfig.DirectoryIndex = true + beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger" + //} beego.Run() }