aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/container_rocksdb_version.yml
blob: 83ae26d25902b6e19b2ea3e44999d7f1bf61f90d (plain)
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
101
102
103
104
105
106
107
108
109
110
name: "docker: build rocksdb image by version"

on:
  workflow_dispatch:
    inputs:
      rocksdb_version:
        description: 'RocksDB git tag or branch to build (e.g. v10.5.1)'
        required: true
        default: 'v10.5.1'
      seaweedfs_ref:
        description: 'SeaweedFS git tag, branch, or commit to build'
        required: true
        default: 'master'
      image_tag:
        description: 'Optional Docker tag suffix (defaults to rocksdb_<rocksdb>_seaweedfs_<ref>)'
        required: false
        default: ''

permissions:
  contents: read

jobs:
  build-rocksdb-image:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v2

      - name: Prepare Docker tag
        id: tag
        env:
          ROCKSDB_VERSION_INPUT: ${{ inputs.rocksdb_version }}
          SEAWEEDFS_REF_INPUT: ${{ inputs.seaweedfs_ref }}
          CUSTOM_TAG_INPUT: ${{ inputs.image_tag }}
        run: |
          set -euo pipefail
          sanitize() {
            local value="$1"
            value="${value,,}"
            value="${value// /-}"
            value="${value//[^a-z0-9_.-]/-}"
            value="${value#-}"
            value="${value%-}"
            printf '%s' "$value"
          }
          version="${ROCKSDB_VERSION_INPUT}"
          seaweed="${SEAWEEDFS_REF_INPUT}"
          tag="${CUSTOM_TAG_INPUT}"
          if [ -z "$version" ]; then
            echo "RocksDB version input is required." >&2
            exit 1
          fi
          if [ -z "$seaweed" ]; then
            echo "SeaweedFS ref input is required." >&2
            exit 1
          fi
          sanitized_version="$(sanitize "$version")"
          if [ -z "$sanitized_version" ]; then
            echo "Unable to sanitize RocksDB version '$version'." >&2
            exit 1
          fi
          sanitized_seaweed="$(sanitize "$seaweed")"
          if [ -z "$sanitized_seaweed" ]; then
            echo "Unable to sanitize SeaweedFS ref '$seaweed'." >&2
            exit 1
          fi
          if [ -z "$tag" ]; then
            tag="rocksdb_${sanitized_version}_seaweedfs_${sanitized_seaweed}"
          fi
          tag="${tag,,}"
          tag="${tag// /-}"
          tag="${tag//[^a-z0-9_.-]/-}"
          tag="${tag#-}"
          tag="${tag%-}"
          if [ -z "$tag" ]; then
            echo "Resulting Docker tag is empty." >&2
            exit 1
          fi
          echo "docker_tag=$tag" >> "$GITHUB_OUTPUT"
          echo "full_image=chrislusf/seaweedfs:$tag" >> "$GITHUB_OUTPUT"
          echo "seaweedfs_ref=$seaweed" >> "$GITHUB_OUTPUT"

      - name: Set up QEMU
        uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v1

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v1

      - name: Login to Docker Hub
        uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: Build and push image
        uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v2
        with:
          context: ./docker
          push: true
          file: ./docker/Dockerfile.rocksdb_large
          build-args: |
            ROCKSDB_VERSION=${{ inputs.rocksdb_version }}
            BRANCH=${{ inputs.seaweedfs_ref }}
          platforms: linux/amd64
          tags: ${{ steps.tag.outputs.full_image }}
          labels: |
            org.opencontainers.image.title=seaweedfs
            org.opencontainers.image.description=SeaweedFS is a distributed storage system for blobs, objects, files, and data lake, to store and serve billions of files fast!
            org.opencontainers.image.vendor=Chris Lu