-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable arm builds for OPA envoy plugin
Signed-off-by: Tyler Schade <[email protected]>
- Loading branch information
Showing
5 changed files
with
171 additions
and
49 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 |
---|---|---|
|
@@ -10,6 +10,7 @@ opa_* | |
_release | ||
site.tar.gz | ||
*.bak | ||
.go/ | ||
|
||
# runtime artifacts | ||
policies | ||
|
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 |
---|---|---|
|
@@ -6,18 +6,21 @@ ARG BASE | |
|
||
FROM ${BASE} | ||
|
||
LABEL org.opencontainers.image.authors="Ashutosh Narkar <[email protected]>" | ||
|
||
# Any non-zero number will do, and unfortunately a named user will not, as k8s | ||
# pod securityContext runAsNonRoot can't resolve the user ID: | ||
# https://github.com/kubernetes/kubernetes/issues/40958. | ||
ARG USER=1000:1000 | ||
USER ${USER} | ||
|
||
MAINTAINER Ashutosh Narkar <[email protected]> | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
WORKDIR /app | ||
|
||
COPY opa_envoy_linux_GOARCH /app | ||
COPY opa_envoy_${TARGETOS}_${TARGETARCH} /app | ||
|
||
ENTRYPOINT ["./opa_envoy_linux_GOARCH"] | ||
ENTRYPOINT ["./app"] | ||
|
||
CMD ["run"] |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
|
||
case "$(uname -m | tr '[:upper:]' '[:lower:]')" in | ||
amd64 | x86_64 | x64) | ||
HOST_ARCH=amd64 | ||
;; | ||
arm64 | aarch64) | ||
HOST_ARCH=arm64 | ||
;; | ||
*) | ||
echo "Error: Host architecture not supported." >&2 | ||
exit 1 | ||
;; | ||
esac | ||
|
||
# Native build | ||
if [ "${GOARCH}" = "${HOST_ARCH}" ]; then | ||
if ! [ -x "$(command -v gcc)" ]; then | ||
echo "Error: gcc not found." >&2 | ||
exit 1 | ||
fi | ||
exit 0 | ||
fi | ||
|
||
# Cross-compile | ||
case "${GOARCH}" in | ||
amd64) | ||
PKG=gcc-x86-64-linux-gnu | ||
CC=x86_64-linux-gnu-gcc | ||
;; | ||
arm64) | ||
PKG=gcc-aarch64-linux-gnu | ||
CC=aarch64-linux-gnu-gcc | ||
;; | ||
*) | ||
echo "Error: Target architecture ${GOARCH} not supported." >&2 | ||
exit 1 | ||
;; | ||
esac | ||
|
||
type -f ${CC} 2>/dev/null && exit 0 | ||
|
||
if ! [ -x "$(command -v apt-get)" ]; then | ||
echo "Error: apt-get not found. Could not install missing toolchain." >&2 | ||
exit 1 | ||
fi | ||
|
||
apt-get update >/dev/null && \ | ||
apt-get install -y ${PKG} >/dev/null | ||
|
||
echo ${CC} |
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