Skip to content

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

chore: change Dockerfile's base image from alpine to debian slim and make (#1615)

Yilong Lifb0943ce7b18
diff --git a/Dockerfile b/Dockerfile
index ec8ae5163a..13fadfdc3a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -20,7 +20,7 @@ COPY ./frontend/ .
# Build frontend
RUN pnpm release-docker
-FROM golang:1.16.5-alpine3.13 as backend
+FROM golang:1.16.5 as backend
ARG VERSION="development"
ARG GO_VERSION="1.16.5"
@@ -31,8 +31,8 @@ ARG BUILD_USER="unknown"
# Build in release mode so we will embed the frontend
ARG RELEASE="release"
-# Need gcc musl-dev for CGO_ENABLED=1
-RUN apk --no-cache add gcc musl-dev
+# Need gcc for CGO_ENABLED=1
+RUN apt-get install -y gcc
WORKDIR /backend-build
@@ -44,13 +44,13 @@ 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_ENABLED
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \
- --tags "${RELEASE} alpine" \
+ --tags "${RELEASE}" \
-ldflags="-w -s -X 'github.com/bytebase/bytebase/bin/server/cmd.version=${VERSION}' -X 'github.com/bytebase/bytebase/bin/server/cmd.goversion=${GO_VERSION}' -X 'github.com/bytebase/bytebase/bin/server/cmd.gitcommit=${GIT_COMMIT}' -X 'github.com/bytebase/bytebase/bin/server/cmd.buildtime=${BUILD_TIME}' -X 'github.com/bytebase/bytebase/bin/server/cmd.builduser=${BUILD_USER}'" \
-o bytebase \
./bin/server/main.go
-# Use alpine instead of scratch because alpine contains many basic utils and the ~10mb overhead is acceptable.
-FROM alpine:3.14.3 as monolithic
+# Use debian because mysql requires glibc.
+FROM debian:bullseye-slim as monolithic
ARG VERSION="development"
ARG GIT_COMMIT="unknown"
@@ -63,10 +63,10 @@ LABEL org.opencontainers.image.revision=${GIT_COMMIT}
LABEL org.opencontainers.image.created=${BUILD_TIME}
LABEL org.opencontainers.image.authors=${BUILD_USER}
-# We need copy timezone file from backend layer.
-# Otherwise, clickhouse cannot be connected due to the missing time zone file in alpine.
-COPY --from=backend /usr/local/go/lib/time/zoneinfo.zip /opt/zoneinfo.zip
-ENV ZONEINFO /opt/zoneinfo.zip
+RUN apt-get update && apt-get install -y locales
+# 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/
@@ -75,7 +75,7 @@ COPY --from=backend /backend-build/bytebase /usr/local/bin/
COPY ./scripts /usr/local/bin/
# Create bytebase user for running Postgres database and server.
-RUN addgroup -g 113 -S bytebase && adduser -u 113 -S -G bytebase bytebase
+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
diff --git a/Dockerfile.bb b/Dockerfile.bb
index 0c381e8264..856ae513c2 100644
--- a/Dockerfile.bb
+++ b/Dockerfile.bb
@@ -5,7 +5,7 @@
# $ docker run --init --rm --name bb bytebase/bb
-FROM golang:1.16.5-alpine3.13 as bb
+FROM golang:1.16.5 as bb
ARG VERSION="development"
ARG GO_VERSION="1.16.5"
@@ -24,8 +24,8 @@ RUN GOOS=linux GOARCH=amd64 go build \
-o bb \
./bin/bb/main.go
-# Use alpine instead of scratch because alpine contains many basic utils and the ~10mb overhead is acceptable.
-FROM alpine:3.14.3 as monolithic
+# Use debian because mysql requires glibc.
+FROM debian:bullseye-slim as monolithic
ARG VERSION="development"
ARG GIT_COMMIT="unknown"
diff --git a/Dockerfile.render b/Dockerfile.render
index 686499da2d..5b8129f06a 100644
--- a/Dockerfile.render
+++ b/Dockerfile.render
@@ -15,7 +15,7 @@ COPY ./frontend/ .
# Build frontend
RUN pnpm release-docker
-FROM golang:1.16.5-alpine3.13 as backend
+FROM golang:1.16.5 as backend
ARG VERSION="development"
ARG GO_VERSION="1.16.5"
@@ -26,8 +26,8 @@ ARG BUILD_USER="unknown"
# Build in release mode so we will embed the frontend
ARG RELEASE="release"
-# Need gcc musl-dev for CGO_ENABLED=1
-RUN apk --no-cache add gcc musl-dev
+# Need gcc for CGO_ENABLED=1
+RUN apt-get install -y gcc
WORKDIR /backend-build
@@ -42,13 +42,13 @@ COPY ./scripts .
# -ldflags="-w -s" means omit DWARF symbol table and the symbol table and debug information
# go-sqlite3 requires CGO_ENABLED
RUN CMD_VERSION=`cat ./VERSION` && CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \
- --tags "${RELEASE} alpine" \
+ --tags "${RELEASE}" \
-ldflags="-w -s -X 'github.com/bytebase/bytebase/bin/server/cmd.version=${CMD_VERSION}' -X 'github.com/bytebase/bytebase/bin/server/cmd.goversion=${GO_VERSION}' -X 'github.com/bytebase/bytebase/bin/server/cmd.gitcommit=${RENDER_GIT_COMMIT}' -X 'github.com/bytebase/bytebase/bin/server/cmd.buildtime=${BUILD_TIME}' -X 'github.com/bytebase/bytebase/bin/server/cmd.builduser=${BUILD_USER}'" \
-o bytebase \
- ./bin/server/main.go;
+ ./bin/server/main.go
-# Use alpine instead of scratch because alpine contains many basic utils and the ~10mb overhead is acceptable.
-FROM alpine:3.14.3 as monolithic
+# Use debian because mysql requires glibc.
+FROM debian:bullseye-slim as monolithic
ARG VERSION="development"
ARG RENDER_GIT_COMMIT="unknown"
@@ -61,14 +61,19 @@ LABEL org.opencontainers.image.revision=${RENDER_GIT_COMMIT}
LABEL org.opencontainers.image.created=${BUILD_TIME}
LABEL org.opencontainers.image.authors=${BUILD_USER}
+RUN apt-get update && apt-get install -y locales
+# 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 utility scripts, we have
# - Demo script to launch Bytebase in readonly demo mode
COPY ./scripts /usr/local/bin/
-# Create bb user for running Postgres database and server.
-RUN addgroup -g 113 -S bytebase && adduser -u 113 -S -G bytebase bytebase
+# Create bytebase user 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
diff --git a/Dockerfile.render-preview b/Dockerfile.render-preview
index 5160928d0a..c1849fa1e4 100644
--- a/Dockerfile.render-preview
+++ b/Dockerfile.render-preview
@@ -17,7 +17,7 @@ COPY ./frontend/ .
# Build frontend
RUN pnpm release-docker
-FROM golang:1.16.5-alpine3.13 as backend
+FROM golang:1.16.5 as backend
ARG VERSION="development"
ARG GO_VERSION="unknown"
@@ -28,8 +28,8 @@ ARG BUILD_USER="unknown"
# Build in release mode so we will embed the frontend
ARG RELEASE="release"
-# Need gcc musl-dev for CGO_ENABLED=1
-RUN apk --no-cache add gcc musl-dev
+# Need gcc for CGO_ENABLED=1
+RUN apt-get install -y gcc
WORKDIR /backend-build
@@ -44,13 +44,13 @@ COPY ./scripts .
# -ldflags="-w -s" means omit DWARF symbol table and the symbol table and debug information
# go-sqlite3 requires CGO_ENABLED
RUN CMD_VERSION=`cat ./VERSION` && CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \
- --tags "${RELEASE} alpine" \
+ --tags "${RELEASE}" \
-ldflags="-w -s -X 'github.com/bytebase/bytebase/bin/server/cmd.version=${CMD_VERSION}' -X 'github.com/bytebase/bytebase/bin/server/cmd.goversion=${GO_VERSION}' -X 'github.com/bytebase/bytebase/bin/server/cmd.gitcommit=${RENDER_GIT_COMMIT}' -X 'github.com/bytebase/bytebase/bin/server/cmd.buildtime=${BUILD_TIME}' -X 'github.com/bytebase/bytebase/bin/server/cmd.builduser=${BUILD_USER}'" \
-o bytebase \
- ./bin/server/main.go;
+ ./bin/server/main.go
-# Use alpine instead of scratch because alpine contains many basic utils and the ~10mb overhead is acceptable.
-FROM alpine:3.14.3 as monolithic
+# Use debian because mysql requires glibc.
+FROM debian:bullseye-slim as monolithic
ARG VERSION="development"
ARG RENDER_GIT_COMMIT="unknown"
@@ -63,14 +63,19 @@ LABEL org.opencontainers.image.revision=${RENDER_GIT_COMMIT}
LABEL org.opencontainers.image.created=${BUILD_TIME}
LABEL org.opencontainers.image.authors=${BUILD_USER}
+RUN apt-get update && apt-get install -y locales
+# 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 utility scripts, we have
# - Demo script to launch Bytebase in readonly demo mode
COPY ./scripts /usr/local/bin/
-# Create bb user for running Postgres database and server.
-RUN addgroup -g 113 -S bytebase && adduser -u 113 -S -G bytebase bytebase
+# Create bytebase user 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