Fix #3157: Add CircleCI config
This commit is contained in:
parent
bb7a0457a3
commit
c31c4843b3
|
@ -0,0 +1,89 @@
|
||||||
|
# These environment variables must be set in CircleCI UI
|
||||||
|
#
|
||||||
|
# DOCKERHUB_REPO - docker hub repo, format: <username>/<repo>
|
||||||
|
# DOCKER_USER - login info for docker hub
|
||||||
|
# DOCKER_PASS
|
||||||
|
#
|
||||||
|
version: 2
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
docker:
|
||||||
|
- image: docker:stable-git
|
||||||
|
working_directory: /dockerflow
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- setup_remote_docker
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: os-release
|
||||||
|
command: |
|
||||||
|
cat /etc/os-release
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: install make
|
||||||
|
command: |
|
||||||
|
apk add make
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Create a Dockerfile.train
|
||||||
|
command: |
|
||||||
|
make Dockerfile.train \
|
||||||
|
DEEPSPEECH_REPO="https://github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME" \
|
||||||
|
DEEPSPEECH_SHA=$CIRCLE_SHA1
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Build Docker image
|
||||||
|
command: docker build -t app:build -f Dockerfile.train .
|
||||||
|
|
||||||
|
# save the built docker container into CircleCI's cache. This is
|
||||||
|
# required since Workflows do not have the same remote docker instance.
|
||||||
|
- run:
|
||||||
|
name: docker save app:build
|
||||||
|
command: mkdir -p /cache; docker save -o /cache/docker.tar "app:build"
|
||||||
|
- save_cache:
|
||||||
|
key: v1-{{ .Branch }}-{{epoch}}
|
||||||
|
paths:
|
||||||
|
- /cache/docker.tar
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
docker:
|
||||||
|
- image: docker:18.02.0-ce
|
||||||
|
steps:
|
||||||
|
- setup_remote_docker
|
||||||
|
- restore_cache:
|
||||||
|
key: v1-{{.Branch}}
|
||||||
|
- run:
|
||||||
|
name: Restore Docker image cache
|
||||||
|
command: docker load -i /cache/docker.tar
|
||||||
|
|
||||||
|
- run:
|
||||||
|
name: Deploy to Dockerhub
|
||||||
|
command: |
|
||||||
|
echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin
|
||||||
|
# deploy master
|
||||||
|
if [ "${CIRCLE_BRANCH}" == "master" ]; then
|
||||||
|
docker tag app:build ${DOCKERHUB_REPO}:latest
|
||||||
|
docker push ${DOCKERHUB_REPO}:latest
|
||||||
|
elif [ ! -z "${CIRCLE_TAG}" ]; then
|
||||||
|
# deploy a release tag...
|
||||||
|
echo "${DOCKERHUB_REPO}:${CIRCLE_TAG}"
|
||||||
|
docker tag app:build "${DOCKERHUB_REPO}:${CIRCLE_TAG}"
|
||||||
|
docker images
|
||||||
|
docker push "${DOCKERHUB_REPO}:${CIRCLE_TAG}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
workflows:
|
||||||
|
version: 2
|
||||||
|
build-deploy:
|
||||||
|
jobs:
|
||||||
|
- build:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
||||||
|
|
||||||
|
- deploy:
|
||||||
|
requires:
|
||||||
|
- build
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
|
@ -49,6 +49,9 @@ RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
|
||||||
RUN curl -LO "https://github.com/bazelbuild/bazel/releases/download/2.0.0/bazel_2.0.0-linux-x86_64.deb"
|
RUN curl -LO "https://github.com/bazelbuild/bazel/releases/download/2.0.0/bazel_2.0.0-linux-x86_64.deb"
|
||||||
RUN dpkg -i bazel_*.deb
|
RUN dpkg -i bazel_*.deb
|
||||||
|
|
||||||
|
# Try and free some space
|
||||||
|
RUN rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# << END Install base software
|
# << END Install base software
|
||||||
|
|
||||||
# >> START Configure Tensorflow Build
|
# >> START Configure Tensorflow Build
|
||||||
|
|
|
@ -28,6 +28,9 @@ RUN apt-get purge -y python3-xdg
|
||||||
# Install dependencies for audio augmentation
|
# Install dependencies for audio augmentation
|
||||||
RUN apt-get install -y --no-install-recommends libopus0 libsndfile1
|
RUN apt-get install -y --no-install-recommends libopus0 libsndfile1
|
||||||
|
|
||||||
|
# Try and free some space
|
||||||
|
RUN rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
RUN git lfs install
|
RUN git lfs install
|
||||||
RUN git clone $DEEPSPEECH_REPO
|
RUN git clone $DEEPSPEECH_REPO
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# This script is intended for Docker Hub Automated Builds since we can't
|
|
||||||
# build on TaskCluster because of too old Docker version (see issue #3057)
|
|
||||||
#
|
|
||||||
# Docker Hub expects an existing ready-to-use Dockerfile, and this hook allows
|
|
||||||
# to generate one basing on the existing |make| template, but we need to change
|
|
||||||
# in-place, hence why the |cp| statement
|
|
||||||
#
|
|
||||||
# Docker Hub Automated Builds needs to be configured as:
|
|
||||||
#
|
|
||||||
# Source Type | Source | Docker Tag | Dockerfile Location | Build Context
|
|
||||||
# ----------------------------------------------------------------------------------------
|
|
||||||
# Tag | /^v([0-9.\-a-zA-Z]+)/ | v{\1} | Dockerfile.train.tmpl | /
|
|
||||||
# Tag | /^v([0-9.\-a-zA-Z]+)/ | v{\1} | Dockerfile.build.tmpl | /
|
|
||||||
#
|
|
||||||
# Docker Hub Automated builds will populate some env variables:
|
|
||||||
# - DOCKERFILE_PATH: the filename defined as "Dockerfile Location"
|
|
||||||
# - SOURCE_REPOSITORY_URL: the url of the repo triggering the tag event
|
|
||||||
# - SOURCE_COMMIT: the sha1 of the commit triggering the tag event
|
|
||||||
#
|
|
||||||
# More details: https://docs.docker.com/docker-hub/builds/advanced/#environment-variables-for-building-and-testing
|
|
||||||
|
|
||||||
set -e # Exit immediately if a command exits with a non-zero status.
|
|
||||||
set -u # Treat unset variables as an error.
|
|
||||||
|
|
||||||
DOCKERFILE_TARGET=$(echo ${DOCKERFILE_PATH} | sed -e 's/\.tmpl//g')
|
|
||||||
make DEEPSPEECH_REPO=${SOURCE_REPOSITORY_URL} DEEPSPEECH_SHA=${SOURCE_COMMIT} ${DOCKERFILE_TARGET}
|
|
||||||
cp ${DOCKERFILE_TARGET} ${DOCKERFILE_PATH}
|
|
||||||
|
|
||||||
#### If you need to inspect the generated Dockerfile
|
|
||||||
## echo "----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----"
|
|
||||||
## cat ${DOCKERFILE_PATH}
|
|
||||||
## echo "----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----"
|
|
Loading…
Reference in New Issue