build-image.sh 1.2 KB

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. root="$(cd "$(dirname "$0")/../.." && pwd)"
  4. export CONTAINERS_REGISTRIES_CONF="${CONTAINERS_REGISTRIES_CONF:-$root/tools/remote/registries-cn.conf}"
  5. pull_policy="${PROD2U_PULL_POLICY:-missing}"
  6. cache_base="${PROD2U_CACHE_DIR:-/data/prod2u/cache}"
  7. mkdir -p "$cache_base/apt/archives/partial"
  8. extra_args=()
  9. if [[ -n "${PROD2U_PIP_WHEELHOUSE:-}" ]]; then
  10. if [[ ! -d "$PROD2U_PIP_WHEELHOUSE" ]]; then
  11. echo "OFFLINE_CACHE_MISS: $PROD2U_PIP_WHEELHOUSE" >&2
  12. exit 4
  13. fi
  14. extra_args+=(
  15. --volume "$PROD2U_PIP_WHEELHOUSE:/opt/prod2u/wheelhouse:ro"
  16. --env PIP_NO_INDEX=1
  17. --env PIP_FIND_LINKS=/opt/prod2u/wheelhouse
  18. )
  19. fi
  20. exec podman build --pull="$pull_policy" \
  21. --volume "$cache_base/apt:/var/cache/apt:rw" \
  22. "${extra_args[@]}" \
  23. --build-arg DEBIAN_MIRROR="${DEBIAN_MIRROR:-http://mirrors.aliyun.com/debian}" \
  24. --build-arg DEBIAN_SECURITY_MIRROR="${DEBIAN_SECURITY_MIRROR:-http://mirrors.aliyun.com/debian-security}" \
  25. --build-arg PYPI_INDEX_URL="${PYPI_INDEX_URL:-https://mirrors.aliyun.com/pypi/simple}" \
  26. -t localhost/prod2u-6400-dev:locked \
  27. -f "$root/containers/6400-dev/Containerfile" \
  28. "$root/containers/6400-dev"