mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-19 10:48:59 +00:00
Update Dockerfile
to have cross-compilation on an AMD64 machine
Also revert changes in the shell scripts
This commit is contained in:
parent
4ca9606148
commit
5ab763b949
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
@ -70,8 +70,6 @@ jobs:
|
|||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
build-args: |
|
build-args: |
|
||||||
ARCH=amd64
|
|
||||||
GOARCH=amd64
|
|
||||||
SEM_VER=${{ steps.versioning.outputs.version }}
|
SEM_VER=${{ steps.versioning.outputs.version }}
|
||||||
BUILD_TIMESTAMP=${{ steps.version_parameters.outputs.build_timestamp }}
|
BUILD_TIMESTAMP=${{ steps.version_parameters.outputs.build_timestamp }}
|
||||||
GIT_BRANCH=${{ steps.version_parameters.outputs.branch }}
|
GIT_BRANCH=${{ steps.version_parameters.outputs.branch }}
|
||||||
|
65
Dockerfile
65
Dockerfile
@ -1,8 +1,7 @@
|
|||||||
ARG ARCH
|
ARG ARCH=amd64
|
||||||
ARG GOARCH
|
|
||||||
FROM ${ARCH}/node:16 AS site-build
|
### Front-end
|
||||||
ARG ARCH
|
FROM node:16 AS front-end
|
||||||
ARG GOARCH
|
|
||||||
|
|
||||||
WORKDIR /app/ui-build
|
WORKDIR /app/ui-build
|
||||||
|
|
||||||
@ -13,14 +12,16 @@ COPY ui .
|
|||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
|
||||||
FROM ${ARCH}/golang:1.17-alpine AS builder
|
### Base of the builder image
|
||||||
ARG ARCH
|
FROM golang:1.17-buster AS builder-base
|
||||||
ARG GOARCH
|
|
||||||
|
|
||||||
# Set necessary environment variables needed for our image.
|
# Set necessary environment variables needed for our image.
|
||||||
ENV CGO_ENABLED=1 GOOS=linux GOARCH=${GOARCH}
|
ENV CGO_ENABLED=1 GOOS=linux GOARCH=${GOARCH}
|
||||||
|
|
||||||
RUN apk add binutils-gold libpcap-dev gcc g++ make bash perl-utils
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
build-essential \
|
||||||
|
libpcap-dev
|
||||||
|
|
||||||
# Move to agent working directory (/agent-build).
|
# Move to agent working directory (/agent-build).
|
||||||
WORKDIR /app/agent-build
|
WORKDIR /app/agent-build
|
||||||
@ -33,15 +34,42 @@ RUN go mod download
|
|||||||
# cheap trick to make the build faster (as long as go.mod did not change)
|
# cheap trick to make the build faster (as long as go.mod did not change)
|
||||||
RUN go list -f '{{.Path}}@{{.Version}}' -m all | sed 1d | grep -e 'go-cache' | xargs go get
|
RUN go list -f '{{.Path}}@{{.Version}}' -m all | sed 1d | grep -e 'go-cache' | xargs go get
|
||||||
|
|
||||||
|
# Copy and build agent code
|
||||||
|
COPY shared ../shared
|
||||||
|
COPY tap ../tap
|
||||||
|
COPY agent .
|
||||||
|
|
||||||
|
|
||||||
|
### Intermediate builder image for AMD64 architecture
|
||||||
|
FROM builder-base AS builder-amd64
|
||||||
|
|
||||||
|
ENV GOARCH=amd64
|
||||||
|
|
||||||
|
|
||||||
|
### Intermediate builder image for ARM64 architecture
|
||||||
|
FROM builder-base AS builder-arm64v8
|
||||||
|
|
||||||
|
ENV GOARCH=arm64
|
||||||
|
ENV CC=aarch64-linux-gnu-gcc
|
||||||
|
ENV PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig
|
||||||
|
|
||||||
|
RUN dpkg --add-architecture arm64 \
|
||||||
|
&& apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
gcc-aarch64-linux-gnu \
|
||||||
|
libpcap-dev:arm64
|
||||||
|
|
||||||
|
|
||||||
|
### Final builder image where the building happens
|
||||||
|
FROM builder-${ARCH} AS builder
|
||||||
|
|
||||||
ARG COMMIT_HASH
|
ARG COMMIT_HASH
|
||||||
ARG GIT_BRANCH
|
ARG GIT_BRANCH
|
||||||
ARG BUILD_TIMESTAMP
|
ARG BUILD_TIMESTAMP
|
||||||
ARG SEM_VER=0.0.0
|
ARG SEM_VER=0.0.0
|
||||||
|
|
||||||
# Copy and build agent code
|
WORKDIR /app/agent-build
|
||||||
COPY shared ../shared
|
|
||||||
COPY tap ../tap
|
|
||||||
COPY agent .
|
|
||||||
RUN go build -ldflags="-extldflags '-fuse-ld=bfd' -s -w \
|
RUN go build -ldflags="-extldflags '-fuse-ld=bfd' -s -w \
|
||||||
-X 'mizuserver/pkg/version.GitCommitHash=${COMMIT_HASH}' \
|
-X 'mizuserver/pkg/version.GitCommitHash=${COMMIT_HASH}' \
|
||||||
-X 'mizuserver/pkg/version.Branch=${GIT_BRANCH}' \
|
-X 'mizuserver/pkg/version.Branch=${GIT_BRANCH}' \
|
||||||
@ -51,19 +79,18 @@ RUN go build -ldflags="-extldflags '-fuse-ld=bfd' -s -w \
|
|||||||
COPY devops/build_extensions.sh ..
|
COPY devops/build_extensions.sh ..
|
||||||
RUN cd .. && /bin/bash build_extensions.sh
|
RUN cd .. && /bin/bash build_extensions.sh
|
||||||
|
|
||||||
FROM ${ARCH}/alpine:3.15
|
|
||||||
ARG ARCH
|
|
||||||
ARG GOARCH
|
|
||||||
|
|
||||||
RUN apk add bash libpcap-dev
|
|
||||||
|
### The shipped image
|
||||||
|
ARG ARCH=amd64
|
||||||
|
FROM ${ARCH}/alpine:3.15
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy binary and config files from /build to root folder of scratch container.
|
# Copy binary and config files from /build to root folder of scratch container.
|
||||||
COPY --from=builder ["/app/agent-build/mizuagent", "."]
|
COPY --from=builder ["/app/agent-build/mizuagent", "."]
|
||||||
COPY --from=builder ["/app/agent/build/extensions", "extensions"]
|
COPY --from=builder ["/app/agent/build/extensions", "extensions"]
|
||||||
COPY --from=site-build ["/app/ui-build/build", "site"]
|
COPY --from=front-end ["/app/ui-build/build", "site"]
|
||||||
RUN mkdir /app/data/
|
|
||||||
|
|
||||||
# gin-gonic runs in debug mode without this
|
# gin-gonic runs in debug mode without this
|
||||||
ENV GIN_MODE=release
|
ENV GIN_MODE=release
|
||||||
|
@ -10,7 +10,7 @@ Basic APIs:
|
|||||||
1. Run `go get github.com/go-delve/delve/cmd/dlv`
|
1. Run `go get github.com/go-delve/delve/cmd/dlv`
|
||||||
2. Create a "Go Remote" run/debug configuration in Intellij, set to localhost:2345
|
2. Create a "Go Remote" run/debug configuration in Intellij, set to localhost:2345
|
||||||
3. Build and push a debug image using
|
3. Build and push a debug image using
|
||||||
`docker build . -t gcr.io/up9-docker-hub/mizu/debug:latest --build-arg ARCH=amd64 --build-arg GOARCH=amd64 -f debug.Dockerfile && docker push gcr.io/up9-docker-hub/mizu/debug:latest`
|
`docker build . -t gcr.io/up9-docker-hub/mizu/debug:latest -f debug.Dockerfile && docker push gcr.io/up9-docker-hub/mizu/debug:latest`
|
||||||
|
|
||||||
### Connecting
|
### Connecting
|
||||||
1. Start mizu using the cli with the debug
|
1. Start mizu using the cli with the debug
|
||||||
|
@ -21,7 +21,7 @@ fi
|
|||||||
|
|
||||||
echo "building ${DOCKER_TAGGED_BUILDS[@]}"
|
echo "building ${DOCKER_TAGGED_BUILDS[@]}"
|
||||||
DOCKER_TAGS_ARGS=$(echo ${DOCKER_TAGGED_BUILDS[@]/#/-t }) # "-t FIRST_TAG -t SECOND_TAG ..."
|
DOCKER_TAGS_ARGS=$(echo ${DOCKER_TAGGED_BUILDS[@]/#/-t }) # "-t FIRST_TAG -t SECOND_TAG ..."
|
||||||
docker build $DOCKER_TAGS_ARGS --build-arg ARCH=${ARCH} --build-arg GOARCH=${GOARCH} --build-arg SEM_VER=${SEM_VER} --build-arg BUILD_TIMESTAMP=${BUILD_TIMESTAMP} --build-arg GIT_BRANCH=${GIT_BRANCH} --build-arg COMMIT_HASH=${COMMIT_HASH} .
|
docker build $DOCKER_TAGS_ARGS --build-arg SEM_VER=${SEM_VER} --build-arg BUILD_TIMESTAMP=${BUILD_TIMESTAMP} --build-arg GIT_BRANCH=${GIT_BRANCH} --build-arg COMMIT_HASH=${COMMIT_HASH} .
|
||||||
|
|
||||||
for DOCKER_TAG in "${DOCKER_TAGGED_BUILDS[@]}"
|
for DOCKER_TAG in "${DOCKER_TAGGED_BUILDS[@]}"
|
||||||
do
|
do
|
||||||
|
@ -14,4 +14,4 @@ GOARCH=$ARCH
|
|||||||
DOCKER_TAGGED_BUILD="$DOCKER_REPO:$SEM_VER"
|
DOCKER_TAGGED_BUILD="$DOCKER_REPO:$SEM_VER"
|
||||||
|
|
||||||
echo "building $DOCKER_TAGGED_BUILD"
|
echo "building $DOCKER_TAGGED_BUILD"
|
||||||
docker build -t ${DOCKER_TAGGED_BUILD} --build-arg ARCH=${ARCH} --build-arg GOARCH=${GOARCH} --build-arg SEM_VER=${SEM_VER} --build-arg BUILD_TIMESTAMP=${BUILD_TIMESTAMP} --build-arg GIT_BRANCH=${GIT_BRANCH} --build-arg COMMIT_HASH=${COMMIT_HASH} .
|
docker build -t ${DOCKER_TAGGED_BUILD} --build-arg SEM_VER=${SEM_VER} --build-arg BUILD_TIMESTAMP=${BUILD_TIMESTAMP} --build-arg GIT_BRANCH=${GIT_BRANCH} --build-arg COMMIT_HASH=${COMMIT_HASH} .
|
||||||
|
@ -21,7 +21,7 @@ fi
|
|||||||
|
|
||||||
echo "building ${DOCKER_TAGGED_BUILDS[@]}"
|
echo "building ${DOCKER_TAGGED_BUILDS[@]}"
|
||||||
DOCKER_TAGS_ARGS=$(echo ${DOCKER_TAGGED_BUILDS[@]/#/-t }) # "-t FIRST_TAG -t SECOND_TAG ..."
|
DOCKER_TAGS_ARGS=$(echo ${DOCKER_TAGGED_BUILDS[@]/#/-t }) # "-t FIRST_TAG -t SECOND_TAG ..."
|
||||||
docker build -f debug.Dockerfile $DOCKER_TAGS_ARGS --build-arg ARCH=${ARCH} --build-arg GOARCH=${GOARCH} --build-arg SEM_VER=${SEM_VER} --build-arg BUILD_TIMESTAMP=${BUILD_TIMESTAMP} --build-arg GIT_BRANCH=${GIT_BRANCH} --build-arg COMMIT_HASH=${COMMIT_HASH} .
|
docker build -f debug.Dockerfile $DOCKER_TAGS_ARGS --build-arg SEM_VER=${SEM_VER} --build-arg BUILD_TIMESTAMP=${BUILD_TIMESTAMP} --build-arg GIT_BRANCH=${GIT_BRANCH} --build-arg COMMIT_HASH=${COMMIT_HASH} .
|
||||||
|
|
||||||
for DOCKER_TAG in "${DOCKER_TAGGED_BUILDS[@]}"
|
for DOCKER_TAG in "${DOCKER_TAGGED_BUILDS[@]}"
|
||||||
do
|
do
|
||||||
|
@ -21,7 +21,7 @@ fi
|
|||||||
|
|
||||||
echo "building ${DOCKER_TAGGED_BUILDS[@]}"
|
echo "building ${DOCKER_TAGGED_BUILDS[@]}"
|
||||||
DOCKER_TAGS_ARGS=$(echo ${DOCKER_TAGGED_BUILDS[@]/#/-t }) # "-t FIRST_TAG -t SECOND_TAG ..."
|
DOCKER_TAGS_ARGS=$(echo ${DOCKER_TAGGED_BUILDS[@]/#/-t }) # "-t FIRST_TAG -t SECOND_TAG ..."
|
||||||
docker build $DOCKER_TAGS_ARGS --build-arg SEM_VER=${SEM_VER} --build-arg ARCH=${ARCH} --build-arg GOARCH=${GOARCH} --build-arg BUILD_TIMESTAMP=${BUILD_TIMESTAMP} --build-arg GIT_BRANCH=${GIT_BRANCH} --build-arg COMMIT_HASH=${COMMIT_HASH} .
|
docker build $DOCKER_TAGS_ARGS --build-arg SEM_VER=${SEM_VER} --build-arg BUILD_TIMESTAMP=${BUILD_TIMESTAMP} --build-arg GIT_BRANCH=${GIT_BRANCH} --build-arg COMMIT_HASH=${COMMIT_HASH} .
|
||||||
|
|
||||||
for DOCKER_TAG in "${DOCKER_TAGGED_BUILDS[@]}"
|
for DOCKER_TAG in "${DOCKER_TAGGED_BUILDS[@]}"
|
||||||
do
|
do
|
||||||
|
Loading…
Reference in New Issue
Block a user