Skip to content

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

chore: simplify dockerfile (#15580)

Danny Xue50e77692502
diff --git a/.github/workflows/build-push-release-image.yml b/.github/workflows/build-push-release-image.yml
index fb09251a98..3e2ca0403e 100644
--- a/.github/workflows/build-push-release-image.yml
+++ b/.github/workflows/build-push-release-image.yml
@@ -21,19 +21,6 @@ jobs:
echo "IMAGE_VERSION=${GITHUB_REF_NAME#release/}" >> $GITHUB_ENV
echo "VERSION=$(cat ./scripts/VERSION)" >> $GITHUB_ENV
echo "GIT_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
- - uses: pnpm/action-setup@v4
- with:
- version: '10.6.2'
- - uses: actions/setup-node@v4
- with:
- node-version: '22.14.0'
- cache: pnpm
- cache-dependency-path: "frontend/pnpm-lock.yaml"
- - name: Run pnpm release build
- run: |
- cp backend/enterprise/api/plan.yaml frontend/src/types
- cp backend/component/iam/permission.yaml frontend/src/types/iam
- pnpm --dir ./frontend i && pnpm --dir ./frontend release
- name: Login to DockerHub
uses: docker/login-action@v3
with:
@@ -47,7 +34,7 @@ jobs:
context: .
project: ${{ secrets.DEPOT_PROJECT}}
token: ${{ secrets.DEPOT_TOKEN }}
- file: scripts/Dockerfile.depot
+ file: scripts/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
@@ -69,7 +56,7 @@ jobs:
context: .
project: ${{ secrets.DEPOT_PROJECT}}
token: ${{ secrets.DEPOT_TOKEN }}
- file: scripts/Dockerfile.demo
+ file: scripts/Dockerfile
platforms: linux/amd64
push: true
tags: |
@@ -77,3 +64,4 @@ jobs:
build-args: |
VERSION=${{ env.VERSION }}
GIT_COMMIT=${{ env.GIT_COMMIT }}
+ RELEASE=dev
diff --git a/.github/workflows/build-artifacts-and-draft-release.yml b/.github/workflows/draft-release.yml
similarity index 87%
rename from .github/workflows/build-artifacts-and-draft-release.yml
rename to .github/workflows/draft-release.yml
index 29e90510d6..d603be7d58 100644
--- a/.github/workflows/build-artifacts-and-draft-release.yml
+++ b/.github/workflows/draft-release.yml
@@ -1,4 +1,4 @@
-name: Build release artifacts and draft release
+name: Draft release
on:
push:
diff --git a/scripts/Dockerfile b/scripts/Dockerfile
index 948d83e7ac..8979cff0eb 100644
--- a/scripts/Dockerfile
+++ b/scripts/Dockerfile
@@ -16,6 +16,7 @@ RUN go mod download
ARG TARGETARCH
ARG VERSION
ARG GIT_COMMIT
+ARG RELEASE="release"
RUN if [ "$TARGETARCH" = "arm64" ]; then \
apt-get install -y gcc-aarch64-linux-gnu; \
@@ -36,7 +37,7 @@ COPY ./scripts/VERSION .
# -ldflags="-w -s" means omit DWARF symbol table and the symbol table and debug information
RUN if [ "$TARGETARCH" = "arm64" ]; then CC=aarch64-linux-gnu-gcc && CC_FOR_TARGET=gcc-aarch64-linux-gnu; fi && \
GOARCH=$TARGETARCH CC=$CC CC_FOR_TARGET=$CC_FOR_TARGET go build \
- --tags "release,embed_frontend,docker" \
+ --tags "${RELEASE},embed_frontend,docker" \
-ldflags="-w -s -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.version=${VERSION}' -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.gitcommit=${GIT_COMMIT}'" \
-o bytebase ./backend/bin/server/main.go
diff --git a/scripts/Dockerfile.aws b/scripts/Dockerfile.aws
index 1d55f95fcf..bbcad7ccad 100644
--- a/scripts/Dockerfile.aws
+++ b/scripts/Dockerfile.aws
@@ -16,6 +16,7 @@ RUN go mod download
ARG TARGETARCH
ARG VERSION
ARG GIT_COMMIT
+ARG RELEASE="release"
RUN if [ "$TARGETARCH" = "arm64" ]; then \
apt-get install -y gcc-aarch64-linux-gnu; \
@@ -36,10 +37,9 @@ COPY ./scripts/VERSION .
# -ldflags="-w -s" means omit DWARF symbol table and the symbol table and debug information
RUN if [ "$TARGETARCH" = "arm64" ]; then CC=aarch64-linux-gnu-gcc && CC_FOR_TARGET=gcc-aarch64-linux-gnu; fi && \
GOARCH=$TARGETARCH CC=$CC CC_FOR_TARGET=$CC_FOR_TARGET go build \
- --tags "release,embed_frontend,aws" \
+ --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.gitcommit=${GIT_COMMIT}'" \
- -o bytebase \
- ./backend/bin/server/main.go
+ -o bytebase ./backend/bin/server/main.go
# Use debian to decompress tar files.
FROM debian:bookworm-slim as decompressor
@@ -61,7 +61,7 @@ FROM debian:bookworm-slim as monolithic
ARG TARGETARCH
ARG VERSION
-ARG GIT_COMMI
+ARG GIT_COMMIT
# See https://github.com/opencontainers/image-spec/blob/master/annotations.md
LABEL org.opencontainers.image.version=${VERSION}
diff --git a/scripts/Dockerfile.demo b/scripts/Dockerfile.demo
deleted file mode 100644
index 1aafbdf588..0000000000
--- a/scripts/Dockerfile.demo
+++ /dev/null
@@ -1,94 +0,0 @@
-FROM node:22.14.0 as frontend
-
-ARG GIT_COMMIT="unknown"
-
-RUN npm i -g pnpm
-
-WORKDIR /frontend-build
-
-COPY . .
-
-ENV GIT_COMMIT="${GIT_COMMIT}"
-RUN pnpm --dir frontend release-docker
-
-FROM golang:1.24.1 as backend
-ADD go.mod go.sum /
-RUN go mod download
-
-ARG GIT_COMMIT="unknown"
-
-RUN apt-get install -y gcc
-RUN apt-get update && apt-get install -y libkrb5-dev
-
-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
-RUN VERSION=`cat ./VERSION` && go build \
- --tags "dev,embed_frontend,minidemo,docker" \
- -ldflags="-w -s -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.version=${VERSION}' -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.gitcommit=${GIT_COMMIT}'" \
- -o bytebase \
- ./backend/bin/server/main.go
-
-# Use debian to decompress tar files.
-FROM debian:bookworm-slim as decompressor
-
-ARG TARGETARCH
-
-RUN apt-get update && apt-get install -y xz-utils
-COPY ./backend/resources /tmp/bytebase/resources/
-# These paths must match the paths in backened/resources/utils/utils_dir.go.
-# The real resource dir is decided by the backend at runtime. But we can only extract these at build time.
-# we extract resources to a specific dir here and the backend will create symlinks at runtime.
-RUN mkdir -p /var/opt/bytebase/resources/mongoutil-1.6.1-linux-${TARGETARCH}/
-RUN tar -Jxf /tmp/bytebase/resources/mongoutil/mongoutil-1.6.1-linux-${TARGETARCH}.txz -C /var/opt/bytebase/resources/mongoutil-1.6.1-linux-${TARGETARCH}/
-RUN mkdir -p /var/opt/bytebase/resources/postgres-linux-${TARGETARCH}-16
-RUN tar -Jxf /tmp/bytebase/resources/postgres/postgres-linux-${TARGETARCH}.txz -C /var/opt/bytebase/resources/postgres-linux-${TARGETARCH}-16/
-
-# Use debian because mysql requires glibc.
-FROM debian:bookworm-slim as monolithic
-
-ARG VERSION
-ARG GIT_COMMIT
-
-# See https://github.com/opencontainers/image-spec/blob/master/annotations.md
-LABEL org.opencontainers.image.version=${VERSION}
-LABEL org.opencontainers.image.revision=${GIT_COMMIT}
-
-# 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"
-
-# Copy utility scripts, we have
-# - Demo script to launch Bytebase in readonly demo mode
-COPY ./scripts /usr/local/bin/
-COPY ./scripts/.psqlrc /root/.psqlrc
-# The file indicates running in docker environment.
-RUN touch /etc/bb.env
-COPY --from=backend /backend-build/bytebase /usr/local/bin/
-COPY --from=backend /etc/ssl/certs /etc/ssl/certs
-COPY --from=decompressor /var/opt/bytebase/resources /bytebase/resources
-
-ENV OPENSSL_CONF /etc/ssl/
-
-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/Dockerfile.depot b/scripts/Dockerfile.depot
deleted file mode 100644
index 07a9ddd205..0000000000
--- a/scripts/Dockerfile.depot
+++ /dev/null
@@ -1,83 +0,0 @@
-FROM golang:1.24.1 as backend
-ADD go.mod go.sum /
-RUN go mod download
-
-ARG VERSION
-ARG GIT_COMMIT
-
-RUN if [ "$TARGETARCH" = "arm64" ]; then \
- apt-get install -y gcc-aarch64-linux-gnu; \
- else \
- apt-get install -y gcc ;\
- fi
-RUN apt-get update && apt-get install -y libkrb5-dev
-
-WORKDIR /backend-build
-
-COPY . .
-
-# -ldflags="-w -s" means omit DWARF symbol table and the symbol table and debug information
-RUN if [ "$TARGETARCH" = "arm64" ]; then CC=aarch64-linux-gnu-gcc && CC_FOR_TARGET=gcc-aarch64-linux-gnu; fi && \
- GOARCH=$TARGETARCH CC=$CC CC_FOR_TARGET=$CC_FOR_TARGET go build \
- --tags "release,embed_frontend,docker" \
- -ldflags="-w -s -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.version=${VERSION}' -X 'github.com/bytebase/bytebase/backend/bin/server/cmd.gitcommit=${GIT_COMMIT}'" \
- -o bytebase ./backend/bin/server/main.go
-
-# Use debian to decompress tar files.
-FROM debian:bookworm-slim as decompressor
-
-ARG TARGETARCH
-
-RUN apt-get update && apt-get install -y xz-utils
-COPY ./backend/resources /tmp/bytebase/resources/
-# These paths must match the paths in backened/resources/utils/utils_dir.go.
-# The real resource dir is decided by the backend at runtime. But we can only extract these at build time.
-# we extract resources to a specific dir here and the backend will create symlinks at runtime.
-RUN mkdir -p /var/opt/bytebase/resources/mongoutil-1.6.1-linux-${TARGETARCH}/
-RUN tar -Jxf /tmp/bytebase/resources/mongoutil/mongoutil-1.6.1-linux-${TARGETARCH}.txz -C /var/opt/bytebase/resources/mongoutil-1.6.1-linux-${TARGETARCH}/
-RUN mkdir -p /var/opt/bytebase/resources/postgres-linux-${TARGETARCH}-16
-RUN tar -Jxf /tmp/bytebase/resources/postgres/postgres-linux-${TARGETARCH}.txz -C /var/opt/bytebase/resources/postgres-linux-${TARGETARCH}-16/
-
-
-# Use debian because mysql requires glibc.
-FROM debian:bookworm-slim as monolithic
-
-ARG TARGETARCH
-ARG VERSION
-ARG GIT_COMMIT
-
-# See https://github.com/opencontainers/image-spec/blob/master/annotations.md
-LABEL org.opencontainers.image.version=${VERSION}
-LABEL org.opencontainers.image.revision=${GIT_COMMIT}
-
-# 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 && DEBIAN_FRONTEND=noninteractive apt-get install -y locales curl psmisc procps libncurses5 krb5-user libkrb5-dev
-# 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-${TARGETARCH}-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
-# The file indicates running in docker environment.
-RUN touch /etc/bb.env
-COPY --from=backend /backend-build/bytebase /usr/local/bin/
-COPY --from=backend /etc/ssl/certs /etc/ssl/certs
-COPY --from=decompressor /var/opt/bytebase/resources /bytebase/resources
-
-ENV OPENSSL_CONF /etc/ssl/
-
-CMD ["--port", "8080", "--data", "/var/opt/bytebase"]
-
-HEALTHCHECK --interval=5m --timeout=60s CMD curl -f http://localhost:8080/healthz || exit 1
-
-ENTRYPOINT ["bytebase"]