github.com/anycable/anycable-go@v1.5.1/.github/workflows/release-docker.yml (about) 1 name: Publish Docker images 2 on: 3 release: 4 types: [published] 5 workflow_dispatch: 6 7 jobs: 8 push_to_dockerhub: 9 runs-on: ubuntu-20.04 10 env: 11 GO111MODULE: on 12 CGO_ENABLED: "0" 13 GOFLAGS: "-mod=vendor" 14 steps: 15 - uses: actions/checkout@v4 16 - name: Install system deps 17 run: | 18 sudo apt-get update 19 sudo apt-get install bison 20 - uses: actions/cache@v1 21 with: 22 path: vendor 23 key: vendor-${{ hashFiles('**/go.sum') }} 24 restore-keys: | 25 vendor- 26 - run: go mod vendor 27 - name: Build mruby 28 run: bash -c '(cd vendor/github.com/mitchellh/go-mruby && MRUBY_CONFIG=../../../../../../etc/build_config.rb make libmruby.a)' 29 - uses: actions/setup-go@v4 30 with: 31 go-version-file: go.mod 32 - name: Set VERSION (if any) 33 if: ${{ contains(github.ref, 'refs/tags/v') }} 34 id: version 35 run: | 36 echo VERSION=${GITHUB_REF#refs/tags/v} >> $GITHUB_OUTPUT 37 - name: Prepare files for Docker build 38 run: | 39 cp /etc/ssl/certs/ca-certificates.crt ./.docker/ca-certificates.crt 40 - name: Build binary 41 run: | 42 env GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X github.com/anycable/anycable-go/version.version=${{ steps.version.outputs.VERSION }} -X github.com/anycable/anycable-go/version.sha=$(echo "$GITHUB_SHA" | cut -c -7)" -a -o .docker/linux/arm64/anycable-go cmd/anycable-go/main.go 43 env GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X github.com/anycable/anycable-go/version.version=${{ steps.version.outputs.VERSION }} -X github.com/anycable/anycable-go/version.sha=$(echo "$GITHUB_SHA" | cut -c -7)" -a -o .docker/linux/amd64/anycable-go cmd/anycable-go/main.go 44 .docker/linux/amd64/anycable-go -v 45 - uses: docker/setup-buildx-action@v2 46 - uses: docker/login-action@v2 47 with: 48 username: ${{ secrets.DOCKERHUB_USERNAME }} 49 password: ${{ secrets.DOCKERHUB_TOKEN }} 50 - name: Prepare Docker metadata and versions 51 id: meta 52 uses: docker/metadata-action@v4 53 with: 54 flavor: | 55 latest=auto 56 images: | 57 anycable/anycable-go 58 tags: | 59 type=semver,pattern={{version}} 60 type=semver,pattern={{major}}.{{minor}} 61 type=semver,pattern={{major}} 62 type=sha,prefix= 63 type=edge,branch=master 64 - name: Build and push base images 65 uses: docker/build-push-action@v4 66 with: 67 context: . 68 file: .docker/Dockerfile.universal 69 push: true 70 platforms: linux/amd64,linux/arm64 71 tags: ${{ steps.meta.outputs.tags }} 72 labels: | 73 maintainer=Vladimir Dementyev 74 org.opencontainers.image.description=AnyCable WebSocket server 75 org.opencontainers.image.vendor=Evil Martians 76 org.opencontainers.image.url=https://anycable.io 77 org.opencontainers.image.source=https://github.com/anycable/anycable-go 78 org.opencontainers.image.documentation=https://docs.anycable.io 79 org.opencontainers.image.licenses=MIT 80 - name: Prepare Docker metadata and versions for alpine image 81 id: meta-alpine 82 uses: docker/metadata-action@v3 83 with: 84 flavor: | 85 latest=auto 86 prefix= 87 suffix=-alpine,onlatest=true 88 images: | 89 anycable/anycable-go 90 tags: | 91 type=semver,pattern={{version}} 92 type=semver,pattern={{major}}.{{minor}} 93 type=semver,pattern={{major}} 94 type=sha,prefix= 95 type=edge,branch=master 96 - name: Build and push alpine images 97 uses: docker/build-push-action@v4 98 with: 99 context: . 100 file: .docker/Dockerfile.alpine 101 push: true 102 platforms: linux/amd64,linux/arm64 103 tags: ${{ steps.meta-alpine.outputs.tags }} 104 labels: | 105 maintainer=Vladimir Dementyev 106 org.opencontainers.image.description=AnyCable WebSocket server 107 org.opencontainers.image.vendor=Evil Martians 108 org.opencontainers.image.url=https://anycable.io 109 org.opencontainers.image.source=https://github.com/anycable/anycable-go 110 org.opencontainers.image.documentation=https://docs.anycable.io 111 org.opencontainers.image.licenses=MIT 112 - name: Build binary with MRuby 113 env: 114 CGO_ENABLED: "1" 115 run: | 116 env GOOS=linux GOARCH=amd64 go build -tags mrb -ldflags "-s -w -X github.com/anycable/anycable-go/version.version=${{ steps.version.outputs.VERSION }} -X github.com/anycable/anycable-go/version.sha=$(echo "$GITHUB_SHA" | cut -c -7)" -a -o .docker/linux/amd64/anycable-go cmd/anycable-go/main.go 117 .docker/linux/amd64/anycable-go -v 118 - name: Prepare Docker metadata and versions for mrb image 119 id: meta-mrb 120 uses: docker/metadata-action@v3 121 with: 122 flavor: | 123 latest=auto 124 prefix= 125 suffix=-mrb,onlatest=true 126 images: | 127 anycable/anycable-go 128 tags: | 129 type=semver,pattern={{version}} 130 type=semver,pattern={{major}}.{{minor}} 131 type=semver,pattern={{major}} 132 type=sha,prefix= 133 type=edge,branch=master 134 - name: Build and push mrb images 135 uses: docker/build-push-action@v4 136 with: 137 context: . 138 file: .docker/Dockerfile.mrb-linux-amd64 139 push: true 140 tags: ${{ steps.meta-mrb.outputs.tags }} 141 labels: | 142 maintainer=Vladimir Dementyev 143 org.opencontainers.image.description=AnyCable WebSocket server 144 org.opencontainers.image.vendor=Evil Martians 145 org.opencontainers.image.url=https://anycable.io 146 org.opencontainers.image.source=https://github.com/anycable/anycable-go 147 org.opencontainers.image.documentation=https://docs.anycable.io 148 org.opencontainers.image.licenses=MIT