-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AMD64 and ARM64 for now. The Tyk plugin depends on the tykio/tyk-plugin-compiler image which does not support any other architecture than AMD64 for now. See TykTechnologies/tyk-build-env#4 ARMv7 was tried but Kong and Tyk do not support it and it may introduce issues due to its 32-bit architecture that we don't want to have to support. Signed-off-by: Felix Kaechele <[email protected]>
- Loading branch information
Showing
6 changed files
with
147 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,13 @@ jobs: | |
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Check licenses | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
@@ -32,8 +39,66 @@ jobs: | |
- name: Run verification | ||
run: make check | ||
|
||
- name: Build Docker image | ||
run: make docker | ||
- name: Get current timestamp | ||
id: timestamp | ||
run: echo "::set-output name=timestamp::$(date -u +'%Y-%m-%dT%H:%M:%SZ')" | ||
|
||
- name: Build APIClarity | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ghcr.io/apiclarity/apiclarity:${{ github.sha }} | ||
file: Dockerfile | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
build-args: | | ||
VERSION=${{ github.sha }} | ||
BUILD_TIMESTAMP=${{ steps.timestamp.outputs.timestamp }} | ||
COMMIT_HASH=${{ github.sha }} | ||
- name: Build Kong plugin | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: plugins | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ghcr.io/apiclarity/kong-plugin:${{ github.sha }} | ||
file: plugins/Dockerfile.kong | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
|
||
- name: Fix Tyk Plugin API dep | ||
id: tyk-dep | ||
run: | | ||
cd plugins/gateway/tyk/v3.2.2 | ||
go mod edit -replace github.com/apiclarity/apiclarity/plugins/[email protected]=./../api | ||
go mod edit -replace github.com/apiclarity/apiclarity/plugins/[email protected]=./../common | ||
- name: Build Tyk plugin | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: plugins | ||
platforms: linux/amd64 # tykio/tyk-plugin-compiler does not currently support other architectures | ||
tags: ghcr.io/apiclarity/tyk-plugin-v3.2.2:${{ github.sha }} | ||
file: plugins/Dockerfile.tyk.v3.2.2 | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
|
||
- name: Undo Tyk Plugin API dep change | ||
id: undo-tyk-dep | ||
run: git checkout -- plugins/gateway/tyk/v3.2.2/go.mod | ||
|
||
- name: Build passive taper | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: plugins | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ghcr.io/apiclarity/passive-taper:${{ github.sha }} | ||
file: plugins/Dockerfile.taper | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
build-args: | | ||
VERSION=${{ github.sha }} | ||
lint_chart: | ||
name: Lint Helm Chart | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,39 @@ | ||
FROM golang:1.16.6-alpine AS builder | ||
## Common build steps for plugins | ||
# Cross-compilation tools | ||
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx | ||
|
||
## Note: this Dockerfile will only be built from the plugins context | ||
FROM --platform=$BUILDPLATFORM golang:1.16.6-alpine AS builder | ||
|
||
RUN apk add --update --no-cache gcc g++ | ||
# Copy cross-compilation tools | ||
COPY --from=xx / / | ||
|
||
WORKDIR /plugins | ||
COPY api ./api | ||
# To optimize caching and multi-architecture we try to get in as much upfront | ||
# work as possible before branching out using our actual source | ||
WORKDIR /plugins/api | ||
COPY api/go.* ./ | ||
RUN go mod download | ||
|
||
WORKDIR /plugins/common | ||
|
||
COPY common/go.* ./ | ||
RUN go mod download | ||
|
||
COPY common ./ | ||
WORKDIR /plugins | ||
COPY api ./api | ||
COPY common ./common | ||
|
||
## Kong plugin build steps | ||
WORKDIR /plugins/gateway/kong | ||
COPY gateway/kong/go.* ./ | ||
|
||
# Cache optimization: Avoid go module downloads unless go.mod/go.sum changed | ||
COPY gateway/kong/go.* ./ | ||
RUN go mod download | ||
|
||
COPY gateway/kong . | ||
|
||
# Build the plugin. | ||
RUN go build -o bin/kong-plugin plugin.go | ||
ARG TARGETPLATFORM | ||
ENV CGO_ENABLED=0 | ||
RUN xx-go build -o bin/kong-plugin plugin.go | ||
|
||
FROM busybox | ||
COPY --from=builder ["/plugins/gateway/kong/bin/kong-plugin", "/kong-plugin"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters