-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·66 lines (52 loc) · 1.68 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -Eeuxo pipefail
# TODO: Add option for latest VSCode plugins.
# TODO: Add option to copy VSCode settings.
IMAGE_NAME=qemu-in-docker
CONTAINER_NAME=${IMAGE_NAME}
ARCH=$(arch)
# --device /dev/dri:/dev/dri \
# --device /dev/kvm:/dev/kvm \
# --device /dev/vfio/vfio:/dev/vfio/vfio \
# --device /dev/vhost-net:/dev/vhost-net \
# --device /dev/net/tun:/dev/net/tun \
DOCKER_DEVICES=" \
"
DOCKER_VOLUMES=""
#\
# --volume /tmp/.X11-unix:/tmp/.X11-unix \
# --volume ${HOME}/fuchsia:/home/developer/fuchsia \
# --volume ${HOME}/qemu:/home/developer/qemu \
# --volume ${HOME}/.vscode:/home/developer/.vscode
# "
set +e
docker container stop ${CONTAINER_NAME}
docker container rm ${CONTAINER_NAME}
set -e
# Stage VSCode settings.
#cp -Rf ~/.vscode vscode-settings
# Create custom VSCode extension intall script.
#
# This pins the Docker extension version to the
# same versions as the Docker host.
# VSCODE_EXTENSIONS=($(code --list-extensions --show-versions))
# cat << EOF > install-vscode-extensions.sh
# #!/usr/bin/env bash
# set -Eeuxo pipefail
# EOF
# for VSCODE_EXTENSION in ${VSCODE_EXTENSIONS[@]}
# do
# cat << EOF >> install-vscode-extensions.sh
# code --install-extension ${VSCODE_EXTENSION}
# EOF
# done
docker build -t ${IMAGE_NAME} -f Dockerfile-${ARCH} .
docker container create \
-e DISPLAY=$DISPLAY \
${DOCKER_DEVICES} \
${DOCKER_VOLUMES} \
--name ${CONTAINER_NAME} ${IMAGE_NAME}
docker container start ${CONTAINER_NAME}
docker logs ${CONTAINER_NAME}
docker container exec --privileged -it ${CONTAINER_NAME} /bin/bash