Skip to content
Permalink
Browse files
Publish docker images by actions (#153)
* publish docker images by actions
* rename computer-algorithm-based.jar to hugegraph-builtin-algorithms.jar
* add build_images.sh
  • Loading branch information
coderzc committed Dec 2, 2021
1 parent b3891b4 commit bba8c754257c6fa33c227b14507856ba5ecd5396
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 5 deletions.
@@ -0,0 +1,72 @@
name: Publish hugegraph-computer images

on:
push:
branches:
- master
release:
types: [ published ]

jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Mapping env
uses: kanga333/variable-mapper@master
with:
key: "${{github.event_name}}"
map: |
{
"push": {
"FRAMEWORK_IMAGE_URL": "hugegraph/hugegraph-computer-framework:latest",
"ALGORITHM_IMAGE_URL": "hugegraph/hugegraph-builtin-algorithms:latest",
"OPERATOR_IMAGE_URL": "hugegraph/hugegraph-computer-operator:latest"
},
"release": {
"FRAMEWORK_IMAGE_URL": "hugegraph/hugegraph-computer-framework:${{ github.ref_name }}",
"ALGORITHM_IMAGE_URL": "hugegraph/hugegraph-builtin-algorithms:${{ github.ref_name }}",
"OPERATOR_IMAGE_URL": "hugegraph/hugegraph-computer-operator:${{ github.ref_name }}"
}
}
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
registry: ''
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Install JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'

- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: Build Project
run: bash computer-dist/builddocker.sh

- name: Build images
env:
TRAVIS_DIR: computer-dist/src/assembly/travis
run: $TRAVIS_DIR/build_images.sh ${{ env.FRAMEWORK_IMAGE_URL }} ${{ env.ALGORITHM_IMAGE_URL }} ${{ env.OPERATOR_IMAGE_URL }}

- name: Docker images
run: docker images

- name: Publish
run: |
docker push ${{ env.FRAMEWORK_IMAGE_URL }}
docker push ${{ env.ALGORITHM_IMAGE_URL }}
docker push ${{ env.OPERATOR_IMAGE_URL }}
@@ -2,6 +2,6 @@ FROM hugegraph/hugegraph-computer-framework:latest

LABEL maintainer="HugeGraph Docker Maintainers <hugegraph@googlegroups.com>"

ARG jarFilePath="/opt/jars/computer-algorithm-based.jar"
ARG jarFilePath="/opt/jars/hugegraph-builtin-algorithms.jar"
COPY target/computer-algorithm-*.jar ${jarFilePath}
ENV JAR_FILE_PATH=${jarFilePath}
@@ -1,8 +1,12 @@
#!/usr/bin/env bash

set -ev

BASE_DIR=$(cd "$(dirname "$0")" && pwd -P)
PROJECT_PATH="$(cd "${BASE_DIR}/.." && pwd -P)"
PROJECT_PATH="$(cd "${BASE_DIR}/../../../.." && pwd -P)"
PROJECT_POM_PATH="${PROJECT_PATH}/pom.xml"
JAR_FILE_PATH=/opt/jars/hugegraph-builtin-algorithms.jar

mvn -f "${PROJECT_POM_PATH}" clean package -DskipTests

CONTEXT_PATH=$(mvn -f "${PROJECT_POM_PATH}" -q -N \
@@ -14,5 +18,12 @@ PROJECT_VERSION=$(mvn -f "${PROJECT_POM_PATH}" -q -N \
org.codehaus.mojo:exec-maven-plugin:1.3.1:exec \
-Dexec.executable='echo' -Dexec.args='${project.version}')

docker build -t "hugegraph/hugegraph-computer-framework:${PROJECT_VERSION}" \
"${CONTEXT_PATH}" -f "${BASE_DIR}"/Dockerfile
docker build -t $1 $CONTEXT_PATH -f $PROJECT_PATH/computer-dist/Dockerfile

echo "FROM $1
LABEL maintainer='HugeGraph Docker Maintainers <hugegraph@googlegroups.com>'
COPY target/computer-algorithm-*.jar $JAR_FILE_PATH
ENV JAR_FILE_PATH=$JAR_FILE_PATH" | \
docker build -t $2 -f - $PROJECT_PATH/computer-algorithm

docker build -t $3 -f $PROJECT_PATH/computer-k8s-operator/Dockerfile $PROJECT_PATH/computer-k8s-operator
@@ -50,7 +50,7 @@ spec:
jobId: *jobName
algorithmName: page_rank
image: hugegraph/hugegraph-computer-based-algorithm:latest # algorithm image url
jarFile: /opt/jars/computer-algorithm-based.jar
jarFile: /opt/jars/hugegraph-builtin-algorithms.jar
pullPolicy: Always
workerInstances: 50
computerConf:

0 comments on commit bba8c75

Please sign in to comment.