Skip to content

Commit 9baf3fc

Browse files
committed
Docker dev image (bokeh#11352)
1 parent 84c129c commit 9baf3fc

File tree

7 files changed

+156
-0
lines changed

7 files changed

+156
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Docker image - Build
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
docker_build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout source
11+
uses: actions/checkout@v2
12+
13+
- name: Set up QEMU
14+
uses: docker/setup-qemu-action@v1
15+
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v1
18+
19+
- name: Build image
20+
uses: docker/build-push-action@v2
21+
with:
22+
context: ci/docker
23+
load: false
24+
tags: bokeh-dev:latest
25+
26+
- name: Save image to file
27+
run: |
28+
docker save -o bokeh-dev.tar bokeh-dev
29+
30+
- name: Upload artifact
31+
uses: actions/upload-artifact@v2
32+
with:
33+
path: bokeh-dev.tar

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,6 @@
6262
/.mypy_cache/
6363
/.images-list
6464
/examples-report.html
65+
66+
# used by docker container
67+
.conda_docker

bokehjs/make/tasks/test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ async function headless(port: number): Promise<ChildProcess> {
134134
"--force-color-profile=srgb", // ^^^
135135
"--force-device-scale-factor=1", // ^^^
136136
]
137+
const bokeh_in_docker = process.env.BOKEH_IN_DOCKER ?? ""
138+
if (bokeh_in_docker == "1") {
139+
args.push("--no-sandbox")
140+
}
137141
const executable = chrome()
138142
const proc = spawn(executable, args, {stdio: "pipe"})
139143

ci/docker/Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM ubuntu:20.04
2+
3+
ARG CHROME_DEB=google-chrome-stable_current_amd64.deb
4+
ARG FIXUID_VERSION=0.5
5+
6+
ENV DEBIAN_FRONTEND=noninteractive
7+
8+
RUN apt update -y && \
9+
apt upgrade -y && \
10+
apt install -y curl git sudo
11+
12+
# User and group setup using fixuid.
13+
RUN addgroup --gid 1000 docker && \
14+
adduser --uid 1000 --ingroup docker --home /home/docker --shell /bin/bash --disabled-password --gecos "" docker && \
15+
USER=docker && \
16+
GROUP=docker && \
17+
ARCH="$(dpkg --print-architecture)" && \
18+
curl -fsSL "https://github.com/boxboat/fixuid/releases/download/v$FIXUID_VERSION/fixuid-$FIXUID_VERSION-linux-$ARCH.tar.gz" | tar -C /usr/local/bin -xzf - && \
19+
chown root:root /usr/local/bin/fixuid && \
20+
chmod 4755 /usr/local/bin/fixuid && \
21+
mkdir -p /etc/fixuid && \
22+
printf "user: $USER\ngroup: $GROUP\n" > /etc/fixuid/config.yml
23+
24+
# Cannot 'snap install chromium' in docker container, so instead install google-chrome deb.
25+
RUN curl -LO https://dl.google.com/linux/direct/$CHROME_DEB && \
26+
apt install --no-install-recommends -y ./$CHROME_DEB && \
27+
rm $CHROME_DEB && \
28+
apt purge -y curl && \
29+
apt autoremove -y && \
30+
apt clean -y && \
31+
rm -rf /var/lib/apt/lists/*
32+
33+
EXPOSE 5006
34+
35+
COPY entrypoint.sh /usr/bin/entrypoint.sh
36+
RUN chmod a+x /usr/bin/entrypoint.sh
37+
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
38+
39+
ENV BOKEH_IN_DOCKER=1
40+
USER docker:docker
41+
WORKDIR /bokeh

ci/docker/bokeh_docker_build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
echo "Start of $0"
6+
7+
bash ci/install_node_modules.sh
8+
python setup.py install
9+
10+
python -m bokeh info
11+
12+
echo "End of $0"

ci/docker/bokeh_docker_test.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# Note do not exit on error, as want remaining tests to run.
4+
set -u
5+
6+
echo "Start of $0"
7+
8+
python -m bokeh info
9+
bokeh sampledata
10+
11+
# Run some of the tests.
12+
pytest tests/codebase
13+
cd bokehjs && node make test
14+
15+
echo "End of $0"

ci/docker/entrypoint.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
CONDA_DIR=.conda_docker
6+
ENV_NAME=bkdev
7+
MINICONDA_SCRIPT=Miniconda3-latest-Linux-x86_64.sh
8+
9+
eval "$(fixuid -q)"
10+
11+
if [ ! -d .git ] || [ ! -f environment.yml ]; then
12+
echo "Directory does not contain Bokeh git repo."
13+
exit 1
14+
fi
15+
16+
if [ ! -f "$CONDA_DIR/condabin/conda" ]; then
17+
# Install miniconda into $CONDA_DIR
18+
START_DIR=$(pwd)
19+
cd /tmp
20+
curl -LO "http://repo.continuum.io/miniconda/$MINICONDA_SCRIPT"
21+
bash $MINICONDA_SCRIPT -p $START_DIR/$CONDA_DIR -b
22+
rm $MINICONDA_SCRIPT
23+
cd $START_DIR
24+
fi
25+
26+
# Activate conda in .bashrc and in this shell.
27+
$CONDA_DIR/condabin/conda init bash > /dev/null
28+
. $CONDA_DIR/etc/profile.d/conda.sh
29+
30+
if [ ! -d "$CONDA_DIR/envs/$ENV_NAME" ]; then
31+
conda env create -f environment.yml
32+
fi
33+
34+
# Ensure conda environment is activated in this shell and in new shells.
35+
conda activate $ENV_NAME
36+
echo "conda activate $ENV_NAME" >> ~/.bashrc
37+
38+
google-chrome --version
39+
40+
if [ "${BOKEH_DOCKER_BUILD:-0}" == 1 ]; then
41+
bash ci/docker/bokeh_docker_build.sh
42+
fi
43+
44+
if [ "${BOKEH_DOCKER_TEST:-0}" == 1 ]; then
45+
bash ci/docker/bokeh_docker_test.sh
46+
fi
47+
48+
/bin/bash "$@"

0 commit comments

Comments
 (0)