Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: added script for staging env (#277)

Luke Zhoude079354423e
diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml
new file mode 100644
index 0000000000..a0483d475d
--- /dev/null
+++ b/.github/workflows/staging.yml
@@ -0,0 +1,14 @@
+name: "Staging Env"
+
+on:
+ release:
+ types: [ prereleased ]
+ workflow_dispatch:
+
+jobs:
+ initiate-render-service:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: "trigger render's webhook"
+ run: curl https://api.render.com/deploy/srv-c75ut6pg7hp4jqrf6ngg?key=OhYoeLwl7qM
diff --git a/Dockerfile b/Dockerfile
index 3aca2bee6f..0747e563f7 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -20,6 +20,7 @@ RUN yarn release-docker
FROM golang:1.16.5-alpine3.13 as backend
+ARG MODE="release"
ARG VERSION="development"
ARG GO_VERSION="unknown"
ARG GIT_COMMIT="unknown"
@@ -39,7 +40,7 @@ COPY --from=frontend /frontend-build/dist ./server/dist
# -ldflags="-w -s" means omit DWARF symbol table and the symbol table and debug information
# go-sqlite3 requires CGO_ENABLED
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \
- --tags "release" \
+ --tags ${MODE} \
-ldflags="-w -s -X 'github.com/bytebase/bytebase/bin/server/cmd.version=${VERSION}' -X 'github.com/bytebase/bytebase/bin/server/cmd.goversion=${GO_VERSION}' -X 'github.com/bytebase/bytebase/bin/server/cmd.gitcommit=${GIT_COMMIT}' -X 'github.com/bytebase/bytebase/bin/server/cmd.buildtime=${BUILD_TIME}' -X 'github.com/bytebase/bytebase/bin/server/cmd.builduser=${BUILD_USER}'" \
-o bytebase \
./bin/server/main.go
diff --git a/scripts/staging.sh b/scripts/staging.sh
new file mode 100644
index 0000000000..82f030a3be
--- /dev/null
+++ b/scripts/staging.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# For now, we use this script to start our staging preview on render
+# by changing the ENTRYPOINT and CMD at the dockerfile to this.
+
+# example usages:
+# ./staging.sh
+# ./staging.sh https://example.com
+# ./staging.sh https://example.com:8080
+
+# If no parameter is passed, use https://staging.bytebase.com as host and 80 as port by default
+ONLINE_DEMO_HOST='https://staging.bytebase.com'
+ONLINE_DEMO_PORT='80'
+if [ $1 ]; then
+ PROTOCAL=`echo $1 | awk -F ':' '{ print $1 }'`
+ URI=`echo $1 | awk -F '[/:]' '{ print $4; }'`
+ PORT=`echo $1 | awk -F '[/:]' '{ print $5; }'`
+
+ ONLINE_DEMO_HOST=$PROTOCAL://$URI
+
+ if [ $PORT ]; then
+ ONLINE_DEMO_PORT=$PORT
+ fi
+fi
+
+echo "Starting Bytebase in demo mode at ${ONLINE_DEMO_HOST}:${ONLINE_DEMO_PORT}..."
+
+bytebase --host ${ONLINE_DEMO_HOST} --port ${ONLINE_DEMO_PORT} --demo --data /var/opt/bytebase