mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 06:20:44 +00:00
Add prettier-plugin-sh (#762)
## Description: Add prettier-plugin-sh to format shell files. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors --------- Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
This commit is contained in:
@@ -7,3 +7,6 @@ end_of_line = lf
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
|
||||
[*.sh]
|
||||
indent_size = 4
|
||||
|
||||
+15
-1
@@ -1,3 +1,17 @@
|
||||
{
|
||||
"plugins": ["prettier-plugin-organize-imports"]
|
||||
"overrides": [
|
||||
{
|
||||
"files": ".husky/**",
|
||||
"options": {
|
||||
"plugins": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": "Dockerfile",
|
||||
"options": {
|
||||
"plugins": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"plugins": ["prettier-plugin-organize-imports", "prettier-plugin-sh"]
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# 2. Copies the update script to Hetzner server
|
||||
# 3. Executes the update script on the Hetzner server
|
||||
|
||||
set -e # Exit immediately if a command exits with a non-zero status
|
||||
set -e # Exit immediately if a command exits with a non-zero status
|
||||
|
||||
# Initialize variables
|
||||
ENABLE_BASIC_AUTH=false
|
||||
@@ -13,16 +13,16 @@ ENABLE_BASIC_AUTH=false
|
||||
# Parse command line arguments
|
||||
POSITIONAL_ARGS=()
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--enable_basic_auth)
|
||||
ENABLE_BASIC_AUTH=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
POSITIONAL_ARGS+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
case $1 in
|
||||
--enable_basic_auth)
|
||||
ENABLE_BASIC_AUTH=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
POSITIONAL_ARGS+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Restore positional parameters
|
||||
@@ -58,7 +58,7 @@ print_header() {
|
||||
|
||||
ENV=$1
|
||||
HOST=$2
|
||||
SUBDOMAIN=$3 # Optional third argument for custom subdomain
|
||||
SUBDOMAIN=$3 # Optional third argument for custom subdomain
|
||||
|
||||
# Set subdomain - use the custom subdomain if provided, otherwise use REGION
|
||||
if [ -n "$SUBDOMAIN" ]; then
|
||||
@@ -116,10 +116,10 @@ else
|
||||
fi
|
||||
|
||||
# Configuration
|
||||
UPDATE_SCRIPT="./update.sh" # Path to your update script
|
||||
UPDATE_SCRIPT="./update.sh" # Path to your update script
|
||||
REMOTE_USER="openfront"
|
||||
REMOTE_UPDATE_PATH="/home/$REMOTE_USER"
|
||||
REMOTE_UPDATE_SCRIPT="$REMOTE_UPDATE_PATH/update-openfront.sh" # Where to place the script on server
|
||||
REMOTE_UPDATE_SCRIPT="$REMOTE_UPDATE_PATH/update-openfront.sh" # Where to place the script on server
|
||||
|
||||
VERSION_TAG=$(date +"%Y%m%d-%H%M%S")
|
||||
DOCKER_IMAGE="${DOCKER_USERNAME}/${DOCKER_REPO}:${VERSION_TAG}"
|
||||
@@ -139,15 +139,15 @@ echo "Using version tag: $VERSION_TAG"
|
||||
echo "Docker repository: $DOCKER_REPO"
|
||||
|
||||
# Get Git commit for build info
|
||||
GIT_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
|
||||
GIT_COMMIT=$(git rev-parse HEAD 2> /dev/null || echo "unknown")
|
||||
echo "Git commit: $GIT_COMMIT"
|
||||
|
||||
docker buildx build \
|
||||
--platform linux/amd64 \
|
||||
--build-arg GIT_COMMIT=$GIT_COMMIT \
|
||||
-t $DOCKER_IMAGE \
|
||||
--push \
|
||||
.
|
||||
--platform linux/amd64 \
|
||||
--build-arg GIT_COMMIT=$GIT_COMMIT \
|
||||
-t $DOCKER_IMAGE \
|
||||
--push \
|
||||
.
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "❌ Docker build failed. Stopping deployment."
|
||||
|
||||
Generated
+50
-3
@@ -114,6 +114,7 @@
|
||||
"postcss-loader": "^8.1.1",
|
||||
"prettier": "^3.5.3",
|
||||
"prettier-plugin-organize-imports": "^4.1.0",
|
||||
"prettier-plugin-sh": "^0.17.4",
|
||||
"raw-loader": "^4.0.2",
|
||||
"sinon": "^18.0.0",
|
||||
"sinon-chai": "^4.0.0",
|
||||
@@ -6826,6 +6827,16 @@
|
||||
"integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==",
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/@reteps/dockerfmt": {
|
||||
"version": "0.3.6",
|
||||
"resolved": "https://registry.npmjs.org/@reteps/dockerfmt/-/dockerfmt-0.3.6.tgz",
|
||||
"integrity": "sha512-Tb5wIMvBf/nLejTQ61krK644/CEMB/cpiaIFXqGApfGqO3GwcR3qnI0DbmkFVCl2OyEp8LnLX3EkucoL0+tbFg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^v12.20.0 || ^14.13.0 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@sapphire/async-queue": {
|
||||
"version": "1.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.5.tgz",
|
||||
@@ -17734,6 +17745,26 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/prettier-plugin-sh": {
|
||||
"version": "0.17.4",
|
||||
"resolved": "https://registry.npmjs.org/prettier-plugin-sh/-/prettier-plugin-sh-0.17.4.tgz",
|
||||
"integrity": "sha512-aAVKXZ7GTEMZdZsIPSwMwddwPvt2ibMbRGd4OJAP0G7QoeYZV+mPNg2Oln3R53sZ4PVjeAA7Xzi/PuI0QlHHfQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@reteps/dockerfmt": "^0.3.5",
|
||||
"sh-syntax": "^0.5.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/unts"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"prettier": "^3.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/pretty-error": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-4.0.0.tgz",
|
||||
@@ -18746,6 +18777,22 @@
|
||||
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/sh-syntax": {
|
||||
"version": "0.5.7",
|
||||
"resolved": "https://registry.npmjs.org/sh-syntax/-/sh-syntax-0.5.7.tgz",
|
||||
"integrity": "sha512-74m9dt91konrF5+m0kASugzi37VxKsnTJQ6yvdDZu3IijG5/vIZpImP6FadsJLWNt2X2YD0VaTwW5W7Ox7mFVg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tslib": "^2.8.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/sh-syntax"
|
||||
}
|
||||
},
|
||||
"node_modules/shallow-clone": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz",
|
||||
@@ -20244,9 +20291,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.0.tgz",
|
||||
"integrity": "sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==",
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/tsx": {
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
"postcss-loader": "^8.1.1",
|
||||
"prettier": "^3.5.3",
|
||||
"prettier-plugin-organize-imports": "^4.1.0",
|
||||
"prettier-plugin-sh": "^0.17.4",
|
||||
"raw-loader": "^4.0.2",
|
||||
"sinon": "^18.0.0",
|
||||
"sinon-chai": "^4.0.0",
|
||||
|
||||
@@ -31,7 +31,7 @@ fi
|
||||
|
||||
echo "👤 Setting up openfront user..."
|
||||
# Create openfront user if it doesn't exist
|
||||
if id "openfront" &>/dev/null; then
|
||||
if id "openfront" &> /dev/null; then
|
||||
echo "User openfront already exists"
|
||||
else
|
||||
useradd -m -s /bin/bash openfront
|
||||
@@ -139,41 +139,41 @@ chown -R openfront:openfront "$OTEL_CONFIG_DIR"
|
||||
# Run Node Exporter
|
||||
echo "🚀 Starting Node Exporter..."
|
||||
docker pull prom/node-exporter:latest
|
||||
docker rm -f node-exporter 2>/dev/null || true
|
||||
docker rm -f node-exporter 2> /dev/null || true
|
||||
docker run -d \
|
||||
--name=node-exporter \
|
||||
--restart=unless-stopped \
|
||||
--net="host" \
|
||||
--pid="host" \
|
||||
-v "/:/host:ro,rslave" \
|
||||
prom/node-exporter:latest \
|
||||
--path.rootfs=/host
|
||||
--name=node-exporter \
|
||||
--restart=unless-stopped \
|
||||
--net="host" \
|
||||
--pid="host" \
|
||||
-v "/:/host:ro,rslave" \
|
||||
prom/node-exporter:latest \
|
||||
--path.rootfs=/host
|
||||
|
||||
# Run OpenTelemetry Collector
|
||||
echo "🚀 Starting OpenTelemetry Collector..."
|
||||
docker pull otel/opentelemetry-collector-contrib:latest
|
||||
docker rm -f otel-collector 2>/dev/null || true
|
||||
docker rm -f otel-collector 2> /dev/null || true
|
||||
# Run OpenTelemetry Collector with appropriate permissions
|
||||
# Run OpenTelemetry Collector
|
||||
echo "🚀 Starting OpenTelemetry Collector..."
|
||||
docker pull otel/opentelemetry-collector-contrib:latest
|
||||
docker rm -f otel-collector 2>/dev/null || true
|
||||
docker rm -f otel-collector 2> /dev/null || true
|
||||
|
||||
docker run -d \
|
||||
--name=otel-collector \
|
||||
--restart=unless-stopped \
|
||||
--network=host \
|
||||
--user=0 \
|
||||
-v "$OTEL_CONFIG_DIR/otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml:ro" \
|
||||
-e OTEL_ENDPOINT="${OTEL_ENDPOINT}" \
|
||||
otel/opentelemetry-collector-contrib:latest
|
||||
--name=otel-collector \
|
||||
--restart=unless-stopped \
|
||||
--network=host \
|
||||
--user=0 \
|
||||
-v "$OTEL_CONFIG_DIR/otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml:ro" \
|
||||
-e OTEL_ENDPOINT="${OTEL_ENDPOINT}" \
|
||||
otel/opentelemetry-collector-contrib:latest
|
||||
|
||||
# Check if containers are running
|
||||
if docker ps | grep -q node-exporter && docker ps | grep -q otel-collector; then
|
||||
echo "✅ Node Exporter and OpenTelemetry Collector started successfully!"
|
||||
echo "✅ Node Exporter and OpenTelemetry Collector started successfully!"
|
||||
else
|
||||
echo "❌ Failed to start containers. Check logs with: docker logs node-exporter or docker logs otel-collector"
|
||||
exit 1
|
||||
echo "❌ Failed to start containers. Check logs with: docker logs node-exporter or docker logs otel-collector"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "====================================================="
|
||||
|
||||
+44
-42
@@ -3,9 +3,9 @@ set -e
|
||||
|
||||
# Check if required environment variables are set
|
||||
if [ -z "$CF_API_TOKEN" ] || [ -z "$CF_ACCOUNT_ID" ] || [ -z "$SUBDOMAIN" ] || [ -z "$DOMAIN" ]; then
|
||||
echo "Error: Required environment variables not set"
|
||||
echo "Please set CF_API_TOKEN, CF_ACCOUNT_ID, SUBDOMAIN, and DOMAIN"
|
||||
exit 1
|
||||
echo "Error: Required environment variables not set"
|
||||
echo "Please set CF_API_TOKEN, CF_ACCOUNT_ID, SUBDOMAIN, and DOMAIN"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Generate a unique tunnel name using timestamp
|
||||
@@ -16,18 +16,18 @@ echo "Using unique tunnel name: ${TUNNEL_NAME}"
|
||||
# Create a new tunnel
|
||||
echo "Creating Cloudflare tunnel for subdomain ${SUBDOMAIN}..."
|
||||
TUNNEL_RESPONSE=$(curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/${CF_ACCOUNT_ID}/cfd_tunnel" \
|
||||
-H "Authorization: Bearer ${CF_API_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data "{\"name\":\"${TUNNEL_NAME}\"}")
|
||||
-H "Authorization: Bearer ${CF_API_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data "{\"name\":\"${TUNNEL_NAME}\"}")
|
||||
|
||||
# Extract tunnel ID and token
|
||||
TUNNEL_ID=$(echo $TUNNEL_RESPONSE | jq -r '.result.id')
|
||||
TUNNEL_TOKEN=$(echo $TUNNEL_RESPONSE | jq -r '.result.token')
|
||||
|
||||
if [ -z "$TUNNEL_ID" ] || [ "$TUNNEL_ID" == "null" ]; then
|
||||
echo "Failed to create tunnel"
|
||||
echo $TUNNEL_RESPONSE
|
||||
exit 1
|
||||
echo "Failed to create tunnel"
|
||||
echo $TUNNEL_RESPONSE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Tunnel created with ID: ${TUNNEL_ID}"
|
||||
@@ -35,47 +35,47 @@ echo "Tunnel created with ID: ${TUNNEL_ID}"
|
||||
# Configure the tunnel with hostname
|
||||
echo "Configuring tunnel to point to ${SUBDOMAIN}.${DOMAIN}..."
|
||||
curl -s -X PUT "https://api.cloudflare.com/client/v4/accounts/${CF_ACCOUNT_ID}/cfd_tunnel/${TUNNEL_ID}/configurations" \
|
||||
-H "Authorization: Bearer ${CF_API_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data "{\"config\":{\"ingress\":[{\"hostname\":\"${SUBDOMAIN}.${DOMAIN}\",\"service\":\"http://localhost:80\"},{\"service\":\"http_status:404\"}]}}"
|
||||
-H "Authorization: Bearer ${CF_API_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data "{\"config\":{\"ingress\":[{\"hostname\":\"${SUBDOMAIN}.${DOMAIN}\",\"service\":\"http://localhost:80\"},{\"service\":\"http_status:404\"}]}}"
|
||||
|
||||
# Update DNS record to point to the new tunnel
|
||||
echo "Updating DNS record to point to the new tunnel..."
|
||||
|
||||
# First check if DNS record exists
|
||||
DNS_RECORDS=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones?name=${DOMAIN}" \
|
||||
-H "Authorization: Bearer ${CF_API_TOKEN}" \
|
||||
-H "Content-Type: application/json")
|
||||
-H "Authorization: Bearer ${CF_API_TOKEN}" \
|
||||
-H "Content-Type: application/json")
|
||||
|
||||
ZONE_ID=$(echo $DNS_RECORDS | jq -r '.result[0].id')
|
||||
|
||||
if [ -z "$ZONE_ID" ] || [ "$ZONE_ID" == "null" ]; then
|
||||
echo "Could not find zone ID for domain ${DOMAIN}"
|
||||
exit 1
|
||||
echo "Could not find zone ID for domain ${DOMAIN}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for existing record
|
||||
EXISTING_RECORDS=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records?name=${SUBDOMAIN}.${DOMAIN}" \
|
||||
-H "Authorization: Bearer ${CF_API_TOKEN}" \
|
||||
-H "Content-Type: application/json")
|
||||
-H "Authorization: Bearer ${CF_API_TOKEN}" \
|
||||
-H "Content-Type: application/json")
|
||||
|
||||
RECORD_ID=$(echo $EXISTING_RECORDS | jq -r '.result[0].id')
|
||||
|
||||
# Create or update the DNS record
|
||||
if [ -z "$RECORD_ID" ] || [ "$RECORD_ID" == "null" ]; then
|
||||
# Create new record
|
||||
echo "Creating new DNS record..."
|
||||
DNS_RESPONSE=$(curl -s -X POST "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records" \
|
||||
-H "Authorization: Bearer ${CF_API_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data "{\"type\":\"CNAME\",\"name\":\"${SUBDOMAIN}\",\"content\":\"${TUNNEL_ID}.cfargotunnel.com\",\"ttl\":1,\"proxied\":true}")
|
||||
# Create new record
|
||||
echo "Creating new DNS record..."
|
||||
DNS_RESPONSE=$(curl -s -X POST "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records" \
|
||||
-H "Authorization: Bearer ${CF_API_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data "{\"type\":\"CNAME\",\"name\":\"${SUBDOMAIN}\",\"content\":\"${TUNNEL_ID}.cfargotunnel.com\",\"ttl\":1,\"proxied\":true}")
|
||||
else
|
||||
# Update existing record
|
||||
echo "Updating existing DNS record..."
|
||||
DNS_RESPONSE=$(curl -s -X PUT "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${RECORD_ID}" \
|
||||
-H "Authorization: Bearer ${CF_API_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data "{\"type\":\"CNAME\",\"name\":\"${SUBDOMAIN}\",\"content\":\"${TUNNEL_ID}.cfargotunnel.com\",\"ttl\":1,\"proxied\":true}")
|
||||
# Update existing record
|
||||
echo "Updating existing DNS record..."
|
||||
DNS_RESPONSE=$(curl -s -X PUT "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${RECORD_ID}" \
|
||||
-H "Authorization: Bearer ${CF_API_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data "{\"type\":\"CNAME\",\"name\":\"${SUBDOMAIN}\",\"content\":\"${TUNNEL_ID}.cfargotunnel.com\",\"ttl\":1,\"proxied\":true}")
|
||||
fi
|
||||
|
||||
# Log the tunnel information
|
||||
@@ -84,23 +84,25 @@ echo "Tunnel is set up! Site will be available at: https://${SUBDOMAIN}.${DOMAIN
|
||||
# Export the tunnel token for supervisord
|
||||
export CLOUDFLARE_TUNNEL_TOKEN=${TUNNEL_TOKEN}
|
||||
|
||||
|
||||
# Check if Basic Auth credentials are set
|
||||
if [ -z "$BASIC_AUTH_USER" ] || [ -z "$BASIC_AUTH_PASS" ]; then
|
||||
echo "HTTP Basic Authentication will be disabled"
|
||||
echo "HTTP Basic Authentication will be disabled"
|
||||
else
|
||||
# Create the htpasswd file
|
||||
echo "Creating basic auth credentials for user: ${BASIC_AUTH_USER}"
|
||||
# Ensure apache2-utils is installed for htpasswd
|
||||
command -v htpasswd >/dev/null 2>&1 || { echo "htpasswd not found, installing apache2-utils..."; apt-get update && apt-get install -y apache2-utils; }
|
||||
# Create the password file
|
||||
htpasswd -bc /etc/nginx/.htpasswd ${BASIC_AUTH_USER} ${BASIC_AUTH_PASS}
|
||||
# Create the htpasswd file
|
||||
echo "Creating basic auth credentials for user: ${BASIC_AUTH_USER}"
|
||||
# Ensure apache2-utils is installed for htpasswd
|
||||
command -v htpasswd > /dev/null 2>&1 || {
|
||||
echo "htpasswd not found, installing apache2-utils..."
|
||||
apt-get update && apt-get install -y apache2-utils
|
||||
}
|
||||
# Create the password file
|
||||
htpasswd -bc /etc/nginx/.htpasswd ${BASIC_AUTH_USER} ${BASIC_AUTH_PASS}
|
||||
|
||||
# Update Nginx configuration to enable Basic Auth
|
||||
sed -i '1i auth_basic "Restricted Access";' /etc/nginx/conf.d/default.conf
|
||||
sed -i '2i auth_basic_user_file /etc/nginx/.htpasswd;' /etc/nginx/conf.d/default.conf
|
||||
# Update Nginx configuration to enable Basic Auth
|
||||
sed -i '1i auth_basic "Restricted Access";' /etc/nginx/conf.d/default.conf
|
||||
sed -i '2i auth_basic_user_file /etc/nginx/.htpasswd;' /etc/nginx/conf.d/default.conf
|
||||
|
||||
echo "HTTP Basic Authentication enabled for user: ${BASIC_AUTH_USER}"
|
||||
echo "HTTP Basic Authentication enabled for user: ${BASIC_AUTH_USER}"
|
||||
fi
|
||||
|
||||
# Start supervisord
|
||||
|
||||
@@ -4,15 +4,14 @@
|
||||
|
||||
# Load environment variables if .env exists
|
||||
if [ -f /home/openfront/.env ]; then
|
||||
echo "Loading environment variables from .env file..."
|
||||
export $(grep -v '^#' /home/openfront/.env | xargs)
|
||||
echo "Loading environment variables from .env file..."
|
||||
export $(grep -v '^#' /home/openfront/.env | xargs)
|
||||
fi
|
||||
|
||||
echo "======================================================"
|
||||
echo "🔄 UPDATING SERVER: ${HOST} ENVIRONMENT"
|
||||
echo "======================================================"
|
||||
|
||||
|
||||
# Container and image configuration
|
||||
CONTAINER_NAME="openfront-${ENV}-${SUBDOMAIN}"
|
||||
|
||||
@@ -23,41 +22,41 @@ echo "Checking for existing container..."
|
||||
# Check for running container
|
||||
RUNNING_CONTAINER=$(docker ps | grep ${CONTAINER_NAME} | awk '{print $1}')
|
||||
if [ -n "$RUNNING_CONTAINER" ]; then
|
||||
echo "Stopping running container $RUNNING_CONTAINER..."
|
||||
docker stop $RUNNING_CONTAINER
|
||||
echo "Waiting for container to fully stop and release resources..."
|
||||
sleep 5 # Add a 5-second delay
|
||||
docker rm $RUNNING_CONTAINER
|
||||
echo "Container $RUNNING_CONTAINER stopped and removed."
|
||||
echo "Stopping running container $RUNNING_CONTAINER..."
|
||||
docker stop $RUNNING_CONTAINER
|
||||
echo "Waiting for container to fully stop and release resources..."
|
||||
sleep 5 # Add a 5-second delay
|
||||
docker rm $RUNNING_CONTAINER
|
||||
echo "Container $RUNNING_CONTAINER stopped and removed."
|
||||
fi
|
||||
|
||||
# Also check for stopped containers with the same name
|
||||
STOPPED_CONTAINER=$(docker ps -a | grep ${CONTAINER_NAME} | awk '{print $1}')
|
||||
if [ -n "$STOPPED_CONTAINER" ]; then
|
||||
echo "Removing stopped container $STOPPED_CONTAINER..."
|
||||
docker rm $STOPPED_CONTAINER
|
||||
echo "Container $STOPPED_CONTAINER removed."
|
||||
echo "Removing stopped container $STOPPED_CONTAINER..."
|
||||
docker rm $STOPPED_CONTAINER
|
||||
echo "Container $STOPPED_CONTAINER removed."
|
||||
fi
|
||||
|
||||
echo "Starting new container for ${HOST} environment..."
|
||||
docker run -d \
|
||||
--restart=always \
|
||||
--env-file /home/openfront/.env \
|
||||
--name ${CONTAINER_NAME} \
|
||||
$DOCKER_IMAGE
|
||||
--restart=always \
|
||||
--env-file /home/openfront/.env \
|
||||
--name ${CONTAINER_NAME} \
|
||||
$DOCKER_IMAGE
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Update complete! New ${CONTAINER_NAME} container is running."
|
||||
echo "Update complete! New ${CONTAINER_NAME} container is running."
|
||||
|
||||
# Final cleanup after successful deployment
|
||||
echo "Performing final cleanup of unused Docker resources..."
|
||||
echo "Removing unused images (not referenced)..."
|
||||
docker image prune -a -f
|
||||
docker container prune -f
|
||||
echo "Cleanup complete."
|
||||
# Final cleanup after successful deployment
|
||||
echo "Performing final cleanup of unused Docker resources..."
|
||||
echo "Removing unused images (not referenced)..."
|
||||
docker image prune -a -f
|
||||
docker container prune -f
|
||||
echo "Cleanup complete."
|
||||
else
|
||||
echo "Failed to start container"
|
||||
exit 1
|
||||
echo "Failed to start container"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "======================================================"
|
||||
|
||||
Reference in New Issue
Block a user