build_and_push.sh 743 Bytes
Newer Older
1
2
3
4
#!/usr/bin/env bash

set -euo pipefail

moto's avatar
moto committed
5
6
7
8
9
if [ $# -ne 1 ]; then
    printf "Usage %s <CUDA_VERSION>\n\n" "$0"
    exit 1
fi

10
datestr="$(date "+%Y%m%d")"
moto's avatar
moto committed
11
12
if [ "$1" = "cpu" ]; then
    base_image="ubuntu:18.04"
13
    image="pytorch/torchaudio_unittest_base:manylinux-${datestr}"
moto's avatar
moto committed
14
else
15
16
17
    base_image="nvidia/cuda:$1-devel-ubuntu18.04"
    docker pull "${base_image}"
    image="pytorch/torchaudio_unittest_base:manylinux-cuda$1-${datestr}"
moto's avatar
moto committed
18
19
fi

20
21
cd "$( dirname "${BASH_SOURCE[0]}" )"

moto's avatar
moto committed
22
23
24
25
# docker build also accepts reading from STDIN
# but in that case, no context (other files) can be passed, so we write out Dockerfile
sed "s|BASE_IMAGE|${base_image}|g" Dockerfile > Dockerfile.tmp
docker build -t "${image}" -f Dockerfile.tmp .
26
docker push "${image}"