Compare commits

..

4 Commits

5 changed files with 12 additions and 6 deletions

5
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"files.associations": {
"start-azurite": "shellscript"
}
}

View File

@@ -48,7 +48,7 @@ else
fi fi
echo "Effective command line arguments:" ${ARCH[@]} ${VERSION_ARG[@]} ${TAG_ARGS[@]} echo "Effective command line arguments:" ${ARCH[@]} ${VERSION_ARG[@]} ${TAG_ARGS[@]}
if command -v dockerd &> /dev/null; then if command -v docker &> /dev/null; then
docker build "${ARCH[@]}" "${VERSION_ARG[@]}" "${TAG_ARGS[@]}" . docker build "${ARCH[@]}" "${VERSION_ARG[@]}" "${TAG_ARGS[@]}" .
elif command -v container &> /dev/null; then elif command -v container &> /dev/null; then
container build "${ARCH[@]}" "${VERSION_ARG[@]}" "${TAG_ARGS[@]}" . container build "${ARCH[@]}" "${VERSION_ARG[@]}" "${TAG_ARGS[@]}" .

View File

@@ -1,15 +1,16 @@
function make_ca() { function make_ca() {
# Use the provided directory argument or default to AZURITE_DIR if not provided # Use the provided directory argument or default to AZURITE_DIR if not provided
local CERT_DIR="$1" local CERT_DIR="$1"
local CA_NAME="$2"
if [[ -z "$CERT_DIR" || ! -d "$CERT_DIR" ]]; then if [[ -z "$CERT_DIR" || -z "$CA_NAME" || ! -d "$CERT_DIR" ]]; then
echo "ERROR: Certificate directory $CERT_DIR does not exist." echo "ERROR: Certificate directory $CERT_DIR does not exist."
return 1 return 1
fi fi
# Generate CA certificate and key if they don't exist # Generate CA certificate and key if they don't exist
if [[ ! -f "$CERT_DIR/ca_cert.pem" || ! -f "$CERT_DIR/ca_key.pem" ]]; then if [[ ! -f "$CERT_DIR/ca_cert.pem" || ! -f "$CERT_DIR/ca_key.pem" ]]; then
echo "Generating CA certificate and key..." echo "Generating CA certificate '$CA_NAME' and key..."
if ! openssl req \ if ! openssl req \
-x509 \ -x509 \
-newkey rsa:4096 \ -newkey rsa:4096 \
@@ -17,7 +18,7 @@ function make_ca() {
-out "$CERT_DIR/ca_cert.pem" \ -out "$CERT_DIR/ca_cert.pem" \
-days 3650 \ -days 3650 \
-nodes \ -nodes \
-subj "/CN=Azurite CA" \ -subj "/CN=${CA_NAME}" \
-text \ -text \
-addext "basicConstraints=critical,CA:TRUE,pathlen:0"; then -addext "basicConstraints=critical,CA:TRUE,pathlen:0"; then
echo "ERROR: Failed to generate CA certificate and key." >&2 echo "ERROR: Failed to generate CA certificate and key." >&2

View File

@@ -73,7 +73,7 @@ while [[ $# -gt 0 ]]; do
done done
# Ensure certificates are generated before starting Azurite or Caddy. # Ensure certificates are generated before starting Azurite or Caddy.
if ! make_ca "$AZURITE_STORAGE"; then if ! make_ca "$AZURITE_STORAGE" "Azurite CA $(date +%Y.%m)"; then
echo "Error: Failed to create CA certificate and key." >&2 echo "Error: Failed to create CA certificate and key." >&2
exit 1 exit 1
fi fi

View File

@@ -30,7 +30,7 @@ done
if command -v dockerd &> /dev/null; then if command -v dockerd &> /dev/null; then
docker run --rm -d --name azurite --env-file "$AZURITE_DIR/accounts.env" -p 443:443 -v "$AZURITE_DIR/storage":/storage "$AZURITE_IMAGE" "${CONTAINER_ARGS[@]}" docker run --rm -d --name azurite --env-file "$AZURITE_DIR/accounts.env" -p 443:443 -v "$AZURITE_DIR/storage":/storage "$AZURITE_IMAGE" "${CONTAINER_ARGS[@]}"
elif command -v container &> /dev/null; then elif command -v container &> /dev/null; then
container run --rm -d --name azurite --env-file "$AZURITE_DIR/accounts.env" -p 443:443 --mount type=bind,source="$AZURITE_DIR/storage",target=/storage "$AZURITE_IMAGE" "${CONTAINER_ARGS[@]}" container run -c 2 -m 512M --rm -d --name azurite --env-file "$AZURITE_DIR/accounts.env" -p 443:443 --mount type=bind,source="$AZURITE_DIR/storage",target=/storage "$AZURITE_IMAGE" "${CONTAINER_ARGS[@]}"
else else
echo "Neither supported container runtime found." >&2 echo "Neither supported container runtime found." >&2
exit 1 exit 1