File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,22 +5,13 @@ WORKDIR /src
55COPY ./main.go /src/main.go
66
77RUN set -xe; \
8- CGO_ENABLED=0 \
8+ CGO_ENABLED=1 \
99 GOARCH=amd64 \
1010 go build \
11- -buildmode=pie \
12- -ldflags="-linkmode=internal" \
11+ -ldflags='-linkmode external -extldflags "-static-pie" -s -w' \
1312 -o /server main.go \
1413 ;
1514
16- # Strip PT_INTERP from the static PIE binary: Go's internal linker adds
17- # /lib64/ld-linux-x86-64.so.2 as interpreter for PIE on Linux, but the
18- # binary is fully self-contained and does not need a dynamic linker.
19- # Unikraft's elfloader fails when the interpreter is listed but absent.
20- # Patch the program header: change PT_INTERP (type=3) -> PT_NULL (type=0).
21- COPY patch_interp.py /patch_interp.py
22- RUN python3 /patch_interp.py /server
23-
2415FROM scratch AS rootfs
2516
2617COPY --from=build /server /bin/server
Load diff This file was deleted.
Original file line number Diff line number Diff line change @@ -5,22 +5,13 @@ WORKDIR /src
55COPY ./hello.go /src/hello.go
66
77RUN set -xe; \
8- CGO_ENABLED=0 \
8+ CGO_ENABLED=1 \
99 GOARCH=amd64 \
1010 go build \
11- -buildmode=pie \
12- -ldflags="-linkmode=internal" \
11+ -ldflags='-linkmode external -extldflags "-static-pie" -s -w' \
1312 -o /hello hello.go \
1413 ;
1514
16- # Strip PT_INTERP from the static PIE binary: Go's internal linker adds
17- # /lib64/ld-linux-x86-64.so.2 as interpreter for PIE on Linux, but the
18- # binary is fully self-contained and does not need a dynamic linker.
19- # Unikraft's elfloader fails when the interpreter is listed but absent.
20- # Patch the program header: change PT_INTERP (type=3) -> PT_NULL (type=0).
21- COPY patch_interp.py /patch_interp.py
22- RUN python3 /patch_interp.py /hello
23-
2415FROM scratch AS rootfs
2516
2617COPY --from=build /hello /bin/hello
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments