| 
									
										
										
										
											2020-02-28 14:40:26 -08:00
										 |  |  | FROM ubuntu:bionic
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # 1. Install node12
 | 
					
						
							|  |  |  | RUN apt-get update && apt-get install -y curl && \
 | 
					
						
							|  |  |  |     curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
 | 
					
						
							|  |  |  |     apt-get install -y nodejs
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # 2. Install WebKit dependencies
 | 
					
						
							| 
									
										
										
										
											2020-07-10 16:01:30 -07:00
										 |  |  | RUN apt-get update && apt-get install -y --no-install-recommends \
 | 
					
						
							|  |  |  |     libwoff1 \
 | 
					
						
							|  |  |  |     libopus0 \
 | 
					
						
							|  |  |  |     libwebp6 \
 | 
					
						
							|  |  |  |     libwebpdemux2 \
 | 
					
						
							|  |  |  |     libenchant1c2a \
 | 
					
						
							|  |  |  |     libgudev-1.0-0 \
 | 
					
						
							|  |  |  |     libsecret-1-0 \
 | 
					
						
							|  |  |  |     libhyphen0 \
 | 
					
						
							|  |  |  |     libgdk-pixbuf2.0-0 \
 | 
					
						
							|  |  |  |     libegl1 \
 | 
					
						
							|  |  |  |     libnotify4 \
 | 
					
						
							|  |  |  |     libxslt1.1 \
 | 
					
						
							|  |  |  |     libevent-2.1-6 \
 | 
					
						
							|  |  |  |     libgles2 \
 | 
					
						
							| 
									
										
										
										
											2020-07-15 17:15:03 -07:00
										 |  |  |     libvpx5 \
 | 
					
						
							|  |  |  |     libxcomposite1 \
 | 
					
						
							|  |  |  |     libatk1.0-0 \
 | 
					
						
							|  |  |  |     libatk-bridge2.0-0 \
 | 
					
						
							|  |  |  |     libepoxy0 \
 | 
					
						
							|  |  |  |     libgtk-3-0 \
 | 
					
						
							|  |  |  |     libharfbuzz-icu0
 | 
					
						
							| 
									
										
										
										
											2020-02-28 14:40:26 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-18 18:12:00 -07:00
										 |  |  | # 3. Install gstreamer and plugins to support video playback in WebKit.
 | 
					
						
							| 
									
										
										
										
											2020-07-10 16:01:30 -07:00
										 |  |  | RUN apt-get update && apt-get install -y --no-install-recommends \
 | 
					
						
							|  |  |  |     libgstreamer-gl1.0-0 \
 | 
					
						
							|  |  |  |     libgstreamer-plugins-bad1.0-0 \
 | 
					
						
							| 
									
										
										
										
											2020-08-03 16:06:57 -07:00
										 |  |  |     gstreamer1.0-plugins-good \
 | 
					
						
							|  |  |  |     gstreamer1.0-libav
 | 
					
						
							| 
									
										
										
										
											2020-06-18 18:12:00 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | # 4. Install Chromium dependencies
 | 
					
						
							| 
									
										
										
										
											2020-07-10 16:01:30 -07:00
										 |  |  | RUN apt-get update && apt-get install -y --no-install-recommends \
 | 
					
						
							|  |  |  |     libnss3 \
 | 
					
						
							|  |  |  |     libxss1 \
 | 
					
						
							|  |  |  |     libasound2 \
 | 
					
						
							| 
									
										
										
										
											2020-07-15 17:20:48 -07:00
										 |  |  |     fonts-noto-color-emoji \
 | 
					
						
							|  |  |  |     libxtst6
 | 
					
						
							| 
									
										
										
										
											2020-02-28 14:40:26 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-18 18:12:00 -07:00
										 |  |  | # 5. Install Firefox dependencies
 | 
					
						
							| 
									
										
										
										
											2020-07-10 16:01:30 -07:00
										 |  |  | RUN apt-get update && apt-get install -y --no-install-recommends \
 | 
					
						
							|  |  |  |     libdbus-glib-1-2 \
 | 
					
						
							|  |  |  |     libxt6
 | 
					
						
							| 
									
										
										
										
											2020-02-28 14:40:26 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-18 18:12:00 -07:00
										 |  |  | # 6. Install ffmpeg to bring in audio and video codecs necessary for playing videos in Firefox.
 | 
					
						
							| 
									
										
										
										
											2020-07-10 16:01:30 -07:00
										 |  |  | RUN apt-get update && apt-get install -y --no-install-recommends \
 | 
					
						
							|  |  |  |     ffmpeg
 | 
					
						
							| 
									
										
										
										
											2020-04-07 18:09:27 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-18 18:12:00 -07:00
										 |  |  | # 7. Add user so we don't need --no-sandbox in Chromium
 | 
					
						
							| 
									
										
										
										
											2020-02-28 14:40:26 -08:00
										 |  |  | RUN groupadd -r pwuser && useradd -r -g pwuser -G audio,video pwuser \
 | 
					
						
							|  |  |  |     && mkdir -p /home/pwuser/Downloads \
 | 
					
						
							|  |  |  |     && chown -R pwuser:pwuser /home/pwuser
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-18 18:12:00 -07:00
										 |  |  | # 8. (Optional) Install XVFB if there's a need to run browsers in headful mode
 | 
					
						
							| 
									
										
										
										
											2020-07-10 16:01:30 -07:00
										 |  |  | RUN apt-get update && apt-get install -y --no-install-recommends \
 | 
					
						
							|  |  |  |     xvfb
 | 
					
						
							| 
									
										
										
										
											2020-03-02 18:54:13 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-10 16:01:30 -07:00
										 |  |  | # 9. Run everything after as non-privileged user.
 | 
					
						
							| 
									
										
										
										
											2020-02-28 14:40:26 -08:00
										 |  |  | USER pwuser
 | 
					
						
							| 
									
										
										
										
											2020-07-17 16:51:39 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | # === BAKE BROWSERS INTO IMAGE ===
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # 1. Add tip-of-tree Playwright package to install its browsers.
 | 
					
						
							|  |  |  | #    The package should be built beforehand from tip-of-tree Playwright.
 | 
					
						
							|  |  |  | COPY --chown=pwuser ./playwright.tar.gz /home/pwuser/playwright.tar.gz
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # 2. Install playwright and then delete the installation.
 | 
					
						
							|  |  |  | #    Browsers will remain downloaded in `/home/pwuser/.cache/ms-playwright`.
 | 
					
						
							|  |  |  | RUN mkdir /home/pwuser/tmp && cd /home/pwuser/tmp && npm init -y && \
 | 
					
						
							|  |  |  |     npm i ../playwright.tar.gz && \
 | 
					
						
							|  |  |  |     cd ../ && rm -rf tmp && rm /home/pwuser/playwright.tar.gz
 | 
					
						
							|  |  |  | 
 |