From fde0f03df0ad67c85053892e5dca8198a0770343 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Sun, 18 Aug 2024 12:02:08 -0700 Subject: [PATCH] created dev deployment --- TODO.txt | 2 ++ update-deploy.sh | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/TODO.txt b/TODO.txt index 5faa36061..24cd5650e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -27,11 +27,13 @@ * only send delta turns on connect/reconnect DONE 8/17/2024 * Create separate game config dev vs prod DONE 8/17/2024 * improve front page, only one game at a time every 30s DONE 8/17/2024 +* create dev server DONE 8/18/2024 * BUG: boats not going to destination, coast not being recognized * BUG: boats freeze game on path calculation * better algorithm for name render placement * make boats larger * have boats not get close to shore +* Allow boats to attack TerraNullius * make coasts look better * add shader to dim border * remove player.info() diff --git a/update-deploy.sh b/update-deploy.sh index 07bba29e5..8ba3f77c5 100755 --- a/update-deploy.sh +++ b/update-deploy.sh @@ -1,5 +1,29 @@ #!/bin/bash +# Check if the --env flag is provided +if [[ "$1" != "--env" ]]; then + echo "Usage: $0 --env [dev|prod]" + exit 1 +fi + +# Get the environment from the command line argument +ENV="$2" + +# Validate the environment +if [[ "$ENV" != "dev" && "$ENV" != "prod" ]]; then + echo "Invalid environment. Use 'dev' or 'prod'." + exit 1 +fi + +# Set the instance name based on the environment +if [[ "$ENV" == "dev" ]]; then + INSTANCE_NAME="openfrontio-dev" + echo "[DEV] Deploying to openfront.dev" +else + INSTANCE_NAME="openfrontio-instance" + echo "[PROD] Deploying to openfront.io" +fi + # Ensure you're authenticated with Google Cloud gcloud auth configure-docker us-central1-docker.pkg.dev @@ -7,14 +31,17 @@ gcloud auth configure-docker us-central1-docker.pkg.dev docker build -t openfrontio . # Tag the new image (use a version number or 'latest') -docker tag openfrontio us-central1-docker.pkg.dev/openfrontio/openfrontio/game-server:latest +docker tag openfrontio us-central1-docker.pkg.dev/openfrontio/openfrontio/game-server:$ENV # Push the new image to Google Container Registry -docker push us-central1-docker.pkg.dev/openfrontio/openfrontio/game-server:latest +docker push us-central1-docker.pkg.dev/openfrontio/openfrontio/game-server:$ENV + +# Prune Docker system on the instance +gcloud compute ssh $INSTANCE_NAME --zone us-central1-a --command 'docker system prune -f -a' # Update the GCE instance with the new container image -gcloud compute instances update-container openfrontio-instance \ +gcloud compute instances update-container $INSTANCE_NAME \ --container-image us-central1-docker.pkg.dev/openfrontio/openfrontio/game-server:latest \ --zone=us-central1-a -echo "Deployment complete. New version should be live soon." \ No newline at end of file +echo "Deployment to $ENV environment complete. New version should be live soon on $INSTANCE_NAME." \ No newline at end of file