diff --git a/Makefile b/Makefile index fd372e5b..b2fa7edf 100644 --- a/Makefile +++ b/Makefile @@ -68,30 +68,30 @@ build: manifests generate fmt vet build-terway build-terway-controlplane .PHONY: build-policy build-policy: - docker buildx build --build-arg GIT_VERSION=$(GIT_COMMIT_SHORT) --platform $(BUILD_PLATFORMS) -t $(REGISTRY)/terway:policy-$(GIT_COMMIT_SHORT) -f Dockerfile.policy . + docker buildx build --build-arg GIT_VERSION=$(GIT_COMMIT_SHORT) --platform $(BUILD_PLATFORMS) -t $(REGISTRY)/terway:policy-$(GIT_COMMIT_SHORT) -f deploy/images/policy/Dockerfile . .PHONY: build-terway build-terway: - docker buildx build --build-arg GIT_VERSION=$(GIT_COMMIT_SHORT) --platform $(BUILD_PLATFORMS) -t $(REGISTRY)/terway:$(GIT_COMMIT_SHORT) -f Dockerfile . + docker buildx build --build-arg GIT_VERSION=$(GIT_COMMIT_SHORT) --platform $(BUILD_PLATFORMS) -t $(REGISTRY)/terway:$(GIT_COMMIT_SHORT) -f deploy/images/terway/Dockerfile . .PHONY: build-terway-controlplane build-terway-controlplane: - docker buildx build --build-arg GIT_VERSION=$(GIT_COMMIT_SHORT) --platform $(BUILD_PLATFORMS) -t $(REGISTRY)/terway-controlplane:$(GIT_COMMIT_SHORT) -f Dockerfile.controlplane . + docker buildx build --build-arg GIT_VERSION=$(GIT_COMMIT_SHORT) --platform $(BUILD_PLATFORMS) -t $(REGISTRY)/terway-controlplane:$(GIT_COMMIT_SHORT) -f deploy/images/terway-controlplane/Dockerfile . .PHONY: build-push build-push: build-push-terway build-push-terway-controlplane .PHONY: build-push-policy build-push-policy: - docker buildx build --push --build-arg GIT_VERSION=$(GIT_COMMIT_SHORT) --platform $(BUILD_PLATFORMS) -t $(REGISTRY)/terway:policy-$(GIT_COMMIT_SHORT) -f Dockerfile.policy . + docker buildx build --push --build-arg GIT_VERSION=$(GIT_COMMIT_SHORT) --platform $(BUILD_PLATFORMS) -t $(REGISTRY)/terway:policy-$(GIT_COMMIT_SHORT) -f deploy/images/policy/Dockerfile . .PHONY: build-push-terway build-push-terway: - docker buildx build --push --build-arg GIT_VERSION=$(GIT_COMMIT_SHORT) --platform $(BUILD_PLATFORMS) -t $(REGISTRY)/terway:$(GIT_COMMIT_SHORT) -f Dockerfile . + docker buildx build --push --build-arg GIT_VERSION=$(GIT_COMMIT_SHORT) --platform $(BUILD_PLATFORMS) -t $(REGISTRY)/terway:$(GIT_COMMIT_SHORT) -f deploy/images/terway/Dockerfile . .PHONY: build-terway-controlplane build-push-terway-controlplane: - docker buildx build --push --build-arg GIT_VERSION=$(GIT_COMMIT_SHORT) --platform $(BUILD_PLATFORMS) -t $(REGISTRY)/terway-controlplane:$(GIT_COMMIT_SHORT) -f Dockerfile.controlplane . + docker buildx build --push --build-arg GIT_VERSION=$(GIT_COMMIT_SHORT) --platform $(BUILD_PLATFORMS) -t $(REGISTRY)/terway-controlplane:$(GIT_COMMIT_SHORT) -f deploy/images/terway-controlplane/Dockerfile . ##@ Dependencies .PHONY: go-generate diff --git a/Dockerfile.policy b/deploy/images/policy/Dockerfile similarity index 95% rename from Dockerfile.policy rename to deploy/images/policy/Dockerfile index 4fff7bdb..a62ca4eb 100644 --- a/Dockerfile.policy +++ b/deploy/images/policy/Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.11.1 FROM --platform=$TARGETPLATFORM calico/go-build:v0.90 AS felix-builder ARG GOPROXY ARG GIT_VERSION @@ -8,7 +9,7 @@ ENV GIT_COMMIT=f1a1611acb98d9187f48bbbe2227301aa69f0499 RUN mkdir -p /go/src/github.com/projectcalico/ && cd /go/src/github.com/projectcalico/ && \ git clone -b ${GIT_BRANCH} --depth 1 https://github.com/projectcalico/calico.git && \ cd calico && [ "`git rev-parse HEAD`" = "${GIT_COMMIT}" ] -COPY policy/felix /terway_patch +COPY ../../../policy/felix /terway_patch RUN cd /go/src/github.com/projectcalico/calico && git apply /terway_patch/*.patch RUN cd /go/src/github.com/projectcalico/calico && \ CGO_ENABLED=0 go build -o bin/calico-felix -ldflags \ @@ -33,7 +34,7 @@ ENV GIT_COMMIT=67190636f1d5a7a443ea0bda585b215e7650dd25 RUN git clone -b $GIT_TAG --depth 1 https://github.com/cilium/cilium.git && \ cd cilium && git config --global user.email terway && git config --global user.name terway && \ [ "`git rev-parse HEAD`" = "${GIT_COMMIT}" ] -COPY policy/cilium /cilium_patch +COPY ../../../policy/cilium /cilium_patch RUN cd cilium && git am /cilium_patch/*.patch ARG NOSTRIP ARG LOCKDEBUG diff --git a/Dockerfile.controlplane b/deploy/images/terway-controlplane/Dockerfile similarity index 92% rename from Dockerfile.controlplane rename to deploy/images/terway-controlplane/Dockerfile index 35dcf394..1b7ae54d 100644 --- a/Dockerfile.controlplane +++ b/deploy/images/terway-controlplane/Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1-labs ARG TERWAY_POLICY_IMAGE=registry-cn-zhangjiakou.ack.aliyuncs.com/acs/terway:policy-b43ee76b@sha256:398acf199f395d3571d2bd305f4e6625ec28fd9ebf462c7a7565f6f7e36b5b4b FROM --platform=$TARGETPLATFORM ${TERWAY_POLICY_IMAGE} AS policy-dist @@ -8,9 +9,7 @@ ARG TARGETOS ARG TARGETARCH ENV GOPROXY=$GOPROXY WORKDIR /go/src/github.com/AliyunContainerService/terway/ -COPY go.sum go.mod ./ -RUN go mod download -COPY . . +COPY --parents go.mod go.sum .git cmd daemon deploy deviceplugin pkg plugin rpc tests types ./ RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -tags default_build \ -ldflags \ "-X \"github.com/AliyunContainerService/terway/pkg/version.gitCommit=`git rev-parse HEAD`\" \ diff --git a/Dockerfile b/deploy/images/terway/Dockerfile similarity index 91% rename from Dockerfile rename to deploy/images/terway/Dockerfile index 8b4a64e2..6d5edb4b 100644 --- a/Dockerfile +++ b/deploy/images/terway/Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1-labs ARG TERWAY_POLICY_IMAGE=registry-cn-zhangjiakou.ack.aliyuncs.com/acs/terway:policy-b43ee76b@sha256:398acf199f395d3571d2bd305f4e6625ec28fd9ebf462c7a7565f6f7e36b5b4b ARG UBUNTU_IMAGE=registry.cn-hangzhou.aliyuncs.com/acs/ubuntu:22.04-update ARG CILIUM_LLVM_IMAGE=quay.io/cilium/cilium-llvm:547db7ec9a750b8f888a506709adb41f135b952e@sha256:4d6fa0aede3556c5fb5a9c71bc6b9585475ac9b1064f516d4c45c8fb691c9d9e @@ -17,9 +18,7 @@ ARG TARGETOS ARG TARGETARCH ENV GOPROXY=$GOPROXY WORKDIR /go/src/github.com/AliyunContainerService/terway/ -COPY go.sum go.mod ./ -RUN go mod download -COPY . . +COPY --parents go.mod go.sum .git cmd daemon deploy deviceplugin pkg plugin rpc tests types ./ RUN cd cmd/terway && CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -tags default_build \ -ldflags \ "-s -w -X \"github.com/AliyunContainerService/terway/pkg/version.gitCommit=`git rev-parse HEAD`\" \ @@ -41,12 +40,10 @@ COPY --from=policy-dist /bin/calico-felix /bin/calico-felix COPY --from=iptables-dist /iptables /iptables RUN dpkg -i /iptables/*\.deb && rm -rf /iptables -COPY policy/policyinit.sh /bin/ -COPY policy/uninstall_policy.sh /bin/ -COPY init.sh /bin/ +COPY ../../../policy/policyinit.sh ./../../policy/uninstall_policy.sh ../../../hack/init.sh /bin/ COPY --from=policy-dist /tmp/install/ / COPY --from=builder /go/src/github.com/AliyunContainerService/terway/cmd/terway/terwayd /go/src/github.com/AliyunContainerService/terway/plugin/terway/terway /go/src/github.com/AliyunContainerService/terway/cmd/terway-cli/terway-cli /usr/bin/ -COPY hack/iptables-wrapper-installer.sh /iptables-wrapper-installer.sh +COPY ../../../hack/iptables-wrapper-installer.sh /iptables-wrapper-installer.sh RUN /iptables-wrapper-installer.sh --no-sanity-check RUN rm -f /usr/bin/cilium-operator-generic /usr/bin/cilium-health* ENTRYPOINT ["/usr/bin/terwayd"] diff --git a/Dockerfile.windows b/deploy/images/windows/Dockerfile similarity index 100% rename from Dockerfile.windows rename to deploy/images/windows/Dockerfile diff --git a/entrypoint.ps1 b/hack/entrypoint.ps1 similarity index 100% rename from entrypoint.ps1 rename to hack/entrypoint.ps1 diff --git a/init.sh b/hack/init.sh similarity index 100% rename from init.sh rename to hack/init.sh