VERSION --allow-privileged-from-dockerfile 0.8
FROM alpine:3.18

privileged-context:
    RUN --privileged echo "hello dockerfile from privileged context" > a.txt
    SAVE ARTIFACT a.txt

test-all:
    BUILD +test
    BUILD +test-allow-privileged-with-privileged-context
    BUILD +test-allow-privileged-with-privileged-run-command

test:
    FROM DOCKERFILE .
    RUN --entrypoint
    SAVE IMAGE test-dockerfile:latest

test-allow-privileged-with-privileged-context:
    FROM DOCKERFILE --allow-privileged -f ./Dockerfile +privileged-context/*
    RUN --entrypoint
    SAVE IMAGE test-allow-privileged-with-privileged-context:latest

test-allow-privileged-with-privileged-run-command:
    FROM DOCKERFILE --allow-privileged -f ./Dockerfile +privileged-context/*
    RUN --privileged ip link add dummy0 type dummy && ip link delete dummy0
    SAVE IMAGE test-allow-privileged-with-privileged-run-command:latest
