Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Make docker build work
天舟d4d4b66641a1
diff --git a/.dockerignore b/.dockerignorenew file mode 100644index 0000000000..75bf68a825--- /dev/null+++ b/.dockerignore@@ -0,0 +1,3 @@+frontend/node_modules+server/dist+bytebase-build\ No newline at end of filediff --git a/Dockerfile b/Dockerfileindex c9f8995f53..fafd60ed26 100644--- a/Dockerfile+++ b/Dockerfile@@ -1,3 +1,23 @@+# 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 mhart/alpine-node:14.16.1 as frontend++WORKDIR /frontend-build++# Install build dependency (e.g. vite)+COPY ./frontend/package.json ./frontend/yarn.lock .+RUN yarn++COPY ./frontend/ .++# Build frontend+RUN yarn release-docker+FROM golang:1.16.5-alpine3.13 as backendARG VERSION="development"@@ -13,6 +33,9 @@ WORKDIR /backend-buildCOPY . .+# Copy frontend asset+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_ENABLEDRUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \@@ -20,13 +43,15 @@ RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \-o bytebase \./bin/server/main.go-FROM alpine:3.14.0+# Use alpine instead of scratch because alpine contains many basic utils and the ~10mb overhead is acceptable.+FROM alpine:3.14.0 as monolithicARG VERSION="development"ARG GIT_COMMIT="unknown"ARG BUILD_TIME="unknown"ARG BUILD_USER="unknown"+# See https://github.com/opencontainers/image-spec/blob/master/annotations.mdLABEL org.opencontainers.image.version=${VERSION}LABEL org.opencontainers.image.revision=${GIT_COMMIT}LABEL org.opencontainers.image.created=${BUILD_TIME}@@ -34,6 +59,7 @@ LABEL org.opencontainers.image.authors=${BUILD_USER}COPY --from=backend /backend-build/bytebase /usr/local/bin/+# Directory to store the data, used as the mount pointRUN mkdir -p /var/opt/bytebaseCMD ["--mode", "release", "--host", "http://localhost", "--port", "8080", "--data", "/var/opt/bytebase"]diff --git a/build_docker.sh b/build_docker.shindex c935911b52..2a40ccbd52 100755--- a/build_docker.sh+++ b/build_docker.sh@@ -1,15 +1,33 @@#!/bin/sh-version=`cat ./VERSION`+# cd to the root directory and run+# ./build_docker.sh-echo "Start building Bytebase docker image ${version}..."+# exit when any command fails+set -e++RED='\033[0;31m'+GREEN='\033[0;32m'+NC='\033[0m' # No Color++VERSION=`cat ./VERSION`+echo "Start building Bytebase docker image ${VERSION}..."docker build \- --build-arg VERSION=${version} \+ --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 "Completed building Bytebase docker image ${version}."\ No newline at end of file+echo "${GREEN}Completed building Bytebase docker image ${VERSION}.${NC}"+echo ""+echo "Command to start Bytebase on http://localhost:8080"+echo ""+echo "$ docker run --init --rm --name bytebase --publish 8080:8080 --volume ~/.bytebase/data:/var/opt/bytebase bytebase/bytebase"+echo ""+echo "Command to start Bytebase in demo mode on http://example.com"+echo ""+echo "$ docker run --init --rm --name bytebase --publish 80:8080 --volume ~/.bytebase/data:/var/opt/bytebase bytebase/bytebase --mode demo --host http://example.com"+echo ""\ No newline at end of file