diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..9dfe5fd --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,22 @@ +image: elixir:latest + +services: + - postgres:latest + +variables: + POSTGRES_DB: test_test + POSTGRES_HOST: postgres + POSTGRES_USER: postgres + POSTGRES_PASSWORD: "postgres" + MIX_ENV: "test" + +before_script: + - apt-get update && apt-get -y install postgresql-client + - mix local.rebar --force + - mix local.hex --force + - mix deps.get + - mix deps.compile + +mix: + script: + - mix test \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a009e1e..7ca6aa0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN apt-get update \ RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ && apt-get update \ - && apt-get install -y google-chrome-stable --no-install-recommends \ + && apt-get install -y git google-chrome-stable --no-install-recommends \ && rm -rf /var/lib/apt/lists/* \ && rm -rf /src/*.deb diff --git a/config/config.exs b/config/config.exs index d8b2801..e18d4c8 100644 --- a/config/config.exs +++ b/config/config.exs @@ -26,25 +26,41 @@ envar = fn name -> end config :logger, - :console, - metadata: [:request_id, :pid, :module], - level: :debug + :console, + metadata: [:request_id, :pid, :module], + level: :debug config :chroxy, - chrome_remote_debug_port_from: envar.("CHROXY_CHROME_PORT_FROM") || "9222", - chrome_remote_debug_port_to: envar.("CHROXY_CHROME_PORT_TO") || "9223" + chrome_remote_debug_port_from: envar.("CHROXY_CHROME_PORT_FROM") || "9222", + chrome_remote_debug_port_to: envar.("CHROXY_CHROME_PORT_TO") || "9223" config :chroxy, Chroxy.ProxyListener, - host: envar.("CHROXY_PROXY_HOST") || "127.0.0.1", - port: envar.("CHROXY_PROXY_PORT") || "1331" + host: envar.("CHROXY_PROXY_HOST") || "127.0.0.1", + port: envar.("CHROXY_PROXY_PORT") || "1331" config :chroxy, Chroxy.ProxyServer, packet_trace: false config :chroxy, Chroxy.Endpoint, - scheme: :http, - port: envar.("CHROXY_ENDPOINT_PORT") || "1330" + scheme: :http, + port: envar.("CHROXY_ENDPOINT_PORT") || "1330" config :chroxy, Chroxy.ChromeServer, - page_wait_ms: envar.("CHROXY_CHROME_SERVER_PAGE_WAIT_MS") || "200", - crash_dumps_dir: envar.("CHROME_CHROME_SERVER_CRASH_DUMPS_DIR") || "/tmp", - verbose_logging: 0 + page_wait_ms: envar.("CHROXY_CHROME_SERVER_PAGE_WAIT_MS") || "200", + crash_dumps_dir: envar.("CHROME_CHROME_SERVER_CRASH_DUMPS_DIR") || "/tmp", + verbose_logging: 0, + chrome_flags: ~w( + --headless + --disable-gpu + --disable-translate + --disable-extensions + --disable-background-networking + --safebrowsing-disable-auto-update + --enable-logging + --disable-sync + --metrics-recording-only + --disable-default-apps + --mute-audio + --no-first-run + --no-sandbox + --incognito + ) diff --git a/lib/chroxy/chrome_server.ex b/lib/chroxy/chrome_server.ex index 4f97712..fec89ae 100644 --- a/lib/chroxy/chrome_server.ex +++ b/lib/chroxy/chrome_server.ex @@ -320,25 +320,12 @@ defmodule Chroxy.ChromeServer do end defp default_opts do + # --headless + [ chrome_port: 9222, chrome_path: chrome_path(), - chrome_flags: ~w( - --headless - --disable-gpu - --disable-translate - --disable-extensions - --disable-background-networking - --safebrowsing-disable-auto-update - --enable-logging - --disable-sync - --metrics-recording-only - --disable-default-apps - --mute-audio - --no-first-run - --no-sandbox - --incognito - ), + chrome_flags: Application.get_env(:chroxy, Chroxy.ChromeServer)[:chrome_flags], verbose_logging: 0, crash_dumps_dir: "/tmp" ] diff --git a/mix.exs b/mix.exs index 1afaee0..3db39f1 100644 --- a/mix.exs +++ b/mix.exs @@ -26,10 +26,10 @@ defmodule Chroxy.MixProject do defp deps do [ {:plug, "~> 1.8.0"}, - {:plug_cowboy, "~> 2.0.2"}, + {:plug_cowboy, "~> 2.0"}, {:cowboy, "~> 2.6.3"}, {:jason, "~> 1.1"}, - {:erlexec, "~> 1.10.0"}, + {:erlexec, git: "https://github.com/saleyn/erlexec.git", override: true }, {:exexec, "~> 0.2"}, {:chrome_remote_interface, "~> 0.3.0"}, {:ex_doc, "~> 0.20", only: :dev, runtime: false} diff --git a/mix.lock b/mix.lock index 4dcce30..686b92d 100644 --- a/mix.lock +++ b/mix.lock @@ -4,7 +4,7 @@ "cowboy": {:hex, :cowboy, "2.6.3", "99aa50e94e685557cad82e704457336a453d4abcb77839ad22dbe71f311fcc06", [:rebar3], [{:cowlib, "~> 2.7.3", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"}, "cowlib": {:hex, :cowlib, "2.7.3", "a7ffcd0917e6d50b4d5fb28e9e2085a0ceb3c97dea310505f7460ff5ed764ce9", [:rebar3], [], "hexpm"}, "earmark": {:hex, :earmark, "1.3.2", "b840562ea3d67795ffbb5bd88940b1bed0ed9fa32834915125ea7d02e35888a5", [:mix], [], "hexpm"}, - "erlexec": {:hex, :erlexec, "1.10.0", "cba7924cf526097d2082ceb0ec34e7db6bca2624b8f3867fb3fa89c4cf25d227", [:rebar3], [], "hexpm"}, + "erlexec": {:git, "https://github.com/saleyn/erlexec.git", "c84cbad85ad1fd5cc4d24118313e90fe907ce886", []}, "ex_doc": {:hex, :ex_doc, "0.20.2", "1bd0dfb0304bade58beb77f20f21ee3558cc3c753743ae0ddbb0fd7ba2912331", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, "exexec": {:hex, :exexec, "0.2.0", "a6ffc48cba3ac9420891b847e4dc7120692fb8c08c9e82220ebddc0bb8d96103", [:mix], [{:erlexec, "~> 1.10", [hex: :erlexec, repo: "hexpm", optional: false]}], "hexpm"}, "hackney": {:hex, :hackney, "1.15.1", "9f8f471c844b8ce395f7b6d8398139e26ddca9ebc171a8b91342ee15a19963f4", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},