Files
markdownblog/docker.sh
rattatwinko e3d8ba1017
All checks were successful
Deploy / build-and-deploy (push) Successful in 31m44s
Update environment configuration, enhance deployment script, and localize backend messages
- Added instructions in .env.local for Docker deployment.
- Improved docker.sh to display deployment status with colored output and added ASCII art.
- Updated main.js to indicate future deprecation of the Electron app.
- Translated various log messages and CLI command outputs in the Rust backend to German for better localization.
- Removed unused asset (peta.png) from the project.
- Updated RustStatusPage component to reflect German translations in UI elements and error messages.
2025-07-06 21:17:22 +02:00

81 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
# Check if Docker daemon is running
if ! docker info >/dev/null 2>&1; then
echo "Error: Docker daemon is not running"
exit 1
fi
IMAGE_NAME="markdownblog"
CONTAINER_NAME="markdownblog"
VOLUME_NAME="markdownblog-posts"
PORT="8080"
# Stop and remove any containers using the volume
VOLUME_CONTAINERS=$(docker ps -a --filter volume=$VOLUME_NAME -q)
if [ -n "$VOLUME_CONTAINERS" ]; then
echo "Stopping and removing containers using the volume..."
docker rm -f $VOLUME_CONTAINERS
fi
# Remove the volume for a clean start (optional, comment out if you want to keep posts)
echo "Removing Docker volume (for a clean start)..."
docker volume rm $VOLUME_NAME 2>/dev/null || true
echo "Building Docker image..."
docker build -t $IMAGE_NAME .
echo "Running new container with persistent volume..."
docker run -d \
--name $CONTAINER_NAME \
-p $PORT:3000 \
-v $VOLUME_NAME:/app/docker \
$IMAGE_NAME
# Copy built-in posts to the volume if it's empty (one-time init)
echo "Copying built-in posts to Docker volume if empty..."
docker exec $CONTAINER_NAME sh -c 'if [ -d /app/posts ] && [ -d /app/docker ] && [ "$(ls -A /app/docker)" = "" ]; then cp -r /app/posts/* /app/docker/; fi'
# Check if container is running
if ! docker ps | grep -q $CONTAINER_NAME; then
echo "Error: Container failed to start. Check logs with: docker logs $CONTAINER_NAME"
exit 1
fi
# Output with colors
GREEN='\033[1;32m' # Green
CYAN='\033[1;36m'
RESET='\033[0m'
echo ""
echo "Deployment complete!"
echo ""
echo -e " App is running at: ${GREEN}http://localhost:${PORT}${RESET}"
echo ""
# Rainbow ASCII Art
RAINBOW=(
'\033[1;31m' # Red
'\033[1;33m' # Yellow
'\033[1;32m' # Green
'\033[1;36m' # Cyan
'\033[1;34m' # Blue
'\033[1;35m' # Magenta
)
ASCII=(
" __ ___ __ __ ____ __ "
" / |/ /___ ______/ /______/ /___ _ ______ / __ )/ /___ ____ _"
" / /|_/ / __ \`/ ___/ //_/ __ / __ \\ | /| / / __ \\/ __ / / __ \\/ __ \`/"
" / / / / /_/ / / / ,< / /_/ / /_/ / |/ |/ / / / / /_/ / / /_/ / /_/ / "
"/_/ /_/\\__,_/_/ /_/|_|\\__,_/\\____/|__/|__/_/ /_/_____/_/\\____/\\__, / "
" /____/ "
)
for i in "${!ASCII[@]}"; do
color="${RAINBOW[$((i % ${#RAINBOW[@]}))]}"
echo -e "${color}${ASCII[$i]}${RESET}"
done