From 925de1995eeb22863e8d4e92d720465834619288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20C=C3=A9sar=20J=C3=BAnior?= Date: Mon, 21 Mar 2022 14:04:16 -0300 Subject: [PATCH] docs: Add Dockerfile and docker build instructions (#3547) Many devs using Shaka and wishing to compile the library are required to install all prerequisites on their machine. For docker devs, this is extremely bad as it requires installing Java and Python on OS. This commit adds a basic configuration for quick compilation via Docker, without requiring any other prerequisites. Improvements can be made in order to allow all Shaka workflow inside Docker. Suggested in #181 --- build/docker/Dockerfile | 26 ++++++++++++++++++++++++++ build/docker/docker-compose.yml | 10 ++++++++++ docs/tutorials/welcome.md | 8 ++++++++ 3 files changed, 44 insertions(+) create mode 100644 build/docker/Dockerfile create mode 100644 build/docker/docker-compose.yml diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile new file mode 100644 index 0000000000..1fb17c7f11 --- /dev/null +++ b/build/docker/Dockerfile @@ -0,0 +1,26 @@ +# Alpine was chosen by providing a node container less than 100mb +FROM node:17.7.1-alpine3.15 + +WORKDIR /usr/src/app + +# install dependencies +RUN apk add --update --no-cache openssh git python3 openjdk11-jre-headless +RUN ln -sf python3 /usr/bin/python + +# Change to non-root user +USER node + +# Python user's setup +RUN mkdir -p /home/node/.local/bin +ENV PATH="$PATH:/home/node/.local/bin" +RUN python3 -m ensurepip +RUN pip3 install --no-cache --upgrade pip setuptools + +# Prevent proxy timeout error (very slow connections) +RUN npm config set fetch-retry-mintimeout 20000 +RUN npm config set fetch-retry-maxtimeout 120000 +RUN npm config rm proxy +RUN npm config rm https-proxy + +# Run compilation +CMD [ "python", "build/all.py" ] diff --git a/build/docker/docker-compose.yml b/build/docker/docker-compose.yml new file mode 100644 index 0000000000..68984ac8ce --- /dev/null +++ b/build/docker/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3' + +services: + shaka-compiler: + build: ./ + container_name: shaka-compiler + volumes: + - ../../:/usr/src/app + +# Others services can be added here diff --git a/docs/tutorials/welcome.md b/docs/tutorials/welcome.md index e19f73d4cb..2261226ac8 100644 --- a/docs/tutorials/welcome.md +++ b/docs/tutorials/welcome.md @@ -35,6 +35,8 @@ To get the sources and compile the library, you will need: * _NOTE: A local web server is required because browsers place restrictions on applications from file:/// URLs._ +If you just want to compile for export to other projects, you might consider compiling through a docker container. (see compile instructions) + To quickly install these prerequisites on Ubuntu or Debian, you can run this script: @@ -62,6 +64,12 @@ cd shaka-player python build/all.py ``` +Alternatively you can use a docker container: +```sh +cd build/docker +docker-compose run --rm shaka-compiler +``` + The output is: * dist/shaka-player.compiled.js (compiled bundle) * dist/shaka-player.compiled.debug.js (debug bundle)