This repository has been archived by the owner on May 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
docker_make
executable file
·62 lines (52 loc) · 2.13 KB
/
docker_make
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
#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: EPL-2.0
#
# terminate child processes on exit
trap 'kill $(jobs -pr) > /dev/null 2>&1' SIGINT SIGTERM EXIT
set -e
set -u
set -o pipefail
# NOTE: proxifier inteferes with nc -z port scan so hardcoded for now:
PORT=64321
type -p socat > /dev/null 2>&1 || (echo "socat needs to be installed" && exit 1)
type -p docker > /dev/null 2>&1 || (echo "Docker needs to be installed" && exit 1)
docker version >/dev/null 2>&1 || (echo "Docker needs to be configured/running" && exit 1)
if [[ -z "${SSH_AUTH_SOCK:-}" ]]; then
echo "Please configure ssh-agent and configure github to use ssh keys."
exit 1
fi
if [[ $(ssh-add -l | grep -c 'no identities') -eq 1 ]]; then
echo "Please add github private key via command 'ssh-add [/path/to/github_private_key]' and rerun this command"
exit 1
fi
# NOTE: forward SSH_AUTH_SOCK until docker socket forwarding is resolved:
# https://github.com/docker/for-mac/issues/483
socat TCP-LISTEN:"$PORT",reuseaddr,fork,bind=127.0.0.1 UNIX-CLIENT:"$SSH_AUTH_SOCK" &
# Set host address based on system
PLATFORM=$(uname -s)
if [[ $PLATFORM == 'Darwin' ]]; then
# NOTE: see https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds
HOST='docker.for.mac.localhost'
else
HOST='127.0.0.1'
fi
docker run --net=host -v "${HOME}"/root \
-v $(pwd)/:/go/src/github.com/IntelAI/vck \
-e SSH_AUTH_SOCK=/var/run/ssh_agent.sock \
-w /go/src/github.com/IntelAI/vck \
-it volumecontroller/golang:1.9.2 /bin/bash -c "socat UNIX-LISTEN:/var/run/ssh_agent.sock,reuseaddr,fork TCP:$HOST:$PORT & make ${1:-}"