-
-
Notifications
You must be signed in to change notification settings - Fork 65
149 lines (148 loc) · 6.33 KB
/
release-docker.yml
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Publish Docker images
on:
release:
types: [published]
workflow_dispatch:
jobs:
push_to_dockerhub:
runs-on: ubuntu-20.04
env:
GO111MODULE: on
CGO_ENABLED: "0"
GOFLAGS: "-mod=vendor"
ANYCABLE_TELEMETRY_TOKEN: ${{ secrets.ANYCABLE_TELEMETRY_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Install system deps
run: |
sudo apt-get update
sudo apt-get install bison
- uses: actions/cache@v1
with:
path: vendor
key: vendor-${{ hashFiles('**/go.sum') }}
restore-keys: |
vendor-
- run: go mod vendor
- name: Build mruby
run: bash -c '(cd vendor/github.com/mitchellh/go-mruby && MRUBY_CONFIG=../../../../../../etc/build_config.rb make libmruby.a)'
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Set VERSION (if any)
if: ${{ contains(github.ref, 'refs/tags/v') }}
id: version
run: |
echo VERSION=${GITHUB_REF#refs/tags/v} >> $GITHUB_OUTPUT
- name: Prepare files for Docker build
run: |
cp /etc/ssl/certs/ca-certificates.crt ./.docker/ca-certificates.crt
- name: Build binary
run: |
env GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X github.com/anycable/anycable-go/telemetry.auth=$(echo "$ANYCABLE_TELEMETRY_TOKEN") -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
env GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X github.com/anycable/anycable-go/telemetry.auth=$(echo "$ANYCABLE_TELEMETRY_TOKEN") -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
.docker/linux/amd64/anycable-go -v
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Prepare Docker metadata and versions
id: meta
uses: docker/metadata-action@v4
with:
flavor: |
latest=auto
images: |
anycable/anycable-go
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix=
type=edge,branch=master
- name: Build and push base images
uses: docker/build-push-action@v4
with:
context: .
file: .docker/Dockerfile.universal
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: |
maintainer=Vladimir Dementyev
org.opencontainers.image.description=AnyCable WebSocket server
org.opencontainers.image.vendor=Evil Martians
org.opencontainers.image.url=https://anycable.io
org.opencontainers.image.source=https://github.com/anycable/anycable-go
org.opencontainers.image.documentation=https://docs.anycable.io
org.opencontainers.image.licenses=MIT
- name: Prepare Docker metadata and versions for alpine image
id: meta-alpine
uses: docker/metadata-action@v3
with:
flavor: |
latest=auto
prefix=
suffix=-alpine,onlatest=true
images: |
anycable/anycable-go
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix=
type=edge,branch=master
- name: Build and push alpine images
uses: docker/build-push-action@v4
with:
context: .
file: .docker/Dockerfile.alpine
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta-alpine.outputs.tags }}
labels: |
maintainer=Vladimir Dementyev
org.opencontainers.image.description=AnyCable WebSocket server
org.opencontainers.image.vendor=Evil Martians
org.opencontainers.image.url=https://anycable.io
org.opencontainers.image.source=https://github.com/anycable/anycable-go
org.opencontainers.image.documentation=https://docs.anycable.io
org.opencontainers.image.licenses=MIT
- name: Build binary with MRuby
env:
CGO_ENABLED: "1"
run: |
env GOOS=linux GOARCH=amd64 go build -tags mrb -ldflags "-s -w -X github.com/anycable/anycable-go/telemetry.auth=$(echo "$ANYCABLE_TELEMETRY_TOKEN") -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
.docker/linux/amd64/anycable-go -v
- name: Prepare Docker metadata and versions for mrb image
id: meta-mrb
uses: docker/metadata-action@v3
with:
flavor: |
latest=auto
prefix=
suffix=-mrb,onlatest=true
images: |
anycable/anycable-go
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix=
type=edge,branch=master
- name: Build and push mrb images
uses: docker/build-push-action@v4
with:
context: .
file: .docker/Dockerfile.mrb-linux-amd64
push: true
tags: ${{ steps.meta-mrb.outputs.tags }}
labels: |
maintainer=Vladimir Dementyev
org.opencontainers.image.description=AnyCable WebSocket server
org.opencontainers.image.vendor=Evil Martians
org.opencontainers.image.url=https://anycable.io
org.opencontainers.image.source=https://github.com/anycable/anycable-go
org.opencontainers.image.documentation=https://docs.anycable.io
org.opencontainers.image.licenses=MIT