-
Notifications
You must be signed in to change notification settings - Fork 4
100 lines (92 loc) · 2.89 KB
/
server-docker.yml
File metadata and controls
100 lines (92 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: "Docker Server Image"
on:
schedule:
- cron: '0 23 * * 1'
workflow_dispatch:
inputs:
repository_url:
required: true
default: 'apache/hugegraph'
repository_branch:
required: true
default: 'master'
image_url:
required: true
default: 'hugegraph/hugegraph'
tag:
required: true
default: 'latest'
jobs:
build:
runs-on: ubuntu-latest
env:
# TODO: support auto tag/label the images by action
# Refer: https://docs.docker.com/build/ci/github-actions/manage-tags-labels/
repository_url: apache/hugegraph
repository_branch: master
image_url: hugegraph/hugegraph:latest
steps:
- name: Reset If Need
if: github.event_name == 'workflow_dispatch'
run: |
echo "repository_url=${{ inputs.repository_url }}" >> $GITHUB_ENV
echo "repository_branch=${{ inputs.repository_branch }}" >> $GITHUB_ENV
echo "image_url=${{ inputs.image_url }}" >> $GITHUB_ENV
echo "tag=${{ inputs.tag }}" >> $GITHUB_ENV
# Used for build X64 & ARM images together
# Refer: https://github.com/marketplace/actions/docker-setup-buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
#registry: ${{ inputs.image_url }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Checkout
uses: actions/checkout@v3
with:
repository: ${{ env.repository_url }}
ref: ${{ env.repository_branch }}
fetch-depth: 2
- name: Build X86 Image
uses: docker/build-push-action@v4
with:
context: .
load: true
tags: ${{ env.image_url }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test X86 Image
run: |
docker images
docker run -itd --name=graph -p 18080:8080 $image_url
sleep 20s
curl 0.0.0.0:18080 || exit
docker ps -a
sleep 20s
curl 0.0.0.0:18080 || exit
docker ps -a
- name: Build ARM & Push all
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.image_url }}
cache-from: type=gha
cache-to: type=gha,mode=max
# - name: Publish Docker images
# run: |
# pwd && ls -lh
# export DOCKER_CLI_EXPERIMENTAL=enabled
# docker version
# docker build -t $IMAGE_URI .
# docker images
# docker run -itd $IMAGE_URI
# sleep 15s
# docker ps -a
# sleep 15s
# docker ps -a
# docker push $IMAGE_URI