53 lines
1.6 KiB
Bash
Executable File
53 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# By default Caddy exposes the SSL termination endpoint and
|
|
# uses DNS name to determine which service to route to.
|
|
EXPOSED_PORTS=("-p" "443:443")
|
|
|
|
CONTAINER_ARGS=()
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
-o|--oauth)
|
|
# OAuth support
|
|
case "$2" in
|
|
blob)
|
|
EXPOSED_PORTS=("-p" "443:10000")
|
|
;;
|
|
queue)
|
|
EXPOSED_PORTS=("-p" "443:10001")
|
|
;;
|
|
table)
|
|
EXPOSED_PORTS=("-p" "443:10002")
|
|
;;
|
|
*)
|
|
echo "Error: --oauth must be followed by 'blob', 'queue', or 'table'." >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
CONTAINER_ARGS+=("--oauth")
|
|
shift 2
|
|
;;
|
|
--ssl|-s|--no-caddy|-n)
|
|
CONTAINER_ARGS+=("$1")
|
|
EXPOSED_PORTS=("-p" "10000:10000" "-p" "10001:10001" "-p" "10002:10002")
|
|
shift
|
|
;;
|
|
*)
|
|
echo "Unknown argument: $1" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
echo "Using exposed ports: ${EXPOSED_PORTS[*]}"
|
|
|
|
if command -v dockerd &> /dev/null; then
|
|
docker run --rm -it --name azurite --env-file accounts.env "${EXPOSED_PORTS[@]}" -v ./storage:/storage azurite:latest "${CONTAINER_ARGS[@]}"
|
|
elif command -v container &> /dev/null; then
|
|
container run --rm -it --name azurite --env-file accounts.env "${EXPOSED_PORTS[@]}" --mount type=bind,source=./storage,target=/storage azurite:latest "${CONTAINER_ARGS[@]}"
|
|
else
|
|
echo "Neither supported container runtime found." >&2
|
|
exit 1
|
|
fi
|