From 31436595c1f9cf739983efbfc1eea2e09ad3bd7e Mon Sep 17 00:00:00 2001 From: Alexandre Lissy Date: Wed, 7 Apr 2021 19:58:24 +0200 Subject: [PATCH] Fix #3603: Docker on GitHub Actions --- .circleci/config.yml | 89 ------------------------------------ .github/workflows/docker.yml | 24 ++++++++++ Dockerfile.build.tmpl | 5 +- Dockerfile.train.tmpl | 2 +- 4 files changed, 27 insertions(+), 93 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/docker.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 9e7f804d..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,89 +0,0 @@ -# These environment variables must be set in CircleCI UI -# -# DOCKERHUB_REPO - docker hub repo, format: / -# 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: /.*/ diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..742920a1 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,24 @@ +name: "Docker Images" +on: + pull_request: + push: + branches: + - master +jobs: + make-docker-img: + name: "Build Dockerfile" + runs-on: ubuntu-20.04 + strategy: + matrix: + template: ["build", "train"] + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: 'recursive' + - run: | + make Dockerfile.${{ matrix.template }} \ + DEEPSPEECH_REPO=https://github.com/${{ github.repository }} \ + DEEPSPEECH_SHA=${{ github.sha }} + - run: | + docker build -t app:${{ matrix.template }} -f Dockerfile.${{ matrix.template }} . diff --git a/Dockerfile.build.tmpl b/Dockerfile.build.tmpl index e6648102..1867068f 100644 --- a/Dockerfile.build.tmpl +++ b/Dockerfile.build.tmpl @@ -115,9 +115,8 @@ WORKDIR / RUN git clone --recursive $DEEPSPEECH_REPO DeepSpeech WORKDIR /DeepSpeech -RUN git checkout $DEEPSPEECH_SHA -RUN git submodule sync tensorflow/ -RUN git submodule update --init tensorflow/ +RUN git fetch origin $DEEPSPEECH_SHA && git checkout $DEEPSPEECH_SHA +RUN git submodule sync tensorflow/ && git submodule update --init tensorflow/ # >> START Build and bind diff --git a/Dockerfile.train.tmpl b/Dockerfile.train.tmpl index 9baa76d9..9caffe1a 100644 --- a/Dockerfile.train.tmpl +++ b/Dockerfile.train.tmpl @@ -34,7 +34,7 @@ WORKDIR / RUN git clone $DEEPSPEECH_REPO DeepSpeech WORKDIR /DeepSpeech -RUN git checkout $DEEPSPEECH_SHA +RUN git fetch origin $DEEPSPEECH_SHA && git checkout $DEEPSPEECH_SHA # Build CTC decoder first, to avoid clashes on incompatible versions upgrades RUN cd native_client/ctcdecode && make NUM_PROCESSES=$(nproc) bindings