Skip to content

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

chore: update scripts for aws (#9751)

ecmadaoef6eb3ab6177
diff --git a/backend/enterprise/plugin/aws/aws.go b/backend/enterprise/plugin/aws/aws.go
index ba4dd22482..d83623b1c2 100644
--- a/backend/enterprise/plugin/aws/aws.go
+++ b/backend/enterprise/plugin/aws/aws.go
@@ -35,7 +35,7 @@ type Provider struct {
// and expose AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION and PRODUCT_ID in the environment.
// And the AWS account must have the permission to access the AWS license manager.
func NewProvider(_ *plugin.ProviderConfig) (plugin.LicenseProvider, error) {
- projectID := os.Getenv("PRODUCT_ID")
+ projectID := os.Getenv("AWS_PRODUCT_ID")
if projectID == "" {
return nil, errors.Errorf("cannot find aws project id")
}
diff --git a/frontend/.env.release-aws b/frontend/.env.release-aws
index 4a53be5f95..958990a8e3 100644
--- a/frontend/.env.release-aws
+++ b/frontend/.env.release-aws
@@ -1,3 +1,2 @@
NODE_ENV=production
-# TODO: change the url
BB_PURCHASE_LICENSE_URL=https://aws.amazon.com/marketplace/pp/prodview-qblqtc45nosps
\ No newline at end of file
diff --git a/frontend/package.json b/frontend/package.json
index d4172d222a..69bf3b1309 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -9,7 +9,7 @@
"release": "export NODE_OPTIONS=--max_old_space_size=8000 && npm run copy:all && vite build --mode release --outDir=../backend/server/dist --emptyOutDir",
"dev-embed": "export NODE OPTIONS=--max_old_space_size=8000 && npm run copy:all && vite build --mode dev --outDir=../backend/server/dist --emptyOutDir",
"release-docker": "export NODE_OPTIONS=--max_old_space_size=8000 && npm run copy:all && vite build --mode release",
- "release-aws": "export NODE_OPTIONS=--max_old_space_size=8000 && npm run copy:all && vite build --mode release-aws --outDir=../backend/server/dist --emptyOutDir",
+ "release-aws": "export NODE_OPTIONS=--max_old_space_size=8000 && npm run copy:all && vite build --mode release-aws",
"lint": "eslint --cache --ext .js,.ts,.tsx,.vue src",
"lint:fix": "eslint --cache --ext .js,.ts,.tsx,.vue --fix src",
"bundle-visualize": "vite-bundle-visualizer -c vite.config.ts",
diff --git a/frontend/src/components/ReleaseRemindModal.vue b/frontend/src/components/ReleaseRemindModal.vue
index 5a59e386c2..40d3e116ae 100644
--- a/frontend/src/components/ReleaseRemindModal.vue
+++ b/frontend/src/components/ReleaseRemindModal.vue
@@ -40,7 +40,7 @@
type="button"
class="btn-primary"
target="_blank"
- href="https://www.bytebase.com/docs/get-started/install/overview"
+ :href="link"
@click="$emit('cancel')"
>
{{ $t("common.learn-more") }}
@@ -51,9 +51,18 @@
</template>
<script lang="ts" setup>
-import { useActuatorV1Store } from "@/store";
+import { computed } from "vue";
+import { useActuatorV1Store, useSubscriptionV1Store } from "@/store";
defineEmits(["cancel"]);
const actuatorStore = useActuatorV1Store();
+const subscriptionStore = useSubscriptionV1Store();
+
+const link = computed(() => {
+ if (subscriptionStore.isSelfHostLicense) {
+ return "https://www.bytebase.com/docs/get-started/install/overview";
+ }
+ return subscriptionStore.purchaseLicenseUrl;
+});
</script>
diff --git a/frontend/src/store/modules/v1/subscription.ts b/frontend/src/store/modules/v1/subscription.ts
index a4e7e1564a..cd264bf8f8 100644
--- a/frontend/src/store/modules/v1/subscription.ts
+++ b/frontend/src/store/modules/v1/subscription.ts
@@ -134,7 +134,7 @@ export const useSubscriptionV1Store = defineStore("subscription_v1", {
return this.isSelfHostLicense && this.currentPlan < PlanType.ENTERPRISE;
},
isSelfHostLicense(state): boolean {
- return import.meta.env.MODE.toLowerCase() !== "aws";
+ return import.meta.env.MODE.toLowerCase() !== "release-aws";
},
purchaseLicenseUrl(state): string {
return import.meta.env.BB_PURCHASE_LICENSE_URL;
diff --git a/scripts/Dockerfile.aws b/scripts/Dockerfile.aws
new file mode 100644
index 0000000000..378db0832a
--- /dev/null
+++ b/scripts/Dockerfile.aws
@@ -0,0 +1,105 @@
+# DO NOT run docker build against this file directly. Instead using ./build_bytebase_docker.sh as that
+# one sets the various ARG used in the Dockerfile
+
+# After build
+
+# $ docker run --init --rm --name bytebase --publish 8080:8080 --volume ~/.bytebase/data:/var/opt/bytebase bytebase/bytebase
+
+FROM node:18 as frontend
+
+ARG TARGETARCH
+ARG RELEASE="release"
+
+RUN npm i -g pnpm
+
+WORKDIR /frontend-build
+
+COPY . .
+
+RUN pnpm --dir frontend install --frozen-lockfile
+RUN pnpm --dir frontend release-aws
+
+FROM golang:1.21.5 as backend
+ADD go.mod go.sum /
+RUN go mod download
+
+ARG VERSION="development"
+ARG VERSION_SUFFIX=""
+ARG GO_VERSION="1.21.5"
+ARG GIT_COMMIT="unknown"
+ARG BUILD_TIME="unknown"
+ARG BUILD_USER="unknown"
+ARG PRODUCT_ID="prod-n4dmmye4e6hjo"
+
+ARG RELEASE="release"
+
+# Need gcc for CGO_ENABLED=1
+RUN if [ "$TARGETARCH" = "arm64" ]; then \
+ apt-get install -y gcc-aarch64-linux-gnu; \
+ else \
+ apt-get install -y gcc ;\
+ fi
+
+WORKDIR /backend-build
+
+COPY . .
+
+# Copy frontend asset
+COPY --from=frontend /frontend-build/frontend/dist ./backend/server/dist
+
+COPY ./scripts/VERSION .
+
+# -ldflags="-w -s" means omit DWARF symbol table and the symbol table and debug information
+# go-sqlite3 requires CGO_ENABLED
+RUN if [ "$TARGETARCH" = "arm64" ]; then \
+ CC=aarch64-linux-gnu-gcc && CC_FOR_TARGET=gcc-aarch64-linux-gnu; \
+ fi && \
+ VERSION=`cat ./scripts/VERSION`${VERSION_SUFFIX} && CGO_ENABLED=1 GOOS=linux GOARCH=$TARGETARCH CC=$CC CC_FOR_TARGET=$CC_FOR_TARGET go build \
+ --tags "${RELEASE},embed_frontend,aws" \
+ -ldflags="-w -s -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.version=${VERSION}' -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.goversion=${GO_VERSION}' -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.gitcommit=${GIT_COMMIT}' -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.buildtime=${BUILD_TIME}' -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.builduser=${BUILD_USER}'" \
+ -o bytebase \
+ ./backend/bin/server/main.go
+
+# Use debian because mysql requires glibc.
+FROM debian:bookworm-slim as monolithic
+
+ARG VERSION="development"
+ARG GIT_COMMIT="unknown"
+ARG BUILD_TIME="unknown"
+ARG BUILD_USER="unknown"
+
+# See https://github.com/opencontainers/image-spec/blob/master/annotations.md
+LABEL org.opencontainers.image.version=${VERSION}
+LABEL org.opencontainers.image.revision=${GIT_COMMIT}
+LABEL org.opencontainers.image.created=${BUILD_TIME}
+LABEL org.opencontainers.image.authors=${BUILD_USER}
+
+# Create user "bytebase" for running Postgres database and server.
+RUN addgroup --gid 113 --system bytebase && adduser --uid 113 --system bytebase && adduser bytebase bytebase
+# Directory to store the data, which can be referenced as the mounting point.
+RUN mkdir -p /var/opt/bytebase
+# Directory to store the demo data.
+RUN mkdir -p /var/opt/bytebase/pgdata-demo
+# Our HEALTHCHECK instruction in dockerfile needs curl.
+# Install psmisc to use killall command in demo.sh used by render.com.
+RUN apt-get update && apt-get install -y locales curl psmisc procps libncurses5
+# Generate en_US.UTF-8 locale which is needed to start postgres server.
+# Fix the posgres server issue (invalid value for parameter "lc_messages": "en_US.UTF-8").
+RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
+ENV PATH="${PATH}:/var/opt/bytebase/resources/postgres-linux-amd64-16/bin:/var/opt/bytebase/resources/postgres-linux-arm64-16/bin"
+
+# Copy utility scripts, we have
+# - Demo script to launch Bytebase in readonly demo mode
+COPY ./scripts /usr/local/bin/
+COPY ./scripts/.psqlrc /root/.psqlrc
+COPY --from=backend /backend-build/bytebase /usr/local/bin/
+COPY --from=backend /etc/ssl/certs /etc/ssl/certs
+
+ENV OPENSSL_CONF /etc/ssl/
+ENV AWS_PRODUCT_ID=$PRODUCT_ID
+
+CMD ["--port", "8080", "--data", "/var/opt/bytebase"]
+
+HEALTHCHECK --interval=5m --timeout=60s CMD curl -f http://localhost:8080/healthz || exit 1
+
+ENTRYPOINT ["bytebase"]
diff --git a/scripts/build_bytebase_aws.sh b/scripts/build_bytebase_aws.sh
new file mode 100644
index 0000000000..938581f924
--- /dev/null
+++ b/scripts/build_bytebase_aws.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+# ===========================================================================
+# File: build_bytebase_aws.sh
+# Description: usage: ./build_bytebase_aws.sh
+# ===========================================================================
+
+# exit when any command fails
+set -e
+
+cd "$(dirname "$0")/../"
+. ./scripts/build_init.sh
+
+echo "Start building Bytebase docker image ${VERSION}..."
+
+docker build -f ./scripts/Dockerfile.aws \
+ --build-arg VERSION=${VERSION} \
+ --build-arg GO_VERSION="$(go version)" \
+ --build-arg GIT_COMMIT="$(git rev-parse HEAD)"\
+ --build-arg BUILD_TIME="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
+ --build-arg BUILD_USER="$(id -u -n)" \
+ -t bytebase/bytebase .
+
+echo "${GREEN}Completed building Bytebase docker image ${VERSION}.${NC}"
+echo ""
+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 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 --port 8080"
+echo ""