diff --git a/.travis.yml b/.travis.yml index 7515cb5..a0f7b28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,12 +19,46 @@ python: - 3.6 services: - docker +before_install: + - if [[ "$TRAVIS_BRANCH" == "master" ]]; then + VERSION=latest; + else + VERSION=$TRAVIS_BRANCH; + fi install: - - docker build -t max-image-resolution-enhancer . - - docker run -it -d --rm -p 5000:5000 max-image-resolution-enhancer + - docker build -f "$DOCKERFILE" -t codait/max-image-resolution-enhancer:"$IMAGE"-"$ARCH"-"$VERSION" . + - docker run -it --rm -d -p 5000:5000 codait/max-image-resolution-enhancer:"$IMAGE"-"$ARCH"-"$VERSION" - pip install pytest requests flake8 Pillow before_script: + - flake8 . --max-line-length=127 - sleep 30 script: - - flake8 . --max-line-length=127 - - pytest tests/test.py \ No newline at end of file + - pytest tests/test.py +after_success: + - if [[ "$IMAGE" != "test" && "$TRAVIS_PULL_REQUEST" == "false" ]] && [[ "$TRAVIS_BRANCH" == "master" || "$TRAVIS_BRANCH" == "$TRAVIS_TAG" ]]; then + echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin; + docker push codait/max-image-resolution-enhancer:"$IMAGE"-"$ARCH"-"$VERSION"; + fi + +matrix: + include: + - os: linux + env: DOCKERFILE=Dockerfile IMAGE=test ARCH=x86_64 + - os: linux + env: DOCKERFILE=Dockerfile.pai IMAGE=powerai ARCH=x86_64 + - os: linux-ppc64le + env: DOCKERFILE=Dockerfile.pai IMAGE=powerai ARCH=ppc64le + - if: type = push AND (branch = master OR tag IS present) + stage: "Docker Manifest" + addons: + apt: + packages: + - docker-ce + install: + before_script: + script: + - export DOCKER_CLI_EXPERIMENTAL=enabled + - docker pull codait/max-image-resolution-enhancer:powerai-ppc64le-"$VERSION"; + - docker pull codait/max-image-resolution-enhancer:powerai-x86_64-"$VERSION"; + - docker manifest create codait/max-image-resolution-enhancer:powerai-"$VERSION" codait/max-image-resolution-enhancer:powerai-ppc64le-"$VERSION" codait/max-image-resolution-enhancer:powerai-x86_64-"$VERSION"; + - docker manifest push codait/max-image-resolution-enhancer:powerai-"$VERSION" diff --git a/Dockerfile.pai b/Dockerfile.pai new file mode 100644 index 0000000..549603e --- /dev/null +++ b/Dockerfile.pai @@ -0,0 +1,21 @@ +FROM codait/max-base:powerai-latest + +ARG model_bucket=https://s3.us-south.cloud-object-storage.appdomain.cloud/max-assets-prod/max-image-resolution-enhancer/1.0.0 +ARG model_file=assets.tar.gz + +WORKDIR /workspace + +RUN wget -nv --show-progress --progress=bar:force:noscroll ${model_bucket}/${model_file} --output-document=assets/${model_file} && \ + tar -x -C assets/ -f assets/${model_file} -v && rm assets/${model_file} + +COPY requirements-pai.txt /workspace +RUN ["/bin/bash", "-c", "cd /opt/anaconda3/bin && source activate base && while read requirement; do conda install --yes $requirement; done < /workspace/requirements-pai.txt"] + +RUN ["/bin/bash", "-c", "cd /opt/anaconda3/bin && source activate base && IBM_POWERAI_LICENSE_ACCEPT=yes ./accept-powerai-license.sh" ] + +COPY . /workspace +RUN md5sum -c md5sums.txt # check file integrity + +EXPOSE 5000 + +CMD ["/bin/bash", "-c", "source /opt/anaconda3/bin/activate base && python3 app.py" ] diff --git a/requirements-pai.txt b/requirements-pai.txt new file mode 100644 index 0000000..96b6a61 --- /dev/null +++ b/requirements-pai.txt @@ -0,0 +1,4 @@ +Pillow +tensorflow +scikit-image +imageio