Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: move frontend to github action (#8430)
Danny Xubaf8e3963734
diff --git a/.github/workflows/build-push-ci-image-depot.yml b/.github/workflows/build-push-ci-image-depot.ymlindex ea17d1a8ab..1c811b3c12 100644--- a/.github/workflows/build-push-ci-image-depot.yml+++ b/.github/workflows/build-push-ci-image-depot.yml@@ -21,6 +21,21 @@ jobs:echo "GIT_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENVecho "BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENVecho "BUILD_USER=$(id -u -n)" >> $GITHUB_ENV+ - uses: pnpm/[email protected]+ with:+ version: 8.6.0+ - uses: actions/setup-node@v3+ with:+ node-version: "18"+ cache: pnpm+ cache-dependency-path: "frontend/pnpm-lock.yaml"+ - run: pnpm install --frozen-lockfile+ working-directory: frontend+ - name: Run pnpm release build+ run: |+ cp backend/plugin/advisor/config/* frontend/src/types+ cp backend/enterprise/api/plan.yaml frontend/src/types+ pnpm --dir ./frontend i && pnpm --dir ./frontend release- name: Login to DockerHubuses: docker/login-action@v3with:@@ -34,7 +49,7 @@ jobs:context: .project: ${{ secrets.DEPOT_PROJECT}}token: ${{ secrets.DEPOT_TOKEN }}- file: scripts/Dockerfile+ file: scripts/Dockerfile.depotplatforms: linux/amd64,linux/arm64push: truetags: bytebase/bytebase:release-cidiff --git a/.github/workflows/build-push-release-image.yml b/.github/workflows/build-push-release-image.ymlindex 8eb0b4e299..02b36f38df 100644--- a/.github/workflows/build-push-release-image.yml+++ b/.github/workflows/build-push-release-image.yml@@ -23,6 +23,21 @@ jobs:echo "GIT_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENVecho "BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENVecho "BUILD_USER=$(id -u -n)" >> $GITHUB_ENV+ - uses: pnpm/[email protected]+ with:+ version: 8.6.0+ - uses: actions/setup-node@v3+ with:+ node-version: "18"+ cache: pnpm+ cache-dependency-path: "frontend/pnpm-lock.yaml"+ - run: pnpm install --frozen-lockfile+ working-directory: frontend+ - name: Run pnpm release build+ run: |+ cp backend/plugin/advisor/config/* frontend/src/types+ cp backend/enterprise/api/plan.yaml frontend/src/types+ pnpm --dir ./frontend i && pnpm --dir ./frontend release- name: Login to DockerHubuses: docker/login-action@v3with:@@ -36,7 +51,7 @@ jobs:context: .project: ${{ secrets.DEPOT_PROJECT}}token: ${{ secrets.DEPOT_TOKEN }}- file: scripts/Dockerfile+ file: scripts/Dockerfile.depotplatforms: linux/amd64,linux/arm64push: truetags: bytebase/bytebase:${{ env.RELEASE_VERSION }}diff --git a/scripts/Dockerfile b/scripts/Dockerfileindex 1f1db5e3b9..0bef2296c8 100644--- a/scripts/Dockerfile+++ b/scripts/Dockerfile@@ -41,7 +41,7 @@ ARG RELEASE="release"# Need gcc for CGO_ENABLED=1RUN if [ "$TARGETARCH" = "arm64" ]; then \- apt-get update && apt-get install -y gcc-aarch64-linux-gnu; \+ apt-get install -y gcc-aarch64-linux-gnu; \else \apt-get install -y gcc ;\fidiff --git a/scripts/Dockerfile.depot b/scripts/Dockerfile.depotnew file mode 100644index 0000000000..0694e5266e--- /dev/null+++ b/scripts/Dockerfile.depot@@ -0,0 +1,87 @@+# DO NOT run docker build against this file directly. Instead using ./build_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 golang:1.21.1 as backend+ADD go.mod go.sum /+RUN go mod download++ARG VERSION="development"+ARG VERSION_SUFFIX=""+ARG GO_VERSION="1.21.1"+ARG GIT_COMMIT="unknown"+ARG BUILD_TIME="unknown"+ARG BUILD_USER="unknown"++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 . .++# -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" \+ -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++ENV OPENSSL_CONF /etc/ssl/++# Copy utility scripts, we have+# - Demo script to launch Bytebase in readonly demo mode+COPY ./scripts /usr/local/bin/+COPY ./scripts/.psqlrc /root/.psqlrc++# 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 postgresql-client 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++COPY --from=backend /backend-build/bytebase /usr/local/bin/+COPY --from=backend /etc/ssl/certs /etc/ssl/certs++CMD ["--port", "80", "--data", "/var/opt/bytebase"]++HEALTHCHECK --interval=5m --timeout=60s CMD curl -f http://localhost:80/healthz || exit 1++ENTRYPOINT ["bytebase"]\ No newline at end of filediff --git a/scripts/build_bytebase_docker.sh b/scripts/build_bytebase_docker.shindex 3b205eeb85..2e5f1ac9b3 100755--- a/scripts/build_bytebase_docker.sh+++ b/scripts/build_bytebase_docker.sh@@ -10,9 +10,22 @@ set -ecd "$(dirname "$0")/../". ./scripts/build_init.sh+rm -r ./backend/server/dist++echo "Start building Bytebase frontend"++if command -v pnpm > /dev/null+then+ pnpm --dir ./frontend i && pnpm --dir ./frontend release+else+ npm --prefix ./frontend run release+fi++echo "Completed building Bytebase frontend."+echo "Start building Bytebase docker image ${VERSION}..."-docker build -f ./scripts/Dockerfile \+docker build -f ./scripts/Dockerfile.depot \--build-arg VERSION=${VERSION} \--build-arg GO_VERSION="$(go version)" \--build-arg GIT_COMMIT="$(git rev-parse HEAD)"\