Skip to content

Commit

Permalink
ci: pre-install the required DuckDB extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
fanyang01 committed Nov 26, 2024
1 parent 230518a commit b6c2c22
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
18 changes: 8 additions & 10 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ FROM debian:bookworm-slim
ARG TARGETOS
ARG TARGETARCH

RUN apt-get update && apt-get install -y \
RUN apt-get update && apt-get install -y debian-archive-keyring \
&& apt-get update && apt-get install -y \
vim \
procps \
curl \
unzip \
libstdc++6 \
python3 \
python3-pip \
python3 python3-pip \
libpq-dev postgresql-client \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

Expand All @@ -68,6 +69,7 @@ RUN if [ "$TARGETARCH" = "arm64" ]; then \
fi && \
curl -LJO https://dev.mysql.com/get/Downloads/MySQL-Shell/mysql-shell-9.1.0-linux-glibc2.28-${ARCH}-64bit.tar.gz \
&& tar -zxvf mysql-shell-9.1.0-linux-glibc2.28-${ARCH}-64bit.tar.gz \
&& rm mysql-shell-9.1.0-linux-glibc2.28-${ARCH}-64bit.tar.gz \
&& mv mysql-shell-9.1.0-linux-glibc2.28-${ARCH}-64bit /usr/local/mysqlsh \
&& ln -s /usr/local/mysqlsh/bin/mysqlsh /usr/local/bin/mysqlsh \
&& mysqlsh --version
Expand All @@ -85,13 +87,6 @@ RUN if [ "$TARGETARCH" = "arm64" ]; then \
&& rm duckdb_cli-linux-$ARCH.zip \
&& duckdb -c 'SELECT extension_name, loaded, install_path FROM duckdb_extensions() where installed'

RUN apt-get update && \
apt-get install -y debian-archive-keyring && \
apt-get update && \
apt-get install -y libpq-dev postgresql-client \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

RUN duckdb -version

RUN useradd --create-home --user-group --shell /bin/bash admin \
Expand All @@ -111,6 +106,9 @@ COPY --chown=admin:admin --chmod=755 devtools/replica-setup-postgres ./replica-s
# ENV LC_CTYPE="en_US.UTF-8"
# ENV LANG="en_US.UTF-8"

# Install the required DuckDB extensions
RUN myduckserver --init

# Expose the ports your server will run on (if applicable)
EXPOSE 3306
EXPOSE 5432
Expand Down
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import (
// The included MySQL client is used in this example, however any MySQL-compatible client will work.

var (
initMode = false

address = "0.0.0.0"
port = 3306
socket string
Expand All @@ -55,6 +57,8 @@ var (
)

func init() {
flag.BoolVar(&initMode, "init", initMode, "Initialize the program and exit. The necessary extensions will be installed.")

flag.StringVar(&address, "address", address, "The address to bind to.")
flag.IntVar(&port, "port", port, "The port to bind to.")
flag.StringVar(&socket, "socket", socket, "The Unix domain socket to bind to.")
Expand Down Expand Up @@ -95,6 +99,12 @@ func main() {

ensureSQLTranslate()

if initMode {
provider := catalog.NewInMemoryDBProvider()
provider.Close()
return
}

provider, err := catalog.NewDBProvider(dataDirectory, dbFileName)
if err != nil {
logrus.Fatalln("Failed to open the database:", err)
Expand Down

0 comments on commit b6c2c22

Please sign in to comment.