Skip to content

Commit

Permalink
Added Docker hub publish (#176)
Browse files Browse the repository at this point in the history
* added github workflow to publish the docker image. Runs test suit as a sanity check.

* Update update-docker-image.yml

* Update update-docker-image.yml

* Update update-docker-image.yml

* Update update-docker-image.yml

* added builds for all python versions.

* syntax

* formatting remove spaces.

* testing

* shuffle the image name concatenation.

* need to references from steps level

* need to references from steps level

* Fix docker args. hyphens are illegal it seems.

* WIP. need to version upstream deps like thet base dp lib from google. Otherwise all our stuff will break unexpectedly. Better to formally pull in deps. However, I see  doesn't have any releases yet.

* Clone submodules as well so we can peg to a SHA and not break unexpectedly. Include python 3.5 in build images

* remove 3rd party from ignore and clone the submodule instead.

* Remove cloning 3rd party deps as it was not pegged to a SHA or version. Using git submodule to ensure we pull in the correct version of 3rd code.

* explicity stated the pipenv place the venv inside the project dir. Set env vars to  the appropriate virtual env so users can simply run

* updated python version arg to upper case

* remove debugging

* debugging GITHUB_SHA

* debugging GITHUB_SHA

* removed debugging

* added docker publish stuff

* added third_party yet again to docker file

It made sense, as people using docker for development already have third-party folder cloned.

* disabled docker hub push on every release

Co-authored-by: Chinmay Shah <[email protected]>
  • Loading branch information
BenjaminDev and chinmayshah99 authored Jun 21, 2020
1 parent 2200a30 commit 883662d
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.git
/third_party
/third_party
71 changes: 71 additions & 0 deletions .github/workflows/update-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
on:
release:
types: [published]
# we wil use this as we move to regular publishing
# push:
# branches:
# - dev # add more branches as required
# # tags:
# # - [v*]
name: Update and Test Docker Image
jobs:
publish:
name: Build and publish
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8]
env:
IMAGE: openmined/pydp

steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# - name: Get the version #
# id: get_version
# run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Show python version and build image name
id: build_name
run: |
python -c "import sys; print(sys.version)"
echo "::set-output name=image_name::${IMAGE}-${GITHUB_REF##*/}-${{matrix.python-version}}"
- name: Build images
run: docker build -t ${{steps.build_name.outputs.image_name}} --build-arg PYTHON_VERSION=${{matrix.python-version}} -f Dockerfile .

- name: Tag images
run: |
docker tag ${{steps.build_name.outputs.image_name}} ${{steps.build_name.outputs.image_name}}:latest
# Pausing this temporary as we don't have verified tests
# - name: Run tests
# run:
# |
# docker run ${{steps.build_name.outputs.image_name}}:latest /bin/bash -c "pipenv install --dev && pipenv run pytest ./tests"

- name: Starting to Publish- docker login
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_LOGIN }} --password-stdin

# we want to only support release at the moment, but might need to change this later in the timeline
# - name: tag and push latest nightly images
# if: github.event_name == 'push'
# run: |
# docker tag $IMAGE $IMAGE:latest-py${{ matrix.python-version }}
# docker push $IMAGE:latest-py${{ matrix.python-version }}

- name: tag and push release image
if: github.event_name == 'release'
run: |
docker tag $IMAGE $IMAGE:${{ github.event.release.tag_name }}-py${{ matrix.python-version }}
docker push $IMAGE:${{ github.event.release.tag_name }}-py${{ matrix.python-version }}
- name: push latest stable image for python 3.7
if: github.event_name == 'release' && matrix.python-version == '3.7'
run: |
docker tag $IMAGE $IMAGE:${{ github.event.release.tag_name }}
docker push $IMAGE:${{ github.event.release.tag_name }}
docker push $IMAGE:latest
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,21 @@ RUN mkdir -p third_party && \
RUN rm -rf third_party/differential-privacy/java && \
rm -rf third_party/differential-privacy/examples/java

# This makes the pipenv's virtual environment in the project dir
ENV PIPENV_VENV_IN_PROJECT=true

# Build the bindings using Bazel and create a python wheel
RUN pipenv --python ${PYTHON_VERSION} && \
pipenv run bazel build src/python:bindings_test --verbose_failures

RUN cp -f ./bazel-bin/src/bindings/pydp.so ./pydp && \
rm -rf dist/ && \
pipenv run python setup.py bdist_wheel && \
pip install dist/*.whl
pipenv install dist/*.whl
# pip install dist/*.whl #TODO: See why one is installing outside of virtual env

# This `activates` the virtual env
ENV VIRTUAL_ENV=$PROJECT_DIR/.venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Default entrypoint
CMD ["/bin/bash"]

0 comments on commit 883662d

Please sign in to comment.