scripts added and Dockerfile adjusted to remove them from production
This commit is contained in:
@@ -30,6 +30,7 @@ RUN rm -rvf /app/Dockerfile* \
|
|||||||
/app/requirements.txt \
|
/app/requirements.txt \
|
||||||
/app/node_modules \
|
/app/node_modules \
|
||||||
/app/*.json \
|
/app/*.json \
|
||||||
|
/app/scripts
|
||||||
/app/test_*.py && \
|
/app/test_*.py && \
|
||||||
python3 /app/manage.py collectstatic --noinput
|
python3 /app/manage.py collectstatic --noinput
|
||||||
CMD ["gunicorn","--bind","0.0.0.0:8000","--workers","3","VorgabenUI.wsgi:application"]
|
CMD ["gunicorn","--bind","0.0.0.0:8000","--workers","3","VorgabenUI.wsgi:application"]
|
||||||
|
|||||||
45
scripts/deploy_secret.sh
Executable file
45
scripts/deploy_secret.sh
Executable file
@@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Generate and deploy Django secret key to Kubernetes
|
||||||
|
|
||||||
|
NAMESPACE="vorgabenui"
|
||||||
|
SECRET_NAME="django-secret"
|
||||||
|
SECRET_FILE="argocd/secret.yaml"
|
||||||
|
|
||||||
|
# Check if secret file exists
|
||||||
|
if [ ! -f "$SECRET_FILE" ]; then
|
||||||
|
echo "Error: $SECRET_FILE not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Generate random secret key
|
||||||
|
SECRET_KEY=$(python3 -c "import secrets; print(secrets.token_urlsafe(50))")
|
||||||
|
|
||||||
|
# Create temporary secret file with generated key
|
||||||
|
TEMP_SECRET_FILE=$(mktemp)
|
||||||
|
cat "$SECRET_FILE" | sed "s/CHANGE_ME_TO_RANDOM_STRING/$SECRET_KEY/g" > "$TEMP_SECRET_FILE"
|
||||||
|
|
||||||
|
# Check if secret already exists
|
||||||
|
if kubectl get secret "$SECRET_NAME" -n "$NAMESPACE" &>/dev/null; then
|
||||||
|
echo "Secret $SECRET_NAME already exists in namespace $NAMESPACE"
|
||||||
|
read -p "Do you want to replace it? (y/N): " -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
echo "Aborted"
|
||||||
|
rm "$TEMP_SECRET_FILE"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
kubectl apply -f "$TEMP_SECRET_FILE"
|
||||||
|
echo "Secret updated successfully"
|
||||||
|
else
|
||||||
|
kubectl apply -f "$TEMP_SECRET_FILE"
|
||||||
|
echo "Secret created successfully"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm "$TEMP_SECRET_FILE"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Secret deployed:"
|
||||||
|
echo " Name: $SECRET_NAME"
|
||||||
|
echo " Namespace: $NAMESPACE"
|
||||||
|
echo " Key: secret-key"
|
||||||
45
scripts/full_deploy.sh
Executable file
45
scripts/full_deploy.sh
Executable file
@@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Full deployment script - bumps both container versions by 0.001 and copies database
|
||||||
|
|
||||||
|
DEPLOYMENT_FILE="argocd/deployment.yaml"
|
||||||
|
DB_SOURCE="data/db.sqlite3"
|
||||||
|
DB_DEST="data-loader/preload.sqlite3"
|
||||||
|
|
||||||
|
# Check if deployment file exists
|
||||||
|
if [ ! -f "$DEPLOYMENT_FILE" ]; then
|
||||||
|
echo "Error: $DEPLOYMENT_FILE not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if source database exists
|
||||||
|
if [ ! -f "$DB_SOURCE" ]; then
|
||||||
|
echo "Error: $DB_SOURCE not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract current version of data-loader
|
||||||
|
LOADER_VERSION=$(grep -E "image: git.baumann.gr/adebaumann/vgui-data-loader:[0-9]" "$DEPLOYMENT_FILE" | sed -E 's/.*:([0-9.]+)/\1/')
|
||||||
|
|
||||||
|
# Extract current version of main container
|
||||||
|
MAIN_VERSION=$(grep -E "image: git.baumann.gr/adebaumann/vgui:[0-9]" "$DEPLOYMENT_FILE" | grep -v "data-loader" | sed -E 's/.*:([0-9.]+)/\1/')
|
||||||
|
|
||||||
|
if [ -z "$LOADER_VERSION" ] || [ -z "$MAIN_VERSION" ]; then
|
||||||
|
echo "Error: Could not find current versions"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Calculate new versions (add 0.001), preserve leading zero
|
||||||
|
NEW_LOADER_VERSION=$(echo "$LOADER_VERSION + 0.001" | bc | sed 's/^\./0./')
|
||||||
|
NEW_MAIN_VERSION=$(echo "$MAIN_VERSION + 0.001" | bc | sed 's/^\./0./')
|
||||||
|
|
||||||
|
# Update the deployment file
|
||||||
|
sed -i "s|image: git.baumann.gr/adebaumann/labhelper-data-loader:$LOADER_VERSION|image: git.baumann.gr/adebaumann/labhelper-data-loader:$NEW_LOADER_VERSION|" "$DEPLOYMENT_FILE"
|
||||||
|
sed -i "s|image: git.baumann.gr/adebaumann/labhelper:$MAIN_VERSION|image: git.baumann.gr/adebaumann/labhelper:$NEW_MAIN_VERSION|" "$DEPLOYMENT_FILE"
|
||||||
|
|
||||||
|
# Copy database
|
||||||
|
cp "$DB_SOURCE" "$DB_DEST"
|
||||||
|
|
||||||
|
echo "Full deployment prepared:"
|
||||||
|
echo " Data loader: $LOADER_VERSION -> $NEW_LOADER_VERSION"
|
||||||
|
echo " Main container: $MAIN_VERSION -> $NEW_MAIN_VERSION"
|
||||||
|
echo " Database copied to $DB_DEST"
|
||||||
27
scripts/partial_deploy.sh
Executable file
27
scripts/partial_deploy.sh
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Partial deployment script - bumps main container version by 0.001
|
||||||
|
|
||||||
|
DEPLOYMENT_FILE="argocd/deployment.yaml"
|
||||||
|
|
||||||
|
# Check if file exists
|
||||||
|
if [ ! -f "$DEPLOYMENT_FILE" ]; then
|
||||||
|
echo "Error: $DEPLOYMENT_FILE not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract current version of main container (labhelper, not labhelper-data-loader)
|
||||||
|
CURRENT_VERSION=$(grep -E "image: git.baumann.gr/adebaumann/vui:[0-9]" "$DEPLOYMENT_FILE" | grep -v "data-loader" | sed -E 's/.*:([0-9.]+)/\1/')
|
||||||
|
|
||||||
|
if [ -z "$CURRENT_VERSION" ]; then
|
||||||
|
echo "Error: Could not find current version"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Calculate new version (add 0.001), preserve leading zero
|
||||||
|
NEW_VERSION=$(echo "$CURRENT_VERSION + 0.001" | bc | sed 's/^\./0./')
|
||||||
|
|
||||||
|
# Update the deployment file (only the main container, not the data-loader)
|
||||||
|
sed -i "s|image: git.baumann.gr/adebaumann/vui:$CURRENT_VERSION|image: git.baumann.gr/adebaumann/vui:$NEW_VERSION|" "$DEPLOYMENT_FILE"
|
||||||
|
|
||||||
|
echo "Partial deployment prepared:"
|
||||||
|
echo " Main container: $CURRENT_VERSION -> $NEW_VERSION"
|
||||||
Reference in New Issue
Block a user