init-wrapper/Dockerfile

43 lines
1.1 KiB
Docker
Raw Permalink Normal View History

2024-03-06 05:03:44 +09:00
#syntax=docker/dockerfile:1
##
## Build
##
2024-07-22 02:27:12 +09:00
FROM rust:1-alpine3.20 AS build
2024-03-06 05:03:44 +09:00
LABEL org.opencontainers.image.authors="Sangbum Kim <sangbumkim@amuz.es>"
# set the workdir and copy the source into it
WORKDIR /app
COPY . /app
2024-07-22 02:27:12 +09:00
ENV RUSTFLAGS='-Cpanic=abort -Crelocation-model=static -Clink-args=-Wl,-x,-s,-fuse-ld=lld,--as-needed,--gc-sections,--no-gnu-unique,--nostdlib,--no-pie,--build-id=none,--no-eh-frame-hdr'
2024-03-06 05:03:44 +09:00
RUN set -x && \
apk add --no-cache \
libcap-static \
libcap-dev \
lld \
musl-dev
RUN set -x && \
2024-07-22 02:28:27 +09:00
cargo build --release && \
2024-07-22 02:27:12 +09:00
objcopy -R .eh_frame -R .got.plt target/release/init-wrapper target/release/init-wrapper && \
ls -alh target/release/init-wrapper && \
readelf -W -S ./target/release/init-wrapper
# && \
# ./target/release/init-wrapper
# ldd target/release/init-wrapper && \
2024-03-06 05:03:44 +09:00
# && \
# ldd target/release/init-wrapper
2024-07-22 02:27:12 +09:00
RUN --mount=type=bind,rw,source=.,target=/host \
cp -avf target/release/init-wrapper /host/init-wrapper && \
./target/release/init-wrapper
2024-03-06 05:03:44 +09:00
FROM scratch
COPY --from=build /app/target/release/init-wrapper /init-wrapper
# ENTRYPOINT ['/init-wrapper']