Skip to content

Commit

Permalink
Merge pull request 5GSEC#87 from VedRatan/netpol_dependency
Browse files Browse the repository at this point in the history
(enhancement): Added relative dependencies for Netpol-Adapter
  • Loading branch information
Anurag Rajawat authored Mar 22, 2024
2 parents 8050a0d + eaa3390 commit 4c38a71
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
34 changes: 24 additions & 10 deletions pkg/adapter/nimbus-netpol/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,33 @@ FROM golang:1.22 as builder
ARG TARGETOS
ARG TARGETARCH

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
WORKDIR /nimbus


# relative deps requried by the adapter

ADD api/ api/
ADD pkg/ pkg/
ADD go.mod go.mod
ADD go.sum go.sum

# nimbus-kubearmor directory
ARG ADAPTER_DIR=pkg/adapter/nimbus-netpol
WORKDIR /nimbus/$ADAPTER_DIR

# # Copy Go modules and manifests
COPY $ADAPTER_DIR/go.mod go.mod
COPY $ADAPTER_DIR/go.sum go.sum

# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY manager/ manager/
COPY processor/ processor/
COPY watcher/ watcher/
COPY $ADAPTER_DIR/manager manager
COPY $ADAPTER_DIR/processor processor
COPY $ADAPTER_DIR/watcher watcher
COPY $ADAPTER_DIR/main.go main.go


# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
Expand All @@ -29,7 +43,7 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -ldflags

FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/nimbus-netpol .
COPY --from=builder /nimbus/pkg/adapter/nimbus-netpol .
USER 65532:65532

ENTRYPOINT ["/nimbus-netpol"]
2 changes: 1 addition & 1 deletion pkg/adapter/nimbus-netpol/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ run: build

.PHONY: docker-build
docker-build:
$(CONTAINER_TOOL) build -t ${IMG}:${TAG} -t ${IMG}:latest --build-arg VERSION=${TAG} .
$(CONTAINER_TOOL) build -t ${IMG}:${TAG} -t ${IMG}:latest --build-arg VERSION=${TAG} -f ./Dockerfile ../../../

.PHONY: docker-push
docker-push:
Expand Down
1 change: 1 addition & 0 deletions pkg/adapter/nimbus-netpol/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module github.com/5GSEC/nimbus/pkg/adapter/nimbus-netpol

go 1.22
replace github.com/5GSEC/nimbus => ../../../../nimbus

require (
github.com/5GSEC/nimbus v0.0.0-20240305043055-359d519c1d9f
Expand Down

0 comments on commit 4c38a71

Please sign in to comment.