Skip to content

Commit

Permalink
Add dockerfile and env_prepare.sh
Browse files Browse the repository at this point in the history
Signed-off-by: yanjianbo <[email protected]>
  • Loading branch information
yanjianbo1983 committed Jan 8, 2024
1 parent fa48f75 commit 888dc87
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.17.13 as builder
ARG pluginVersion=v0.9.1
COPY . /plugins
RUN cd /plugins && \
bash build_linux.sh -ldflags "-extldflags -static -X 'github.com/containernetworking/plugins/pkg/utils/buildversion.BuildVersion=${pluginVersion}'"

FROM alpine:3.15

RUN mkdir -p /plugins/bin
COPY --from=builder /plugins/bin/bridge \
/plugins/bin/host-local \
/plugins/bin/loopback \
/plugins/bin/portmap \
/plugins/bin/bandwidth \
/plugins/bin/
COPY --from=builder /plugins/scripts/env_prepare.sh /plugins/
16 changes: 16 additions & 0 deletions build-and-push-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

VERSION=${1:-latest}

if [[ $(docker buildx ls) != *"mybuilder"* ]]; then
docker buildx create --name mybuilder --bootstrap --use
fi
docker buildx use mybuilder

docker buildx build \
--build-arg="pluginVersion=${VERSION}" \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
--push \
-t fabedge/cni-plugins:${VERSION} .

docker buildx use default
19 changes: 19 additions & 0 deletions scripts/env_prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

set -x

# install CNI plugins
find /etc/cni/net.d/ -type f -not -name fabedge.conflist -exec rm {} \;
cp -f /plugins/bin/bridge \
/plugins/bin/host-local \
/plugins/bin/loopback \
/plugins/bin/portmap \
/plugins/bin/bandwidth /opt/cni/bin

# cleanup flannel stuff
ip link delete cni0
ip link delete flannel.1
ip route | grep "flannel" | while read dst via gw others; do ip route delete $dst via $gw; done
iptables -t nat -F POSTROUTING

exit 0

0 comments on commit 888dc87

Please sign in to comment.