Skip to content

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

feat: introduce --external-url and remove --host (THIS IS A BREAKING CHANGE) (#2608)

tianzhou9284b0edb4de
diff --git a/.vscode/launch.json b/.vscode/launch.json
index c9c0286d64..cdb9fe0201 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -1,24 +1,27 @@
{
- "version": "0.2.0",
- "configurations": [
- {
- "name": "Debug Dev Binary",
- "type": "go",
- "request": "launch",
- "mode": "exec",
- "program": "${workspaceFolder}/.air/bytebase",
- "args": [
- "--port", "8080",
- "--frontend-port", "3000",
- "--data", "${workspaceFolder}/.air",
- ]
- },
- {
- "name": "Attach to Process",
- "type": "go",
- "request": "attach",
- "mode": "local",
- "processId": 0
- }
- ]
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Debug Dev Binary",
+ "type": "go",
+ "request": "launch",
+ "mode": "exec",
+ "program": "${workspaceFolder}/.air/bytebase",
+ "args": [
+ "--port",
+ "8080",
+ "--external-url",
+ "http://localhost:3000",
+ "--data",
+ "${workspaceFolder}/.air"
+ ]
+ },
+ {
+ "name": "Attach to Process",
+ "type": "go",
+ "request": "attach",
+ "mode": "local",
+ "processId": 0
+ }
+ ]
}
diff --git a/Dockerfile b/Dockerfile
index dc2e63feb0..85d2a6ec54 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -90,7 +90,7 @@ RUN mkdir -p /var/opt/bytebase
ENV OPENSSL_CONF /etc/ssl/
-CMD ["--host", "http://localhost", "--port", "80", "--data", "/var/opt/bytebase"]
+CMD ["--port", "80", "--data", "/var/opt/bytebase"]
HEALTHCHECK --interval=5m --timeout=60s CMD curl -f http://localhost:80/healthz || exit 1
diff --git a/Dockerfile.render-demo b/Dockerfile.render-demo
index de9bc997b2..598e731af9 100644
--- a/Dockerfile.render-demo
+++ b/Dockerfile.render-demo
@@ -86,7 +86,7 @@ RUN mkdir -p /var/opt/bytebase
ENV OPENSSL_CONF /etc/ssl/
-CMD ["--host", "http://localhost", "--port", "80", "--data", "/var/opt/bytebase"]
+CMD ["--port", "80", "--data", "/var/opt/bytebase"]
HEALTHCHECK --interval=5m --timeout=60s CMD curl -f http://localhost:80/healthz || exit 1
diff --git a/api/actuator.go b/api/actuator.go
index c8706c411f..85f4c4fcc4 100644
--- a/api/actuator.go
+++ b/api/actuator.go
@@ -10,6 +10,7 @@ type ServerInfo struct {
DemoName string `json:"demoName"`
Host string `json:"host"`
Port string `json:"port"`
+ ExternalURL string `json:"externalUrl"`
NeedAdminSetup bool `json:"needAdminSetup"`
// Rand may be based on the server start time, thus exposing startedTs to the client may cause security issues (e.g. jwt key is based on Rand).
// StartedTs int64 `json:"startedTs"`
diff --git a/bin/server/cmd/profile.go b/bin/server/cmd/profile.go
index 96a03848be..66d680689a 100644
--- a/bin/server/cmd/profile.go
+++ b/bin/server/cmd/profile.go
@@ -26,10 +26,7 @@ func getBaseProfile() server.Profile {
datastorePort := flags.port + 1
return server.Profile{
- BackendHost: flags.host,
- BackendPort: flags.port,
- FrontendHost: flags.frontendHost,
- FrontendPort: flags.frontendPort,
+ ExternalURL: flags.externalURL,
DatastorePort: datastorePort,
Readonly: flags.readonly,
Debug: flags.debug,
@@ -53,8 +50,7 @@ func GetTestProfile(dataDir string, port int) server.Profile {
datastorePort := port + 1
return server.Profile{
Mode: common.ReleaseModeDev,
- BackendHost: flags.host,
- BackendPort: port,
+ ExternalURL: fmt.Sprintf("http://localhost:%d", port),
DatastorePort: datastorePort,
PgUser: "bbtest",
DataDir: dataDir,
@@ -70,8 +66,7 @@ func GetTestProfile(dataDir string, port int) server.Profile {
func GetTestProfileWithExternalPg(dataDir string, port int, pgUser string, pgURL string) server.Profile {
return server.Profile{
Mode: common.ReleaseModeDev,
- BackendHost: flags.host,
- BackendPort: port,
+ ExternalURL: fmt.Sprintf("http://localhost:%d", port),
PgUser: pgUser,
DataDir: dataDir,
DemoDataDir: fmt.Sprintf("demo/%s", common.ReleaseModeDev),
diff --git a/bin/server/cmd/root.go b/bin/server/cmd/root.go
index 903ebd5fab..27add238c9 100644
--- a/bin/server/cmd/root.go
+++ b/bin/server/cmd/root.go
@@ -8,6 +8,7 @@ import (
"os"
"os/signal"
"path/filepath"
+ "strconv"
"strings"
"syscall"
@@ -57,6 +58,12 @@ const (
╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝
%s
+
+************* External Visiting URL (--external-url) *************
+
+%s
+
+******************************************************************
___________________________________________________________________________________________
`
@@ -71,6 +78,8 @@ ________________________________________________________________________________
╚═════╝ ╚═╝ ╚══════╝
`
+ // The placeholder page to instruct user how to configure --external-url.
+ externalURLPlaceholder = "https://www.bytebase.com/docs/get-started/install/external-url"
)
// -----------------------------------Global constant END------------------------------------------
@@ -79,11 +88,9 @@ ________________________________________________________________________________
var (
flags struct {
// Used for Bytebase command line config
- host string
- port int
- frontendHost string
- frontendPort int
- dataDir string
+ port int
+ externalURL string
+ dataDir string
// When we are running in readonly mode:
// - The data file will be opened in readonly mode, no applicable migration or seeding will be applied.
// - Requests other than GET will be rejected
@@ -111,13 +118,6 @@ var (
Use: "bytebase",
Short: "Bytebase is a database schema change and version control tool",
Run: func(_ *cobra.Command, _ []string) {
- if flags.frontendHost == "" {
- flags.frontendHost = flags.host
- }
- if flags.frontendPort == 0 {
- flags.frontendPort = flags.port
- }
-
start()
fmt.Print(byeBanner)
@@ -131,10 +131,18 @@ func Execute() error {
}
func init() {
- rootCmd.PersistentFlags().StringVar(&flags.host, "host", "http://localhost", "host where Bytebase backend is accessed from, must start with http:// or https://. This is used by Bytebase to create the webhook callback endpoint for VCS integration")
- rootCmd.PersistentFlags().IntVar(&flags.port, "port", 80, "port where Bytebase backend is accessed from. This is also used by Bytebase to create the webhook callback endpoint for VCS integration")
- rootCmd.PersistentFlags().StringVar(&flags.frontendHost, "frontend-host", "", "host where Bytebase frontend is accessed from, must start with http:// or https://. This is used by Bytebase to compose the frontend link when posting the webhook event. Default is the same as --host")
- rootCmd.PersistentFlags().IntVar(&flags.frontendPort, "frontend-port", 0, "port where Bytebase frontend is accessed from. This is used by Bytebase to compose the frontend link when posting the webhook event. Default is the same as --port")
+ // In the release build, Bytebase bundles frontend and backend together and runs on a single port as a mono server.
+ // During development, Bytebase frontend runs on a separate port.
+ rootCmd.PersistentFlags().IntVar(&flags.port, "port", 80, "port where Bytebase server runs. Default to 80")
+ // When running the release build in production, most of the time, users would not expose Bytebase directly to the public.
+ // Instead they would configure a gateway to forward the traffic to Bytebase. Users need to set --external-url to the address
+ // exposed on that gateway accordingly.
+ //
+ // It's important to set the correct --external-url. This is used for:
+ // 1. Constructing the correct callback URL when configuring the VCS provider. The callback URL points to the frontend.
+ // 2. Creating the correct webhook endpoint when configuring the project GitOps workflow. The webhook endpoint points to the backend.
+ // Since frontend and backend are bundled and run on the same address in the release build, thus we just need to specify a single external URL.
+ rootCmd.PersistentFlags().StringVar(&flags.externalURL, "external-url", externalURLPlaceholder, "the external URL where user visits Bytebase, must start with http:// or https://")
rootCmd.PersistentFlags().StringVar(&flags.dataDir, "data", ".", "directory where Bytebase stores data. If relative path is supplied, then the path is relative to the directory where Bytebase is under")
rootCmd.PersistentFlags().BoolVar(&flags.readonly, "readonly", false, "whether to run in read-only mode")
rootCmd.PersistentFlags().BoolVar(&flags.demo, "demo", false, "whether to run using demo data")
@@ -155,7 +163,31 @@ func init() {
// -----------------------------------Command Line Config END--------------------------------------
-// -----------------------------------Main Entry Point---------------------------------------------
+func normalizeExternalURL(url string) (string, error) {
+ r := strings.TrimSpace(url)
+ r = strings.TrimSuffix(r, "/")
+ if !common.HasPrefixes(r, "http://", "https://") {
+ return "", errors.Errorf("%s must start with http:// or https://", url)
+ }
+ parts := strings.Split(r, ":")
+ if len(parts) > 3 {
+ return "", errors.Errorf("%s malformed", url)
+ }
+ if len(parts) == 3 {
+ port, err := strconv.Atoi(parts[2])
+ if err != nil {
+ return "", errors.Errorf("%s has non integer port", url)
+ }
+ // The external URL is used as the redirectURL in the get token process of OAuth, and the
+ // RedirectURL needs to be consistent with the RedirectURL in the get code process.
+ // The frontend gets it through window.location.origin in the get code
+ // process, so port 80/443 need to be cropped.
+ if port == 80 || port == 443 {
+ r = strings.Join(parts[0:2], ":")
+ }
+ }
+ return r, nil
+}
func checkDataDir() error {
// Convert to absolute path if relative path is supplied.
@@ -200,9 +232,10 @@ func start() {
}
defer log.Sync()
- // check flags
- if !common.HasPrefixes(flags.host, "http://", "https://") {
- log.Error(fmt.Sprintf("--host %s must start with http:// or https://", flags.host))
+ var err error
+ flags.externalURL, err = normalizeExternalURL(flags.externalURL)
+ if err != nil {
+ log.Error("invalid --external-url", zap.Error(err))
return
}
if err := checkDataDir(); err != nil {
@@ -233,14 +266,20 @@ func start() {
cancel()
}()
- s, err := server.NewServer(ctx, profile)
+ s, err = server.NewServer(ctx, profile)
if err != nil {
log.Error("Cannot new server", zap.Error(err))
return
}
- fmt.Printf(greetingBanner, fmt.Sprintf("Version %s has started at %s:%d", profile.Version, profile.BackendHost, profile.BackendPort))
+
+ exteranlAddr := profile.ExternalURL
+ if profile.ExternalURL == externalURLPlaceholder {
+ exteranlAddr = fmt.Sprintf("!!! You have not set --external-url. If you want to make Bytebase\n!!! externally accessible, follow:\n\n%s", externalURLPlaceholder)
+ }
+ fmt.Printf(greetingBanner, fmt.Sprintf("Version %s has started on port %d", profile.Version, flags.port), exteranlAddr)
+
// Execute program.
- if err := s.Run(ctx); err != nil {
+ if err := s.Run(ctx, flags.port); err != nil {
if err != http.ErrServerClosed {
log.Error(err.Error())
_ = s.Shutdown(ctx)
diff --git a/bin/server/cmd/root_test.go b/bin/server/cmd/root_test.go
new file mode 100644
index 0000000000..ec72110b81
--- /dev/null
+++ b/bin/server/cmd/root_test.go
@@ -0,0 +1,72 @@
+package cmd
+
+import (
+ "testing"
+)
+
+func TestNormalizeExternalURL(t *testing.T) {
+ tests := []struct {
+ url string
+ want string
+ wantErr bool
+ }{
+ {
+ url: "http://localhost:3000",
+ want: "http://localhost:3000",
+ wantErr: false,
+ },
+ {
+ url: "https://localhost:3000",
+ want: "https://localhost:3000",
+ wantErr: false,
+ },
+ {
+ url: "https://localhost",
+ want: "https://localhost",
+ wantErr: false,
+ },
+ {
+ url: "http://localhost:80",
+ want: "http://localhost",
+ wantErr: false,
+ },
+ {
+ url: "https://localhost:443",
+ want: "https://localhost",
+ wantErr: false,
+ },
+ {
+ url: " https://localhost:3000/ ",
+ want: "https://localhost:3000",
+ wantErr: false,
+ },
+ // Missing http:// or https://
+ {
+ url: "localhost:3000",
+ want: "",
+ wantErr: true,
+ },
+ // Invalid port
+ {
+ url: "http://localhost:xxx",
+ want: "",
+ wantErr: true,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.url, func(t *testing.T) {
+ g, err := normalizeExternalURL(tt.url)
+ if err != nil {
+ if !tt.wantErr {
+ t.Errorf("expect no error, got %s", err.Error())
+ }
+ } else {
+ if tt.wantErr {
+ t.Errorf("expect error")
+ } else if tt.want != g {
+ t.Errorf("expect %s, got %s", tt.want, g)
+ }
+ }
+ })
+ }
+}
diff --git a/frontend/src/components/BannersWrapper.vue b/frontend/src/components/BannersWrapper.vue
index c991fc04e5..c176c6d413 100644
--- a/frontend/src/components/BannersWrapper.vue
+++ b/frontend/src/components/BannersWrapper.vue
@@ -15,6 +15,9 @@
{{ $t("banner.readonly") }}
</div>
</template>
+ <template v-if="shouldShowExternalUrlBanner">
+ <BannerExternalUrl />
+ </template>
</template>
<script lang="ts" setup>
@@ -29,6 +32,7 @@ import {
import { isDBAOrOwner } from "@/utils";
import BannerDemo from "@/views/BannerDemo.vue";
import BannerDebug from "@/views/BannerDebug.vue";
+import BannerExternalUrl from "@/views/BannerExternalUrl.vue";
import BannerSubscription from "@/views/BannerSubscription.vue";
const actuatorStore = useActuatorStore();
@@ -36,7 +40,8 @@ const currentUser = useCurrentUser();
const debugStore = useDebugStore();
const subscriptionStore = useSubscriptionStore();
-const { isDemo, isReadonly } = storeToRefs(actuatorStore);
+const { isDemo, isReadonly, needConfigureExternalUrl } =
+ storeToRefs(actuatorStore);
const { isDebug } = storeToRefs(debugStore);
const { isExpired, isTrialing } = storeToRefs(subscriptionStore);
@@ -64,4 +69,8 @@ const shouldShowSubscriptionBanner = computed(() => {
const shouldShowReadonlyBanner = computed(() => {
return !isDemo.value && isReadonly.value;
});
+
+const shouldShowExternalUrlBanner = computed(() => {
+ return needConfigureExternalUrl.value;
+});
</script>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index ef93c75faf..e3afa9c55f 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -290,7 +290,9 @@
"extend-trial": "Extend trialing time",
"action": "Deploy yours in 5 seconds",
"debug": "Debug mode is active, you can disable Debug mode via the top-right profile dropdown.",
- "readonly": "Server is in readonly mode. You can still view the console, but any change attempt will fail."
+ "readonly": "Bytebase is in readonly mode. You can still view the console, but any change attempt will fail.",
+ "external-url": "Bytebase has not configured --external-url",
+ "configure-now": "Configure now"
},
"intro": {
"doc": "doc",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 936259cd5e..42ba89f8dd 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -290,7 +290,9 @@
"extend-trial": "申请延长试用",
"action": "5 秒部署您自己的服务",
"debug": "Debug 模式已开启,您可以通过右上角头像下拉框关闭 Debug。",
- "readonly": "服务器处于只读模式。您仍然可以查看控制台,但任何尝试更改的请求都会失败。"
+ "readonly": "Bytebase 处于只读模式。您仍然可以查看控制台,但任何尝试更改的请求都会失败。",
+ "external-url": "Bytebase 还没有配置 --external-url",
+ "configure-now": "现在配置"
},
"intro": {
"doc": "文档",
diff --git a/frontend/src/store/modules/actuator.ts b/frontend/src/store/modules/actuator.ts
index b66dc2798c..bf5bc65308 100644
--- a/frontend/src/store/modules/actuator.ts
+++ b/frontend/src/store/modules/actuator.ts
@@ -2,6 +2,9 @@ import axios from "axios";
import { defineStore } from "pinia";
import { ActuatorState, ServerInfo } from "@/types";
+const EXTERNAL_URL_PLACEHOLDER =
+ "https://www.bytebase.com/docs/get-started/install/external-url";
+
export const useActuatorStore = defineStore("actuator", {
state: (): ActuatorState => ({
serverInfo: undefined,
@@ -25,6 +28,9 @@ export const useActuatorStore = defineStore("actuator", {
needAdminSetup: (state) => {
return state.serverInfo?.needAdminSetup || false;
},
+ needConfigureExternalUrl: (state) => {
+ return state.serverInfo?.externalUrl === EXTERNAL_URL_PLACEHOLDER;
+ },
},
actions: {
setServerInfo(serverInfo: ServerInfo) {
diff --git a/frontend/src/types/actuator.ts b/frontend/src/types/actuator.ts
index b789b23f89..b575e5928d 100644
--- a/frontend/src/types/actuator.ts
+++ b/frontend/src/types/actuator.ts
@@ -4,8 +4,7 @@ export type ServerInfo = {
readonly: boolean;
demo: boolean;
demoName: string;
- host: string;
- port: string;
+ externalUrl: string;
needAdminSetup: boolean;
startedTs: number;
};
diff --git a/frontend/src/views/BannerExternalUrl.vue b/frontend/src/views/BannerExternalUrl.vue
new file mode 100644
index 0000000000..b30a38c20f
--- /dev/null
+++ b/frontend/src/views/BannerExternalUrl.vue
@@ -0,0 +1,51 @@
+<template>
+ <div v-if="show" class="bg-accent">
+ <div class="mx-auto py-3 px-3">
+ <div class="flex items-center justify-between flex-wrap">
+ <div class="w-0 flex-1 flex items-center">
+ <p class="ml-3 font-medium text-white truncate">
+ <span>
+ {{ $t("banner.external-url") }}
+ </span>
+ </p>
+ </div>
+ <div
+ class="order-3 mt-2 flex-shrink-0 w-full sm:order-2 sm:mt-0 sm:w-auto"
+ >
+ <a
+ href="https://www.bytebase.com/docs/get-started/install/external-url?source=console"
+ target="_blank"
+ class="flex items-center justify-center pl-4 pr-2 py-2 border border-transparent rounded-md shadow-sm text-base font-medium text-accent bg-white hover:bg-indigo-50"
+ >
+ {{ $t("banner.configure-now") }}
+ <heroicons-outline:wrench-screwdriver class="ml-1 w-5 h-5" />
+ </a>
+ </div>
+ <div class="order-2 flex-shrink-0 sm:order-3 sm:ml-3">
+ <button
+ type="button"
+ class="-mr-1 flex p-2 rounded-md hover:bg-accent-hover focus:outline-none focus:ring-2 focus:ring-white sm:-mr-2"
+ @click.prevent="show = false"
+ >
+ <span class="sr-only">{{ $t("common.dismiss") }}</span>
+ <!-- Heroicon name: outline/x -->
+ <heroicons-outline:x class="h-6 w-6 text-white" />
+ </button>
+ </div>
+ </div>
+ </div>
+ </div>
+</template>
+
+<script lang="ts">
+import { defineComponent, ref } from "vue";
+
+export default defineComponent({
+ name: "BannerExternalUrl",
+ setup() {
+ const show = ref(true);
+
+ return { show };
+ },
+});
+</script>
diff --git a/helm-charts/bytebase/templates/statefulset.yaml b/helm-charts/bytebase/templates/statefulset.yaml
index 4522bfe0c7..41959b8211 100644
--- a/helm-charts/bytebase/templates/statefulset.yaml
+++ b/helm-charts/bytebase/templates/statefulset.yaml
@@ -29,10 +29,10 @@ spec:
[
"--data",
{{ $data | quote }},
- "--host",
- {{ $host | quote }},
"--port",
{{ $port | quote }},
+ "--external-url",
+ {{ $external-url | quote }},
"--pg",
{{ $pg | quote}},
]
diff --git a/helm-charts/bytebase/values.yaml b/helm-charts/bytebase/values.yaml
index c1cc2d8999..4bd247c3eb 100644
--- a/helm-charts/bytebase/values.yaml
+++ b/helm-charts/bytebase/values.yaml
@@ -4,8 +4,9 @@
bytebase:
option:
- host: http://localhost
port: 8080
+ # You should set this to the URL where users visits Bytebase.
+ external-url: https://www.bytebase.com/docs/get-started/install/external-url
pg: postgresql://user:secret@host:port/dbname
data: /var/opt/bytebase
version: 1.3.2
diff --git a/quickstart/clickhouse-cluster-quickstart.docker-compose.yml b/quickstart/clickhouse-cluster-quickstart.docker-compose.yml
index 8478807a25..323fc11fc6 100644
--- a/quickstart/clickhouse-cluster-quickstart.docker-compose.yml
+++ b/quickstart/clickhouse-cluster-quickstart.docker-compose.yml
@@ -1,4 +1,4 @@
-version: '3.7'
+version: "3.7"
services:
bb:
@@ -11,21 +11,13 @@ services:
# # Uncomment the following lines to persist data
# volumes:
# - ~/.bytebase/data:/var/opt/bytebase
- command:
- [
- "--data",
- "/var/opt/bytebase",
- "--host",
- "http://localhost",
- "--port",
- "8080"
- ]
- networks: [ clickhouse-network ]
+ command: ["--data", "/var/opt/bytebase", "--port", "8080"]
+ networks: [clickhouse-network]
# Clickhouse cluster
zookeeper:
image: zookeeper
- networks: [ clickhouse-network ]
+ networks: [clickhouse-network]
clickhouse01:
image: yandex/clickhouse-server
@@ -40,7 +32,7 @@ services:
- ./clickhouse/users.xml:/etc/clickhouse-server/users.xml
- ./clickhouse-cluster/clickhouse01.config.xml:/etc/clickhouse-server/config.xml
- ./clickhouse-cluster/test_schema:/docker-entrypoint-initdb.d
- networks: [ clickhouse-network ]
+ networks: [clickhouse-network]
depends_on:
- zookeeper
@@ -57,7 +49,7 @@ services:
- ./clickhouse/users.xml:/etc/clickhouse-server/users.xml
- ./clickhouse-cluster/clickhouse02.config.xml:/etc/clickhouse-server/config.xml
- ./clickhouse-cluster/test_schema:/docker-entrypoint-initdb.d
- networks: [ clickhouse-network ]
+ networks: [clickhouse-network]
depends_on:
- zookeeper
@@ -74,7 +66,7 @@ services:
- ./clickhouse/users.xml:/etc/clickhouse-server/users.xml
- ./clickhouse-cluster/clickhouse03.config.xml:/etc/clickhouse-server/config.xml
- ./clickhouse-cluster/test_schema:/docker-entrypoint-initdb.d
- networks: [ clickhouse-network ]
+ networks: [clickhouse-network]
depends_on:
- zookeeper
@@ -91,7 +83,7 @@ services:
- ./clickhouse/users.xml:/etc/clickhouse-server/users.xml
- ./clickhouse-cluster/clickhouse04.config.xml:/etc/clickhouse-server/config.xml
- ./clickhouse-cluster/test_schema:/docker-entrypoint-initdb.d
- networks: [ clickhouse-network ]
+ networks: [clickhouse-network]
depends_on:
- zookeeper
diff --git a/quickstart/clickhouse-quickstart.docker-compose.yml b/quickstart/clickhouse-quickstart.docker-compose.yml
index 3c904af5d1..e295685612 100644
--- a/quickstart/clickhouse-quickstart.docker-compose.yml
+++ b/quickstart/clickhouse-quickstart.docker-compose.yml
@@ -1,4 +1,4 @@
-version: '3.7'
+version: "3.7"
services:
bb:
@@ -11,15 +11,7 @@ services:
# # Uncomment the following lines to persist data
# volumes:
# - ~/.bytebase/data:/var/opt/bytebase
- command:
- [
- "--data",
- "/var/opt/bytebase",
- "--host",
- "http://localhost",
- "--port",
- "8080"
- ]
+ command: ["--data", "/var/opt/bytebase", "--port", "8080"]
clickhouse-db:
image: yandex/clickhouse-server
diff --git a/quickstart/getting-started.docker-compose.yml b/quickstart/getting-started.docker-compose.yml
index ef8715207f..09ec85344b 100644
--- a/quickstart/getting-started.docker-compose.yml
+++ b/quickstart/getting-started.docker-compose.yml
@@ -1,4 +1,4 @@
-version: '3.7'
+version: "3.7"
services:
bytebase:
@@ -11,15 +11,7 @@ services:
# # Uncomment the following lines to persist data
# volumes:
# - ~/.bytebase/data:/var/opt/bytebase
- command:
- [
- "--data",
- "/var/opt/bytebase",
- "--host",
- "http://localhost",
- "--port",
- "5678"
- ]
+ command: ["--data", "/var/opt/bytebase", "--port", "5678"]
employee-prod:
image: bytebase/sample-database:mysql-employee-small
diff --git a/quickstart/gitlab-quickstart.docker-compose.yml b/quickstart/gitlab-quickstart.docker-compose.yml
index a8f46c679a..28f00c1f5b 100644
--- a/quickstart/gitlab-quickstart.docker-compose.yml
+++ b/quickstart/gitlab-quickstart.docker-compose.yml
@@ -1,4 +1,4 @@
-version: '3.7'
+version: "3.7"
services:
bb:
@@ -11,15 +11,7 @@ services:
# # Uncomment the following lines to persist data
# volumes:
# - ~/.bytebase/data:/var/opt/bytebase
- command:
- [
- "--data",
- "/var/opt/bytebase",
- "--host",
- "http://localhost",
- "--port",
- "8080"
- ]
+ command: ["--data", "/var/opt/bytebase", "--port", "8080"]
gitlab:
image: yrzr/gitlab-ce-arm64v8
diff --git a/quickstart/mysql-quickstart.docker-compose.yml b/quickstart/mysql-quickstart.docker-compose.yml
index a454583abf..074fd21cac 100644
--- a/quickstart/mysql-quickstart.docker-compose.yml
+++ b/quickstart/mysql-quickstart.docker-compose.yml
@@ -1,4 +1,4 @@
-version: '3.7'
+version: "3.7"
services:
bb:
@@ -11,15 +11,7 @@ services:
# # Uncomment the following lines to persist data
# volumes:
# - ~/.bytebase/data:/var/opt/bytebase
- command:
- [
- "--data",
- "/var/opt/bytebase",
- "--host",
- "http://localhost",
- "--port",
- "8080"
- ]
+ command: ["--data", "/var/opt/bytebase", "--port", "8080"]
mysql-db:
image: mysql
diff --git a/scripts/.air.toml b/scripts/.air.toml
index 4610f9414f..d0d5c6cf84 100644
--- a/scripts/.air.toml
+++ b/scripts/.air.toml
@@ -2,7 +2,7 @@ root = "."
tmp_dir = ".air"
[build]
- bin = "./.air/bytebase --port 8080 --frontend-port 3000 --data . --debug"
+ bin = './.air/bytebase --port 8080 --external-url http:\/\/localhost:3000 --data . --debug'
## Use --tags "store.db" to enable SQL query logging against our metadata db.
cmd = """
go build \
diff --git a/scripts/build.sh b/scripts/build.sh
index f2ef64e767..c5684cbb31 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -62,7 +62,11 @@ ${OUTPUT_BINARY} version
echo ""
echo "${GREEN}Completed building Bytebase monolithic ${VERSION} at ${OUTPUT_BINARY}.${NC}"
echo ""
-echo "Command to start Bytebase on http://localhost:8080"
+echo "Command to start Bytebase on port 8080"
echo ""
-echo "$ ${OUTPUT_BINARY} --host http://localhost --port 8080${NC}"
+echo "$ ${OUTPUT_BINARY} --port 8080${NC}"
+echo ""
+echo "Command to start Bytebase on port 8080 and exposed at http://example.com via a separate gateway"
+echo ""
+echo "$ ${OUTPUT_BINARY} --port 8080 --external-url http://example.com${NC}"
echo ""
diff --git a/scripts/build_docker.sh b/scripts/build_docker.sh
index a5bb11b236..4f28f06fc3 100755
--- a/scripts/build_docker.sh
+++ b/scripts/build_docker.sh
@@ -26,15 +26,15 @@ echo "Command to tag and push the image"
echo ""
echo "$ docker tag bytebase/bytebase bytebase/bytebase:${VERSION}; docker push bytebase/bytebase:${VERSION}"
echo ""
-echo "Command to start Bytebase on http://localhost:8080"
+echo "Command to start Bytebase on port 8080"
echo ""
-echo "$ docker run --init --name bytebase --restart always --publish 8080:8080 --volume ~/.bytebase/data:/var/opt/bytebase bytebase/bytebase:${VERSION} --data /var/opt/bytebase --host http://localhost --port 8080"
+echo "$ docker run --init --name bytebase --restart always --publish 8080:8080 --volume ~/.bytebase/data:/var/opt/bytebase bytebase/bytebase:${VERSION} --data /var/opt/bytebase --port 8080"
echo ""
-echo "Command to start Bytebase in demo mode on http://example.com"
+echo "Command to start Bytebase on port 8080 and exposed at http://example.com via a separate gateway"
echo ""
-echo "$ docker run --init --name bytebase --restart always --publish 80:80 --volume ~/.bytebase/data:/var/opt/bytebase bytebase/bytebase:${VERSION} --data /var/opt/bytebase --host http://example.com --port 80 --demo"
+echo "$ docker run --init --name bytebase --restart always --publish 8080:8080 --volume ~/.bytebase/data:/var/opt/bytebase bytebase/bytebase:${VERSION} --data /var/opt/bytebase --port 8080 --external-url http://example.com"
echo ""
-echo "Command to start Bytebase in readonly mode on http://example.com"
+echo "Command to start Bytebase in readonly and demo mode on port 8080"
echo ""
-echo "$ docker run --init --name bytebase --restart always --publish 80:80 --volume ~/.bytebase/data:/var/opt/bytebase bytebase/bytebase:${VERSION} --data /var/opt/bytebase --host http://example.com --port 80 --readonly"
+echo "$ docker run --init --name bytebase --restart always --publish 8080:8080 --volume ~/.bytebase/data:/var/opt/bytebase bytebase/bytebase:${VERSION} --data /var/opt/bytebase --port 8080 --demo --readonly"
echo ""
diff --git a/scripts/demo.sh b/scripts/demo.sh
index e327790e82..9c80382128 100644
--- a/scripts/demo.sh
+++ b/scripts/demo.sh
@@ -11,14 +11,14 @@
# ./demo.sh https://schema-migration.demo.bytebase.com schema-migration
# If no parameter is passed, use https://demo.bytebase.com as host and 443 as port by default
-ONLINE_DEMO_HOST='https://demo.bytebase.com'
+ONLINE_DEMO_EXTERNAL_URL='https://demo.bytebase.com'
ONLINE_DEMO_PORT='443'
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
+ ONLINE_DEMO_EXTERNAL_URL=$PROTOCAL://$URI
if [ $PORT ]; then
ONLINE_DEMO_PORT=$PORT
@@ -33,7 +33,7 @@ fi
seedDemoData() {
echo 'Seeding data for online demo'
- bytebase --host ${ONLINE_DEMO_HOST} --port ${ONLINE_DEMO_PORT} --demo --demo-name ${DEMO_NAME} --data /var/opt/bytebase &
+ bytebase --port ${ONLINE_DEMO_PORT} --external-url ${ONLINE_DEMO_EXTERNAL_URL} --demo --demo-name ${DEMO_NAME} --data /var/opt/bytebase &
until [ -f /var/opt/bytebase/pgdata/PG_VERSION ]; do
echo "waiting..."
@@ -50,9 +50,9 @@ seedDemoData() {
}
startReadonly() {
- echo "Starting Bytebase in readonly and demo mode at ${ONLINE_DEMO_HOST}:${ONLINE_DEMO_PORT}..."
+ echo "Starting Bytebase in readonly and demo mode on port ${ONLINE_DEMO_PORT}, visiting from ${ONLINE_DEMO_EXTERNAL_URL}..."
- bytebase --host ${ONLINE_DEMO_HOST} --port ${ONLINE_DEMO_PORT} --readonly --demo --demo-name ${DEMO_NAME} --data /var/opt/bytebase
+ bytebase --port ${ONLINE_DEMO_PORT} --external-url ${ONLINE_DEMO_EXTERNAL_URL} --readonly --demo --demo-name ${DEMO_NAME} --data /var/opt/bytebase
}
seedDemoData
diff --git a/scripts/staging.sh b/scripts/staging.sh
index c2afe792ea..1a595d442e 100644
--- a/scripts/staging.sh
+++ b/scripts/staging.sh
@@ -9,20 +9,20 @@
# ./staging.sh https://example.com:8080
# If no parameter is passed, use https://staging.bytebase.com as host and 443 as port by default
-ONLINE_DEMO_HOST='https://staging.bytebase.com'
+ONLINE_DEMO_EXTERNAL_URL='https://staging.bytebase.com'
ONLINE_DEMO_PORT='443'
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
+ ONLINE_DEMO_EXTERNAL_URL=$PROTOCAL://$URI
if [ $PORT ]; then
ONLINE_DEMO_PORT=$PORT
fi
fi
-echo "Starting Bytebase in demo mode at ${ONLINE_DEMO_HOST}:${ONLINE_DEMO_PORT}..."
+echo "Starting Bytebase in demo mode on port ${ONLINE_DEMO_PORT}, visiting from ${ONLINE_DEMO_EXTERNAL_URL}..."
-bytebase --host ${ONLINE_DEMO_HOST} --port ${ONLINE_DEMO_PORT} --demo --data /var/opt/bytebase --debug
+bytebase --port ${ONLINE_DEMO_PORT} --external-url ${ONLINE_DEMO_EXTERNAL_URL} --demo --data /var/opt/bytebase --debug
diff --git a/server/activity_manager.go b/server/activity_manager.go
index c1a55272b3..d511b74855 100644
--- a/server/activity_manager.go
+++ b/server/activity_manager.go
@@ -104,7 +104,7 @@ func (m *ActivityManager) getWebhookContext(ctx context.Context, activity *api.A
var webhookCtx webhook.Context
level := webhook.WebhookInfo
title := ""
- link := fmt.Sprintf("%s:%d/issue/%s", m.s.profile.FrontendHost, m.s.profile.FrontendPort, api.IssueSlug(meta.issue))
+ link := fmt.Sprintf("%s/issue/%s", m.s.profile.ExternalURL, api.IssueSlug(meta.issue))
switch activity.Type {
case api.ActivityIssueCreate:
title = "Issue created - " + meta.issue.Name
diff --git a/server/actuator.go b/server/actuator.go
index e81a15e424..d5e2c23d9b 100644
--- a/server/actuator.go
+++ b/server/actuator.go
@@ -2,7 +2,6 @@ package server
import (
"net/http"
- "strconv"
"strings"
"github.com/labstack/echo/v4"
@@ -18,12 +17,11 @@ func (s *Server) registerActuatorRoutes(g *echo.Group) {
ctx := c.Request().Context()
serverInfo := api.ServerInfo{
- Version: s.profile.Version,
- GitCommit: s.profile.GitCommit,
- Readonly: s.profile.Readonly,
- Demo: s.profile.Demo,
- Host: s.profile.BackendHost,
- Port: strconv.Itoa(s.profile.BackendPort),
+ Version: s.profile.Version,
+ GitCommit: s.profile.GitCommit,
+ Readonly: s.profile.Readonly,
+ Demo: s.profile.Demo,
+ ExternalURL: s.profile.ExternalURL,
}
if s.profile.Demo && strings.HasPrefix(s.profile.DemoDataDir, demoDataPath) {
diff --git a/server/auth.go b/server/auth.go
index 01f905f6fe..b0ea923557 100644
--- a/server/auth.go
+++ b/server/auth.go
@@ -87,18 +87,6 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("vcs do not exist, name: %v, ID: %v", login.Name, login.Name)).SetInternal(err)
}
- // We need to attach the RedirectURL in the get token process of OAuth, and the
- // RedirectURL needs to be consistent with the RedirectURL in the get code
- // process. The frontend get it through window.location.origin in the get code
- // process, so port 80 needs to be cropped when the backend splices the
- // RedirectURL.
- var redirectURL string
- if s.profile.FrontendPort == 80 {
- redirectURL = fmt.Sprintf("%s/oauth/callback", s.profile.FrontendHost)
- } else {
- redirectURL = fmt.Sprintf("%s:%d/oauth/callback", s.profile.FrontendHost, s.profile.FrontendPort)
- }
-
// Exchange OAuth Token
oauthToken, err := vcs.Get(vcsFound.Type, vcs.ProviderConfig{}).ExchangeOAuthToken(
ctx,
@@ -107,7 +95,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
ClientID: vcsFound.ApplicationID,
ClientSecret: vcsFound.Secret,
Code: login.Code,
- RedirectURL: redirectURL,
+ RedirectURL: fmt.Sprintf("%s/oauth/callback", s.profile.ExternalURL),
},
)
if err != nil {
diff --git a/server/config.go b/server/config.go
index f886c6ab1f..5304f910ef 100644
--- a/server/config.go
+++ b/server/config.go
@@ -24,15 +24,10 @@ type config struct {
type Profile struct {
// Mode can be "prod" or "dev"
Mode common.ReleaseMode
- // BackendHost is the listening backend host for server
- BackendHost string
- // BackendPort is the binding backend port for server.
- BackendPort int
- // FrontendHost is the listening frontend host for server.
- FrontendHost string
- // FrontendPort is the listening frontend host for server.
- FrontendPort int
- // DatastorePort is the binding port for database instance for storing Bytebase data.
+ // ExternalURL is the URL user visits Bytebase.
+ ExternalURL string
+ // DatastorePort is the binding port for database instance for storing Bytebase metadata.
+ // Only applicable when using embedded PG (PgURL is empty).
DatastorePort int
// PgUser is the user we use to connect to bytebase's Postgres database.
// The name of the database storing metadata is the same as pgUser.
diff --git a/server/oauth.go b/server/oauth.go
index 81860b2b89..b339af4436 100644
--- a/server/oauth.go
+++ b/server/oauth.go
@@ -67,16 +67,7 @@ func (s *Server) registerOAuthRoutes(g *echo.Group) {
}
}
- // We need to attach the RedirectURL in the get token process of oauth,
- // and the RedirectURL needs to be consistent with the RedirectURL in the get code process.
- // The frontend get it through window.location.origin in the get code process,
- // so port 80 needs to be cropped when the backend splices the RedirectURL.
- if s.profile.FrontendPort == 80 {
- oauthExchange.RedirectURL = fmt.Sprintf("%s/oauth/callback", s.profile.FrontendHost)
- } else {
- oauthExchange.RedirectURL = fmt.Sprintf("%s:%d/oauth/callback", s.profile.FrontendHost, s.profile.FrontendPort)
- }
-
+ oauthExchange.RedirectURL = fmt.Sprintf("%s/oauth/callback", s.profile.ExternalURL)
oauthToken, err := vcsPlugin.Get(vcsType, vcsPlugin.ProviderConfig{}).
ExchangeOAuthToken(
c.Request().Context(),
@@ -84,7 +75,7 @@ func (s *Server) registerOAuthRoutes(g *echo.Group) {
oauthExchange,
)
if err != nil {
- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to exchange OAuth token").SetInternal(err)
+ return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to exchange OAuth token. Make sure --external-url: %s matches your browser host.", s.profile.ExternalURL)).SetInternal(err)
}
resp := &api.OAuthToken{
diff --git a/server/project.go b/server/project.go
index 460c963b92..4a4143c9e7 100644
--- a/server/project.go
+++ b/server/project.go
@@ -247,7 +247,7 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("VCS not found with ID: %d", repositoryCreate.VCSID))
}
- repositoryCreate.WebhookURLHost = fmt.Sprintf("%s:%d", s.profile.BackendHost, s.profile.BackendPort)
+ repositoryCreate.WebhookURLHost = s.profile.ExternalURL
repositoryCreate.WebhookEndpointID = uuid.New().String()
secretToken, err := common.RandomString(gitlab.SecretTokenLength)
if err != nil {
@@ -260,7 +260,7 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {
switch vcs.Type {
case vcsPlugin.GitLabSelfHost:
webhookCreate := gitlab.WebhookCreate{
- URL: fmt.Sprintf("%s:%d/%s/%s", s.profile.BackendHost, s.profile.BackendPort, gitlabWebhookPath, repositoryCreate.WebhookEndpointID),
+ URL: fmt.Sprintf("%s/%s/%s", s.profile.ExternalURL, gitlabWebhookPath, repositoryCreate.WebhookEndpointID),
SecretToken: repositoryCreate.WebhookSecretToken,
PushEvents: true,
PushEventsBranchFilter: repositoryCreate.BranchFilter,
@@ -271,13 +271,9 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to marshal request body for creating webhook for project ID: %d", repositoryCreate.ProjectID)).SetInternal(err)
}
case vcsPlugin.GitHubCom:
- webhookHost := s.profile.BackendHost
- if s.profile.BackendHost == "http://localhost" {
- webhookHost = fmt.Sprintf("%s:%d", s.profile.BackendHost, s.profile.BackendPort)
- }
webhookPost := github.WebhookCreateOrUpdate{
Config: github.WebhookConfig{
- URL: fmt.Sprintf("%s/%s/%s", webhookHost, githubWebhookPath, repositoryCreate.WebhookEndpointID),
+ URL: fmt.Sprintf("%s/%s/%s", s.profile.ExternalURL, githubWebhookPath, repositoryCreate.WebhookEndpointID),
ContentType: "json",
Secret: repositoryCreate.WebhookSecretToken,
InsecureSSL: 1, // TODO: Allow user to specify this value through api.RepositoryCreate
@@ -449,7 +445,7 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {
switch vcs.Type {
case vcsPlugin.GitLabSelfHost:
webhookUpdate := gitlab.WebhookUpdate{
- URL: fmt.Sprintf("%s:%d/%s/%s", s.profile.BackendHost, s.profile.BackendPort, gitlabWebhookPath, updatedRepo.WebhookEndpointID),
+ URL: fmt.Sprintf("%s/%s/%s", s.profile.ExternalURL, gitlabWebhookPath, updatedRepo.WebhookEndpointID),
PushEventsBranchFilter: *repoPatch.BranchFilter,
}
webhookUpdatePayload, err = json.Marshal(webhookUpdate)
@@ -459,7 +455,7 @@ func (s *Server) registerProjectRoutes(g *echo.Group) {
case vcsPlugin.GitHubCom:
webhookUpdate := github.WebhookCreateOrUpdate{
Config: github.WebhookConfig{
- URL: fmt.Sprintf("%s:%d/%s/%s", s.profile.BackendHost, s.profile.BackendPort, githubWebhookPath, updatedRepo.WebhookEndpointID),
+ URL: fmt.Sprintf("%s/%s/%s", s.profile.ExternalURL, githubWebhookPath, updatedRepo.WebhookEndpointID),
ContentType: "json",
Secret: updatedRepo.WebhookSecretToken,
InsecureSSL: 1, // TODO: Allow user to specify this value through api.RepositoryPatch
diff --git a/server/project_webhook.go b/server/project_webhook.go
index ca39b3e114..f064b2df1f 100644
--- a/server/project_webhook.go
+++ b/server/project_webhook.go
@@ -194,7 +194,7 @@ func (s *Server) registerProjectWebhookRoutes(g *echo.Group) {
ActivityType: string(api.ActivityIssueCreate),
Title: fmt.Sprintf("Test webhook %q", webhook.Name),
Description: "This is a test",
- Link: fmt.Sprintf("%s:%d/project/%s/webhook/%s", s.profile.FrontendHost, s.profile.FrontendPort, api.ProjectSlug(project), api.ProjectWebhookSlug(webhook)),
+ Link: fmt.Sprintf("%s/project/%s/webhook/%s", s.profile.ExternalURL, api.ProjectSlug(project), api.ProjectWebhookSlug(webhook)),
CreatorID: api.SystemBotID,
CreatorName: "Bytebase",
CreatorEmail: "[email protected]",
diff --git a/server/server.go b/server/server.go
index 463fe25e69..95a8f0112d 100644
--- a/server/server.go
+++ b/server/server.go
@@ -114,9 +114,7 @@ func NewServer(ctx context.Context, prof Profile) (*Server, error) {
// Display config
log.Info("-----Config BEGIN-----")
log.Info(fmt.Sprintf("mode=%s", prof.Mode))
- log.Info(fmt.Sprintf("server=%s:%d", prof.BackendHost, prof.BackendPort))
- log.Info(fmt.Sprintf("datastore=%s:%d", prof.BackendHost, prof.DatastorePort))
- log.Info(fmt.Sprintf("frontend=%s:%d", prof.FrontendHost, prof.FrontendPort))
+ log.Info(fmt.Sprintf("externalURL=%s", prof.ExternalURL))
log.Info(fmt.Sprintf("demoDataDir=%s", prof.DemoDataDir))
log.Info(fmt.Sprintf("readonly=%t", prof.Readonly))
log.Info(fmt.Sprintf("demo=%t", prof.Demo))
@@ -149,6 +147,7 @@ func NewServer(ctx context.Context, prof Profile) (*Server, error) {
pgDataDir = common.GetPostgresDataDir(prof.DataDir)
}
log.Info("-----Embedded Postgres Config BEGIN-----")
+ log.Info(fmt.Sprintf("datastorePort=%d", prof.DatastorePort))
log.Info(fmt.Sprintf("resourceDir=%s", resourceDir))
log.Info(fmt.Sprintf("pgdataDir=%s", pgDataDir))
log.Info("-----Embedded Postgres Config END-----")
@@ -457,7 +456,7 @@ func getInitSetting(ctx context.Context, store *store.Store) (*config, error) {
}
// Run will run the server.
-func (s *Server) Run(ctx context.Context) error {
+func (s *Server) Run(ctx context.Context, port int) error {
ctx, cancel := context.WithCancel(ctx)
s.cancel = cancel
if !s.profile.Readonly {
@@ -482,7 +481,7 @@ func (s *Server) Run(ctx context.Context) error {
// Sleep for 1 sec to make sure port is released between runs.
time.Sleep(time.Duration(1) * time.Second)
- return s.e.Start(fmt.Sprintf(":%d", s.profile.BackendPort))
+ return s.e.Start(fmt.Sprintf(":%d", port))
}
// Shutdown will shut down the server.
diff --git a/server/task_executor.go b/server/task_executor.go
index 14a12ce05b..0ba54bfc45 100644
--- a/server/task_executor.go
+++ b/server/task_executor.go
@@ -238,7 +238,7 @@ func postMigration(ctx context.Context, server *Server, task *api.Task, vcsPushE
bytebaseURL := ""
if issue != nil {
- bytebaseURL = fmt.Sprintf("%s:%d/issue/%s?stage=%d", server.profile.FrontendHost, server.profile.FrontendPort, api.IssueSlug(issue), task.StageID)
+ bytebaseURL = fmt.Sprintf("%s/issue/%s?stage=%d", server.profile.ExternalURL, api.IssueSlug(issue), task.StageID)
}
commitID, err := writeBackLatestSchema(ctx, server, repo, vcsPushEvent, mi, branch, latestSchemaFile, schema, bytebaseURL)
diff --git a/store/migration/dev/LATEST.sql b/store/migration/dev/LATEST.sql
index c4e12919c5..fa8e625a07 100644
--- a/store/migration/dev/LATEST.sql
+++ b/store/migration/dev/LATEST.sql
@@ -931,7 +931,7 @@ CREATE TABLE repository (
-- Push webhook id from the corresponding VCS provider.
-- For GitLab, this is the project webhook id. e.g. 123
external_webhook_id TEXT NOT NULL,
- -- Identify the host of the webhook url where the webhook event sends. We store this to identify stale webhook url whose url doesn't match the current bytebase --host.
+ -- Identify the host of the webhook url where the webhook event sends. We store this to identify stale webhook url whose url doesn't match the current bytebase --external-url.
webhook_url_host TEXT NOT NULL,
-- Identify the target repository receiving the webhook event. This is a random string.
webhook_endpoint_id TEXT NOT NULL,
diff --git a/store/migration/prod/1.0/0000__initial_schema.sql b/store/migration/prod/1.0/0000__initial_schema.sql
index 30472c5297..d53d48ce87 100644
--- a/store/migration/prod/1.0/0000__initial_schema.sql
+++ b/store/migration/prod/1.0/0000__initial_schema.sql
@@ -870,7 +870,7 @@ CREATE TABLE repository (
-- Push webhook id from the corresponding VCS provider.
-- For GitLab, this is the project webhook id. e.g. 123
external_webhook_id TEXT NOT NULL,
- -- Identify the host of the webhook url where the webhook event sends. We store this to identify stale webhook url whose url doesn't match the current bytebase --host.
+ -- Identify the host of the webhook url where the webhook event sends. We store this to identify stale webhook url whose url doesn't match the current bytebase --external-url.
webhook_url_host TEXT NOT NULL,
-- Identify the target repository receiving the webhook event. This is a random string.
webhook_endpoint_id TEXT NOT NULL,
diff --git a/store/migration/prod/LATEST.sql b/store/migration/prod/LATEST.sql
index 20c91abf25..d34c54167a 100644
--- a/store/migration/prod/LATEST.sql
+++ b/store/migration/prod/LATEST.sql
@@ -929,7 +929,7 @@ CREATE TABLE repository (
-- Push webhook id from the corresponding VCS provider.
-- For GitLab, this is the project webhook id. e.g. 123
external_webhook_id TEXT NOT NULL,
- -- Identify the host of the webhook url where the webhook event sends. We store this to identify stale webhook url whose url doesn't match the current bytebase --host.
+ -- Identify the host of the webhook url where the webhook event sends. We store this to identify stale webhook url whose url doesn't match the current bytebase --external-url.
webhook_url_host TEXT NOT NULL,
-- Identify the target repository receiving the webhook event. This is a random string.
webhook_endpoint_id TEXT NOT NULL,
diff --git a/tests/tests.go b/tests/tests.go
index 4b23149961..da18af2509 100644
--- a/tests/tests.go
+++ b/tests/tests.go
@@ -206,7 +206,7 @@ func (ctl *controller) start(ctx context.Context, vcsProviderCreator fake.VCSPro
errChan := make(chan error, 1)
go func() {
- if err := ctl.server.Run(ctx); err != nil {
+ if err := ctl.server.Run(ctx, port); err != nil {
errChan <- errors.Wrap(err, "failed to run main server")
}
}()