docs icon indicating copy to clipboard operation
docs copied to clipboard

Go websocket not working in oathkeeper example

Open Gawise opened this issue 3 years ago • 2 comments

Preflight checklist

Describe the bug

The go websocket container called ws in the oathkeeper example fails to build. The logs are saying that the executable in the Dockerfile's entrypoint doesn't exist.

Reproducing the bug

  1. Run cd code-examples/oathkeeper
  2. Run docker compose up --build
  3. Go to http://127.0.0.1:4455 and create an account
  4. Go to http://127.0.0.1:8080

Relevant log output

Attaching to oathkeeper-kratos-1, oathkeeper-kratos-migrate-1, oathkeeper-kratos-selfservice-ui-node-1, oathkeeper-mailslurper-1, oathkeeper-oathkeeper-1, oathkeeper-postgres-kratos-1, oathkeeper-ws-1
oathkeeper-ws-1                          | exec /ws: no such file or directory
oathkeeper-mailslurper-1                 | time="2022-11-22T23:44:31Z" level=info msg="Starting MailSlurper Server v1.14.1" who=MailSlurper

Relevant configuration

No response

Version

master

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Docker Compose

Additional Context

I ran it on WSL but it failed on Docker Desktop for Windows too.

Gawise avatar Nov 22 '22 23:11 Gawise

I'm not very proficient at golang, but it seems like the problem is that the go build is made at a stage with a 'golang' base image, but is then run on a different 'alpine' image. I managed to make it work by doing everything in a 'golang:alpine' image like so: `FROM golang:alpine

RUN mkdir /build

ADD . /build

WORKDIR /build

RUN GOOS=linux GOARCH=amd64 go build -o ws main.go

EXPOSE 8090

CMD ["/build/ws"]`

Gawise avatar Nov 23 '22 00:11 Gawise

Another fix is to switch out the image used in the second stage to debian. Are there any plans to fix the guide though?

netthier avatar Jun 14 '23 14:06 netthier