CaliDog / certstream-server

Certificate Transparency Log aggregation, parsing, and streaming service written in Elixir
https://certstream.calidog.io
MIT License
271 stars 75 forks source link

Can't get server to run #120

Open kevbo-oh opened 8 months ago

kevbo-oh commented 8 months ago

I'm sorry, I'm going to ask stupid questions here.

I'm an old-school Linux admin/app developer. These days, mostly writing code in go. I don't know a thing about elixir or erlang. I also don't use Docker much.

I'm trying to get certstream-server to work, and can't.

At first, I tried to just run the code on a modern Fedora 39 install (Fedora because RHEL and clones don't have elixir available at all). Attempting to run the code in this repo on a modern Elixir fails miserably:

[kwhite@mock-f39 certstream-server]$ mix deps.get
warning: use Mix.Config is deprecated. Use the Config module instead
  config/config.exs:1

warning: Mix.Config.config/2 is deprecated. Use the Config module instead
  config/config.exs:3

warning: Mix.Config.config/2 is deprecated. Use the Config module instead
  config/config.exs:8

warning: Mix.Config.config/2 is deprecated. Use the Config module instead
  config/config.exs:12

warning: Mix.Config.config/2 is deprecated. Use the Config module instead
  config/config.exs:19

[kwhite@mock-f39 certstream-server]$ mix run --no-halt
warning: use Mix.Config is deprecated. Use the Config module instead
  config/config.exs:1

warning: Mix.Config.config/2 is deprecated. Use the Config module instead
  config/config.exs:3

warning: Mix.Config.config/2 is deprecated. Use the Config module instead
  config/config.exs:8

warning: Mix.Config.config/2 is deprecated. Use the Config module instead
  config/config.exs:12

warning: Mix.Config.config/2 is deprecated. Use the Config module instead
  config/config.exs:19

==> easy_ssl
Compiling 1 file (.ex)

== Compilation error in file lib/easy_ssl.ex ==
** (ArgumentError) lib file public_key/include/OTP-PUB-KEY.hrl could not be found
    (elixir 1.15.7) lib/record/extractor.ex:41: Record.Extractor.from_lib_file/1
    (elixir 1.15.7) lib/record/extractor.ex:18: Record.Extractor.from_or_from_lib_file/1
    (elixir 1.15.7) lib/record/extractor.ex:9: Record.Extractor.extract_all/1
    lib/easy_ssl.ex:10: (module)
could not compile dependency :easy_ssl, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile easy_ssl --force", update it with "mix deps.update easy_ssl" or clean it with "mix deps.clean easy_ssl"

I realize that 1.15 is a lot newer than the 1.8 specified in the Dockerfile. The most recent Fedora that has 1.8 is Fedora 31, which has been EOL for over 3 years. Since I don't know anything about Elixir, I have no idea how to get this package to run. I have no idea what newer version of Elixir should be expected to work.

So, it seems that moving to Docker would be the path of least resistance.

I tried with podman on Fedora 39, but had trouble. To remove podman from the equation, I decided to try real docker on Debian 12. I ended up having exactly the same problems in docker, documented as follows.

I installed a Debian 12 VM, did 'apt-get install docker.io', then this:

sudo docker build .
kwhite@docker:~/git/certstream-server$ sudo docker image ls
REPOSITORY   TAG          IMAGE ID       CREATED          SIZE
<none>       <none>       7574a8455bd6   43 seconds ago   119MB
elixir       1.8-alpine   ca333c791f18   16 months ago    82MB

kwhite@docker:~/git/certstream-server$ sudo docker run -p 4000:4000 ca333c791f18
Interactive Elixir (1.8.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 

I'm surprised that the server doesn't start automatically. I don't understand why it didn't. The Dockerfile sdems to indicate that it should.

So I try again, adding -it:

kwhite@docker:~/git/certstream-server$ sudo docker run -it -p 4000:4000 ca333c791f18
Erlang/OTP 21 [erts-10.3.5.19] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1]

Interactive Elixir (1.8.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :observer.start

06:57:03.306 [error] ERROR: Could not find 'wxe_driver.so' in: /usr/local/lib/erlang/lib/wx-1.8.7/priv

{:error,
 {{:load_driver, 'No driver found'},
  [
    {:wxe_server, :start, 1, [file: 'wxe_server.erl', line: 65]},
    {:wx, :new, 1, [file: 'wx.erl', line: 115]},
    {:observer_wx, :init, 1, [file: 'observer_wx.erl', line: 107]},
    {:wx_object, :init_it, 6, [file: 'wx_object.erl', line: 372]},
    {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}
  ]}}

Well, that's not good.

Again, I'm sorry. I'm sure that everything I'm doing looks really stupid to someone who a) knows Elixir and b) knows Docker. But I hope you can see that for a knowledgeable Linux user who doesn't know either, well....I can't figure out how to get this to run.

Thank you.

kevbo-oh commented 8 months ago

OK, so, like I said, I knew I was doing something dumb. I wasn't running the prepared image, but was running the default elixir:1.8-alpine image. When I started the correct image instead, the server started properly.

kwhite@docker:~/git/certstream-server$ sudo docker image ls
REPOSITORY   TAG          IMAGE ID       CREATED         SIZE
<none>       <none>       7574a8455bd6   6 hours ago     119MB
elixir       1.8-alpine   ca333c791f18   16 months ago   82MB
kwhite@docker:~/git/certstream-server$ sudo docker run -it -p 4000:4000 7574a8455bd6

Maybe this will help someone else figure this out.

edwardwc commented 3 months ago

For all future MacOS users (and maybe users from other platforms) - the issue probably stems with using the latest Elixir. Going into mix.exs and changing the EasySSL dependency to: {:easy_ssl, github: "CaliDog/EasySSL", branch: "master"} worked!