diff --git a/pkg/pillar/Dockerfile b/pkg/pillar/Dockerfile index 3fc2c53670..2a37de3d8a 100644 --- a/pkg/pillar/Dockerfile +++ b/pkg/pillar/Dockerfile @@ -1,6 +1,9 @@ # Copyright (c) 2018 Zededa, Inc. # SPDX-License-Identifier: Apache-2.0 FROM lfedge/eve-alpine:3a7658b4168bcf40dfbcb15fbae8979d81efb6f1 as build + +ARG DEV=n + ENV BUILD_PKGS git gcc linux-headers libc-dev make linux-pam-dev m4 findutils go util-linux make patch wget zfs-dev ENV PKGS alpine-baselayout musl-utils libtasn1-progs pciutils yajl xz bash iptables ip6tables iproute2 dhcpcd coreutils dmidecode libbz2 libuuid ipset curl radvd ethtool util-linux e2fsprogs libcrypto1.1 xorriso qemu-img jq e2fsprogs-extra keyutils ca-certificates ip6tables-openrc iptables-openrc ipset-openrc hdparm zfs RUN eve-alpine-deploy.sh @@ -45,9 +48,15 @@ RUN [ -z "$GOARCH" ] || export CC=$(echo /*-cross/bin/*-gcc) ;\ echo "Running go vet" && go vet ./... && \ echo "Running go fmt" && ERR=$(gofmt -e -l -s $(find . -name \*.go | grep -v /vendor/)) && \ if [ -n "$ERR" ] ; then echo "go fmt Failed - ERR: "$ERR ; exit 1 ; fi && \ - make DISTDIR=/out/opt/zededa/bin build + make DEV=$DEV DISTDIR=/out/opt/zededa/bin build WORKDIR / + +RUN if [ ${DEV} = "y" ]; then \ + CGO_ENABLED=0 go get -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@v1.8.3 && \ + cp /root/go/bin/dlv /out/opt; \ +fi + COPY patches/* /sys-patches/ # hadolint ignore=SC1097 RUN set -e && for patch in /sys-patches/*.patch; do \ diff --git a/pkg/pillar/Makefile b/pkg/pillar/Makefile index 506bffbc9f..354b3cccd3 100644 --- a/pkg/pillar/Makefile +++ b/pkg/pillar/Makefile @@ -33,13 +33,21 @@ $(DISTDIR): build: $(APPS) $(APPS1) -LDFLAGS=-s -w -X=main.Version=$(BUILD_VERSION) +LDFLAGS=-X=main.Version=$(BUILD_VERSION) +ifneq ($(DEV),y) + LDFLAGS+=-s -w +endif LDFLAGS:=-ldflags "$(LDFLAGS)" +GCFLAGS= +ifeq ($(DEV),y) + GCFLAGS:=-gcflags=all="-N -l" +endif + $(APPS): $(DISTDIR)/$(APPS) $(DISTDIR)/$(APPS): $(DISTDIR) @echo "Building $@" - GO111MODULE=on GOOS=linux go build -mod=vendor $(LDFLAGS) -o $@ ./$(@F) + GO111MODULE=on GOOS=linux go build -mod=vendor $(GCFLAGS) $(LDFLAGS) -o $@ ./$(@F) $(APPS1): $(DISTDIR) @echo $@ diff --git a/pkg/pillar/build-dev.yml b/pkg/pillar/build-dev.yml new file mode 100644 index 0000000000..d55ff34bd3 --- /dev/null +++ b/pkg/pillar/build-dev.yml @@ -0,0 +1,30 @@ +# linuxkit build template +# +# Copyright (c) 2018-2022 Zededa, Inc. +# SPDX-License-Identifier: Apache-2.0 +org: lfedge +image: eve-pillar-dev +network: yes +config: + binds: + - /lib/modules:/lib/modules + - /dev:/dev + - /etc/resolv.conf:/etc/resolv.conf + - /run:/run + - /config:/config + - /:/hostfs + - /persist:/persist:rshared,rbind + - /usr/bin/containerd:/usr/bin/containerd + - /usr/bin/containerd-shim:/usr/bin/containerd-shim + - /usr/bin/containerd-shim-runc-v2:/usr/bin/containerd-shim-runc-v2 + net: host + capabilities: + - all + pid: host + rootfsPropagation: shared + security_opt: + - seccomp:unconfined + ports: + - 2345:2345 +buildArgs: + - DEV=y