Remove ecosystem configuration file, add Docker entrypoint script, and update deployment workflow to build and push Docker images. Enhance AdminPage with Docker export functionality and improve post management API to use dynamic posts directory path.
This commit is contained in:
36
docker.sh
Executable file
36
docker.sh
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
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'
|
||||
|
||||
echo "Deployment complete!"
|
||||
echo "App should be available at http://localhost:$PORT"
|
||||
Reference in New Issue
Block a user