VERSION 0.8
FROM alpine:latest

# This target can be called in the following ways:
# 1. $ earthly --secret MY_SECRET=foobar +secrets
# 2. $ export MY_SECRET=foobar
#    $ earthly --secret MY_SECRET +secrets
# 3. $ export EARTHLY_SECRETS="MY_SECRET=foobar"
#    $ earthly +secrets
# 4. $ echo "MY_SECRET=foobar" > .env
#    $ earthly +secrets
secrets:
  RUN --secret MY_SECRET_VAR=MY_SECRET test -n "$MY_SECRET_VAR"
  # the secret path can be omitted if the ID and the environment variable are matching
  RUN --secret MY_SECRET test -n "$MY_SECRET"
  RUN --mount=type=secret,id=MY_SECRET,target=/root/secret ls /root/secret

# Note: it is also possible to store secrets in the cloud, which can be shared between users of
# an organization. See the ../cloud-secrets/Earthfile for details.
