Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Tim Möhlmann
c43d0e7295 feat: add docker file for static server example 2023-03-28 16:43:25 +03:00
2 changed files with 23 additions and 3 deletions

View file

@ -4,6 +4,7 @@ import (
"fmt"
"log"
"net/http"
"os"
"github.com/zitadel/oidc/v2/example/server/exampleop"
"github.com/zitadel/oidc/v2/example/server/storage"
@ -12,8 +13,12 @@ import (
func main() {
//we will run on :9998
port := "9998"
issuer, ok := os.LookupEnv("ISSUER")
if !ok {
//which gives us the issuer: http://localhost:9998/
issuer := fmt.Sprintf("http://localhost:%s/", port)
issuer = fmt.Sprintf("http://localhost:%s/", port)
}
// the OpenIDProvider interface needs a Storage interface handling various checks and state manipulations
// this might be the layer for accessing your database
@ -26,7 +31,7 @@ func main() {
Addr: ":" + port,
Handler: router,
}
log.Printf("server listening on http://localhost:%s/", port)
log.Printf("server listening on %s", issuer)
log.Println("press ctrl+c to stop")
err := server.ListenAndServe()
if err != nil {

15
static-op.Dockerfile Normal file
View file

@ -0,0 +1,15 @@
FROM golang:latest as build
COPY go.mod go.sum /build/
WORKDIR /build
RUN go mod download -x
COPY . /build/
RUN go build ./example/server
FROM busybox:glibc
COPY --from=build /build/server /usr/local/bin/server
ENV ISSUER=http://localhost:9998/
EXPOSE 9998
CMD [ "/usr/local/bin/server" ]