# syntax=docker/dockerfile:1.0

## STAGE 1: Build the static binary
FROM alpine:latest AS build
RUN apk add --no-cache build-base
COPY echo.c /
RUN gcc -Os -s -static echo.c -o echo

## STAGE 2: Build the container proper
FROM scratch
COPY --from=build /echo /bin/

# ROS's container engine won't start a container without these, even
# though the container itself doesn't use any of this.
COPY --from=build /tmp /dev
COPY --from=build /tmp /proc
COPY --from=build /tmp /run
COPY --from=build /tmp /sys
COPY --from=build /tmp /tmp

# Start it
ENTRYPOINT [ "/bin/echo" ]
CMD [ "Hello,", "world!" ]
