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" |
pierventre | ef5e1d1 | 2022-02-21 15:32:55 -0800 | [diff] [blame] | 17 | ENV="macos" |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 18 | |
| 19 | mkdir -p "${CONTAINER_FS}/tmp" |
| 20 | rm -rf "${CONTAINER_FS}/tmp/additional-py-pkgs.txt" |
| 21 | touch "${CONTAINER_FS}/tmp/additional-py-pkgs.txt" |
| 22 | |
| 23 | for op in $@; do |
| 24 | case $op in |
| 25 | '--wk' ) |
| 26 | rm -rf "${CONTAINER_FS}/home/jenkins/.ssh" |
| 27 | cp -r "${HOME}/.ssh" "${CONTAINER_FS}/home/jenkins/.ssh" |
| 28 | ;; |
| 29 | '--di' ) |
| 30 | rm -rf "${CONTAINER_FS}/tmp/bf-di-scripts" |
| 31 | git clone "${DI_UTIL_REPO}" "${CONTAINER_FS}/tmp/bf-di-scripts" |
| 32 | echo "/tmp/bf-di-scripts/4/utility" > "${CONTAINER_FS}/tmp/additional-py-pkgs.txt" |
| 33 | ;; |
pierventre | ef5e1d1 | 2022-02-21 15:32:55 -0800 | [diff] [blame] | 34 | '--li' ) |
| 35 | ENV="linux" |
| 36 | ;; |
Yi Tseng | aae6ef5 | 2021-09-01 13:48:27 -0700 | [diff] [blame] | 37 | esac |
| 38 | done |
| 39 | |
pierventre | ef5e1d1 | 2022-02-21 15:32:55 -0800 | [diff] [blame] | 40 | docker build -t teston -f "${THIS_DIR}/Dockerfile" "${TEST_ON_DIR}" --build-arg ENV=$ENV |