timgremore commited on
Commit
fb8450f
·
1 Parent(s): 7a604c1

fix: Add Chrome to image and configure ChromicPDF

Browse files
Files changed (2) hide show
  1. Dockerfile +6 -1
  2. lib/medicode/application.ex +15 -1
Dockerfile CHANGED
@@ -73,9 +73,14 @@ FROM ${RUNNER_IMAGE}
73
 
74
  RUN apt-get update -y && \
75
  apt-get install -y libstdc++6 openssl libncurses5 locales ca-certificates \
76
- curl unzip ffmpeg libasound2-dev portaudio19-dev \
 
77
  && apt-get clean && rm -f /var/lib/apt/lists/*_*
78
 
 
 
 
 
79
  # Set the locale
80
  RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
81
 
 
73
 
74
  RUN apt-get update -y && \
75
  apt-get install -y libstdc++6 openssl libncurses5 locales ca-certificates \
76
+ curl unzip ffmpeg libasound2-dev portaudio19-dev fonts-liberation libatk-bridge2.0-0 libatk1.0-0 \
77
+ libatspi2.0-0 libcups2 libgtk-3-0 libnspr4 libnss3 libu2f-udev libxcomposite1 wget xdg-utils \
78
  && apt-get clean && rm -f /var/lib/apt/lists/*_*
79
 
80
+ RUN curl -LO https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
81
+ RUN apt-get install -y ./google-chrome-stable_current_amd64.deb \
82
+ && apt-get clean && rm -f ./google-chrome-stable_current_amd64.deb
83
+
84
  # Set the locale
85
  RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
86
 
lib/medicode/application.ex CHANGED
@@ -29,7 +29,7 @@ defmodule Medicode.Application do
29
  Medicode.ClassificationSupervisor,
30
  strategy: :one_for_one, max_restarts: 1
31
  },
32
- ChromicPDF,
33
  # Start a worker by calling: Medicode.Worker.start_link(arg)
34
  # {Medicode.Worker, arg},
35
  # Start to serve requests, typically the last entry
@@ -61,4 +61,18 @@ defmodule Medicode.Application do
61
  defp text_embedding_spec do
62
  Vectors.child_spec(Medicode.TextEmbeddingServing)
63
  end
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  end
 
29
  Medicode.ClassificationSupervisor,
30
  strategy: :one_for_one, max_restarts: 1
31
  },
32
+ {ChromicPDF, chromic_pdf_opts()},
33
  # Start a worker by calling: Medicode.Worker.start_link(arg)
34
  # {Medicode.Worker, arg},
35
  # Start to serve requests, typically the last entry
 
61
  defp text_embedding_spec do
62
  Vectors.child_spec(Medicode.TextEmbeddingServing)
63
  end
64
+
65
+ defp chromic_pdf_opts do
66
+ # NOTE: Security implications of using Chrome:
67
+ # https://github.com/bitcrowd/chromic_pdf/blob/2c13cd2690204e6a30d817e72a3d1ef13e8a2441/lib/chromic_pdf.ex#L71
68
+ #
69
+ # `chrome_executable` recommendation found here:
70
+ # https://community.fly.io/t/cant-install-chrome-chromium-via-dockerfile-or-ssh/5303/6
71
+ [
72
+ disable_scripts: true,
73
+ offline: true,
74
+ no_sandbox: true,
75
+ chrome_executable: "/usr/bin/google-chrome"
76
+ ]
77
+ end
78
  end