Skip to content

Commit

Permalink
[spark] Add docker_publish action
Browse files Browse the repository at this point in the history
  • Loading branch information
xyang16 committed Feb 27, 2023
1 parent ef553e1 commit bba2984
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/docker_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Docker publish

on:
schedule:
- cron: '0 15 * * *'
workflow_dispatch:
inputs:
mode:
description: 'release/nightly, default is nightly'
required: true
default: 'nightly'

jobs:
publish:
if: github.repository == 'deepjavalibrary/djl'
runs-on: ubuntu-latest
env:
DOCKER_REGISTRY: deepjavalibrary
DOCKER_REPOSITORY: djl-spark
steps:
- uses: actions/checkout@v3
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
registries: "711395599931"
- name: Login to Docker
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set variables
run: |
DJL_VERSION=$(cat gradle.properties | awk -F '=' '/djl_version/ {print $2}')
echo "DJL_VERSION=$DJL_VERSION" >> $GITHUB_ENV
- name: Build wheel
working-directory: extensions/spark/setup/
run: ./setup.py bdist_wheel
- name: Build and push nightly docker image
if: ${{ github.event.inputs.mode == '' || github.event.inputs.mode == 'nightly' }}
uses: docker/build-push-action@v3
with:
context: .
push: true
file: docker/spark/Dockerfile
tags: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}:cpu-nightly
- name: Build and push release docker image
if: ${{ github.event.inputs.mode == 'release' }}
uses: docker/build-push-action@v3
with:
context: .
file: docker/spark/Dockerfile
build-args: DJL_VERSION=${DJL_VERSION}
tags: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}:${{ env.DJL_VERSION }}-cpu
2 changes: 1 addition & 1 deletion docker/spark/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ARG TENSORFLOW_CORE_VERSION=0.4.2
ARG PROTOBUF_VERSION=3.21.9

COPY extensions/spark/setup/dist/ dist/
RUN pip3 install --no-cache-dir dist/djl_spark-${DJL_VERSION}-py3-none-any.whl && \
RUN pip3 install --no-cache-dir dist/djl_spark-*-py3-none-any.whl && \
rm -rf dist
RUN pip3 install --no-cache-dir pillow pandas numpy

Expand Down
12 changes: 11 additions & 1 deletion extensions/spark/setup/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,24 @@
pkgs = find_packages(exclude='src')


def detect_version():
with open("../../../gradle.properties", "r") as f:
for line in f:
if not line.startswith('#'):
prop = line.split('=')
if prop[0] == "djl_version":
return prop[1].strip()
return None


class BuildPy(setuptools.command.build_py.build_py):

def run(self):
setuptools.command.build_py.build_py.run(self)


if __name__ == '__main__':
version = '0.20.0'
version = detect_version()

requirements = ['packaging', 'wheel']

Expand Down

0 comments on commit bba2984

Please sign in to comment.