Skip to content

Commit

Permalink
docs: Add Dockerfile and docker build instructions (#3547)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
juninhocruzg3 authored Mar 21, 2022
1 parent bdc5ea7 commit 925de19
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
26 changes: 26 additions & 0 deletions build/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
10 changes: 10 additions & 0 deletions build/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3'

services:
shaka-compiler:
build: ./
container_name: shaka-compiler
volumes:
- ../../:/usr/src/app

# Others services can be added here
8 changes: 8 additions & 0 deletions docs/tutorials/welcome.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 925de19

Please sign in to comment.