Skip to content

Commit

Permalink
pillar: introduce debug build
Browse files Browse the repository at this point in the history
Now if pillar is build with `DEV=y`, the debug symbols are not
stripped, and use reccomended GCFLAGS for devle.

Also include delve to the pillar container, and make required port
forwarded, so delve can attach.

Note that in this patch the development version of pillar container is
not picked up by linuxkit yet.

Signed-off-by: Yuri Volchkov <yuri@volch.org>
  • Loading branch information
Yuri Volchkov authored and eriknordmark committed Jun 23, 2022
1 parent 8bb32ec commit f284dd6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
11 changes: 10 additions & 1 deletion 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
Expand Down Expand Up @@ -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 \
Expand Down
12 changes: 10 additions & 2 deletions pkg/pillar/Makefile
Expand Up @@ -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 $@
Expand Down
30 changes: 30 additions & 0 deletions 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

0 comments on commit f284dd6

Please sign in to comment.