mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-25 01:34:02 +00:00
a72bdac7df
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
37 lines
922 B
Bash
Executable file
37 lines
922 B
Bash
Executable file
#!/bin/bash
|
|
|
|
# Prerequisites:
|
|
#
|
|
# - Log in to the DigitalOcean docker registry
|
|
# doctl registry login
|
|
#
|
|
# - Target the `zed-1` kubernetes cluster
|
|
# doctl kubernetes cluster kubeconfig save zed-1
|
|
|
|
set -eu
|
|
|
|
if [[ $# < 1 ]]; then
|
|
echo "Usage: $0 [production|staging|...]"
|
|
exit 1
|
|
fi
|
|
|
|
export ZED_KUBE_NAMESPACE=$1
|
|
ENV_FILE="crates/server/k8s/environments/${ZED_KUBE_NAMESPACE}.sh"
|
|
if [[ ! -f $ENV_FILE ]]; then
|
|
echo "Invalid environment name '${ZED_KUBE_NAMESPACE}'"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ $ZED_KUBE_NAMESPACE == "production" && -n $(git status --short) ]]; then
|
|
echo "Cannot deploy uncommited changes to production"
|
|
exit 1
|
|
fi
|
|
|
|
git_sha=$(git rev-parse HEAD)
|
|
export ZED_IMAGE_ID="registry.digitalocean.com/zed/zed-server:${ZED_KUBE_NAMESPACE}-${git_sha}"
|
|
export $(cat $ENV_FILE)
|
|
|
|
docker build . --tag "$ZED_IMAGE_ID"
|
|
docker push "$ZED_IMAGE_ID"
|
|
|
|
envsubst < crates/server/k8s/manifest.template.yml | kubectl apply -f -
|