Skip to content

Instantly share code, notes, and snippets.

@OldhamMade
Created October 11, 2017 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OldhamMade/a0da67ba450aa391145d2f0b41f8988c to your computer and use it in GitHub Desktop.
Save OldhamMade/a0da67ba450aa391145d2f0b41f8988c to your computer and use it in GitHub Desktop.
Kemal error under docker

To reproduce

Spin up your docker environment, then run the following:

$ docker build -t my/kemaltest .
$ docker run -p 8080:8080 -it my/kemaltest

Run the following inside the container, and then hit the docker machine's IP on port 8080 in a browser. You should see a "Hello World" message.

/app # ./test

If you do, CTRL-C to stop kemal, then run again. Repeat, and eventually you should see the following error:

[production] Kemal is ready to lead at http://0.0.0.0:8080
accept: Invalid argument (Errno)
0x560bb97ebf75: run at /usr/lib/crystal/src/io/file_descriptor.cr 297:7
0x560bb978c606: main at /app/lib/kemal/src/kemal.cr 19:5
0x7f12462c8964: trap at /usr/lib/crystal/src/pointer.cr 129:6
FROM alpine
ENV APP_PORT 8080
ENV KEMAL_ENV production
EXPOSE $APP_PORT
ENV PACKAGES="\
wget \
ca-certificates \
linux-headers \
openssl-dev \
git \
gcc \
tini \
"
RUN set -x && \
apk update && \
apk upgrade && \
apk add --no-cache $PACKAGES
RUN echo "http://public.portalier.com/alpine/testing" >> /etc/apk/repositories && \
wget -nv "http://public.portalier.com/alpine/julien%40portalier.com-56dab02e.rsa.pub" \
-O /etc/apk/keys/julien@portalier.com-56dab02e.rsa.pub
RUN apk add --no-cache crystal shards
RUN echo "System Info: " && uname -a && /usr/bin/crystal -v && /usr/bin/crystal env
RUN mkdir /app
COPY . /app/
WORKDIR /app
RUN /usr/bin/crystal deps
RUN /usr/bin/crystal build test.cr --release
ENTRYPOINT /bin/sh
require "kemal"
Kemal.config.port = 8080
get "/" do
"Hello World!"
end
Kemal.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment