Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/next/external/config/templates/config-docker.conf
Views: 3957
# DO NOT EDIT THIS FILE1#2# This is a Docker launcher file. To set up the configuration, use command line arguments to compile.sh3# or use pass a config file as a parameter ./compile docker [example] BUILD_KERNEL="yes" ...45[[ ! -c /dev/loop-control ]] && display_alert "/dev/loop-control does not exist, image building may not work" "" "wrn"67# second argument can be a build parameter or a config file8# create user accessible directories and set their owner group and permissions9# if they are created from Docker they will be owned by root and require root permissions to change/delete10mkdir -p $SRC/{output,userpatches}11grep -q '^docker:' /etc/group && chgrp --quiet docker $SRC/{output,userpatches}12chmod --quiet g+w,g+s $SRC/{output,userpatches}13VERSION=latest1415if grep -q $VERSION <(grep orangepi <(docker images)); then16display_alert "Using existed a orangepi Docker container"17else18# build a new container based on provided Dockerfile19display_alert "Docker container not found or out of date"20display_alert "Building a Docker container"21if ! docker build -t orangepi:$VERSION . ; then22STATUS=$?23# Adding a newline, so the alert won't be shown in the same line as the error24echo25display_alert "Docker container build exited with code: " "$STATUS" "err"26exit 127fi28fi2930DOCKER_FLAGS=()3132# Running this container in privileged mode is a simple way to solve loop device access issues33# Required for USB FEL or when writing image directly to the block device, when CARD_DEVICE is defined34#DOCKER_FLAGS+=(--privileged)3536# add only required capabilities instead (though MKNOD should be already present)37# CAP_SYS_PTRACE is required for systemd-detect-virt in some cases38DOCKER_FLAGS+=(--cap-add=SYS_ADMIN --cap-add=MKNOD --cap-add=SYS_PTRACE)3940# mounting things inside the container on Ubuntu won't work without this41# https://github.com/moby/moby/issues/16429#issuecomment-21712658642DOCKER_FLAGS+=(--security-opt=apparmor:unconfined)4344# remove resulting container after exit to minimize clutter45# bad side effect - named volumes are considered not attached to anything and are removed on "docker volume prune"46DOCKER_FLAGS+=(--rm)4748# pass through loop devices49for d in /dev/loop*; do50DOCKER_FLAGS+=(--device=$d)51done5253# accessing dynamically created devices won't work by default54# and --device doesn't accept devices that don't exist at the time "docker run" is executed55# https://github.com/moby/moby/issues/2788656# --device-cgroup-rule requires new Docker version5758# Test for --device-cgroup-rule support. If supported, appends it59# Otherwise, let it go and let user know that only kernel and u-boot for you60if docker run --help | grep device-cgroup-rule > /dev/null 2>&1; then61# allow loop devices (not required)62DOCKER_FLAGS+=(--device-cgroup-rule='b 7:* rmw')63# allow loop device partitions64DOCKER_FLAGS+=(--device-cgroup-rule='b 259:* rmw')6566# this is an ugly hack, but it is required to get /dev/loopXpY minor number67# for mknod inside the container, and container itself still uses private /dev internally68DOCKER_FLAGS+=(-v /dev:/tmp/dev:ro)69else70display_alert "Your Docker version does not support device-cgroup-rule" "" "wrn"71display_alert "and will be able to create only Kernel and u-boot packages (KERNEL_ONLY=yes)" "" "wrn"72fi7374# Expose ports for NFS server inside docker container, required for USB FEL75#DOCKER_FLAGS+=(-p 0.0.0.0:2049:2049 -p 0.0.0.0:2049:2049/udp -p 0.0.0.0:111:111 -p 0.0.0.0:111:111/udp -p 0.0.0.0:32765:32765 -p 0.0.0.0:32765:32765/udp -p 0.0.0.0:32767:32767 -p 0.0.0.0:32767:32767/udp)76# Export usb device for FEL, required for USB FEL77#DOCKER_FLAGS+=(-v /dev/bus/usb:/dev/bus/usb:ro)7879# map source to Docker Working dir.80DOCKER_FLAGS+=(-v=$SRC/:/root/orangepi/)8182# mount 2 named volumes - for cacheable data and compiler cache83DOCKER_FLAGS+=(-v=orangepi-cache:/root/orangepi/cache -v=orangepi-ccache:/root/.ccache)8485DOCKER_FLAGS+=(-e COLUMNS="`tput cols`" -e LINES="`tput lines`")8687# pass other command line arguments like KERNEL_ONLY=yes, KERNEL_CONFIGURE=yes, etc.88# pass "docker-guest" as an additional config name that will be sourced in the container if exists89if [[ $SHELL_ONLY == yes ]]; then90display_alert "Running the container in shell mode" "" "info"91cat <<\EOF92Welcome to the docker shell of Armbian.9394To build the whole thing using default profile, run:95./compile.sh9697To build the U-Boot only, run:98# Optional: prepare the environment first if you had not run `./compile.sh`99./compile.sh 'prepare_host && compile_sunxi_tools && install_rkbin_tools'100101# build the U-Boot only102./compile.sh compile_uboot103104If you prefer to use profile, for example, `userpatches/config-my.conf`, try:105./compile.sh my 'prepare_host && compile_sunxi_tools && install_rkbin_tools'106./compile.sh my compile_uboot107108EOF109docker run "${DOCKER_FLAGS[@]}" -it --entrypoint /usr/bin/env orangepi:$VERSION "$@" /bin/bash110else111display_alert "Running the container" "" "info"112docker run "${DOCKER_FLAGS[@]}" -it orangepi:$VERSION "$@"113fi114115# Docker error treatment116STATUS=$?117# Adding a newline, so the message won't be shown in the same line as the error118echo119case $STATUS in1200)121# No errors from either Docker or build script122echo123;;124125)125display_alert "Docker command failed, check syntax or version support. Error code: " "$STATUS" "err"126;;127126)128display_alert "Failure when running containerd command. Error code: " "$STATUS" "err"129;;130127)131display_alert "containerd command not found. Error code: " "$STATUS" "err"132;;133137)134display_alert "Container exit from docker stop. Error code: " "$STATUS" "info"135;;136*)137# Build script exited with error, but the error message should have been already printed138echo139;;140esac141142# don't need to proceed further on the host143exit 0144145146