#!/bin/bash # Build and run FreeTAKServer with different installation types set -e INSTALL_TYPE=${1:-latest} CONTAINER_NAME="freetak-server" IMAGE_NAME="freetak-server" echo "Building FreeTAKServer Docker image with install type: $INSTALL_TYPE" # Stop and remove existing container if it exists if docker ps -a --format 'table {{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then echo "Stopping and removing existing container..." docker stop $CONTAINER_NAME || true docker rm $CONTAINER_NAME || true fi # Build the Docker image echo "Building Docker image..." docker build -t $IMAGE_NAME . # Run the container echo "Starting FreeTAKServer container..." docker run -d \ --name $CONTAINER_NAME \ -p 8087:8087 \ -p 8080:8080 \ -p 8443:8443 \ -p 19023:19023 \ -e INSTALL_TYPE=$INSTALL_TYPE \ -e TZ=UTC \ --restart unless-stopped \ $IMAGE_NAME echo "FreeTAKServer is starting up..." echo "Web UI will be available at: http://localhost:8080" echo "Main server API at: http://localhost:8087" echo "API endpoint at: http://localhost:19023" echo "" echo "Use 'docker logs $CONTAINER_NAME' to view the logs" echo "Use 'docker exec -it $CONTAINER_NAME /bin/bash' to access the container" echo "" echo "To stop the container: docker stop $CONTAINER_NAME"