Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # SPDX-FileCopyrightText: Copyright 2021-present Open Networking Foundation. |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | # Usage: |
| 5 | # ./build.sh [--wk] [--di] |
| 6 | # |
| 7 | # Options: |
| 8 | # --wk: with user's SSH key. |
| 9 | # --di: with DeepInsight utility library(from a private repo) |
| 10 | |
| 11 | set -euo pipefail |
| 12 | |
| 13 | THIS_DIR="$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)" |
| 14 | TEST_ON_DIR="$(cd ${THIS_DIR}/.. && pwd)" |
| 15 | CONTAINER_FS="${THIS_DIR}/fs" |
| 16 | DI_UTIL_REPO="git@github.com:opennetworkinglab/bf-di-scripts.git" |
| 17 | |
| 18 | mkdir -p "${CONTAINER_FS}/tmp" |
| 19 | rm -rf "${CONTAINER_FS}/tmp/additional-py-pkgs.txt" |
| 20 | touch "${CONTAINER_FS}/tmp/additional-py-pkgs.txt" |
| 21 | |
| 22 | for op in $@; do |
| 23 | case $op in |
| 24 | '--wk' ) |
| 25 | rm -rf "${CONTAINER_FS}/home/jenkins/.ssh" |
| 26 | cp -r "${HOME}/.ssh" "${CONTAINER_FS}/home/jenkins/.ssh" |
| 27 | ;; |
| 28 | '--di' ) |
| 29 | rm -rf "${CONTAINER_FS}/tmp/bf-di-scripts" |
| 30 | git clone "${DI_UTIL_REPO}" "${CONTAINER_FS}/tmp/bf-di-scripts" |
| 31 | echo "/tmp/bf-di-scripts/4/utility" > "${CONTAINER_FS}/tmp/additional-py-pkgs.txt" |
| 32 | ;; |
| 33 | esac |
| 34 | done |
| 35 | |
| 36 | docker build -t teston -f "${THIS_DIR}/Dockerfile" "${TEST_ON_DIR}" |