diff --git a/Dockerfile b/Dockerfile index 8f27ad7..432433c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,12 @@ -FROM golang:1.20 as builder +FROM golang:1.20 AS builder WORKDIR / COPY . . RUN CGO_ENABLED=1 go build -o quackpipe quackpipe.go RUN strip quackpipe +RUN apt update && apt install -y libgrpc-dev FROM debian:12 COPY --from=builder /quackpipe /quackpipe +COPY --from=builder /usr/share/grpc/roots.pem /usr/share/grpc/roots.pem RUN echo "INSTALL httpfs; INSTALL json; INSTALL parquet; INSTALL fts;" | /quackpipe --stdin CMD ["/quackpipe"] diff --git a/README.md b/README.md index 8e64f29..e79e145 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,17 @@ curl -fsSL github.com/metrico/quackpipe/releases/latest/download/quackpipe-amd64 ./quackpipe --port 8123 --params "/tmp/test.db?access_mode=READ_ONLY" ``` +##### 🔌 Start Server w/ Motherduck authentication token +###### Using DuckDB Params +```bash +./quackpipe --port 8123 --params "/tmp/test.db?motherduck_token=YOUR_TOKEN_HERE" +``` +###### Using System ENV +```bash +export motherduck_token='' +./quackpipe --port 8123 +``` + Run with `-h` for a full list of parameters ##### Parameters diff --git a/quackpipe.go b/quackpipe.go index e290821..2ac0618 100644 --- a/quackpipe.go +++ b/quackpipe.go @@ -51,6 +51,7 @@ func check(args ...interface{}) { func quack(query string, stdin bool, format string, params string, hashdb string) (string, error) { var err error alias := *appFlags.Alias + motherduck, md := os.LookupEnv("motherduck_token") if (len(hashdb) > 0) { params = hashdb + "?" + params @@ -72,6 +73,10 @@ func quack(query string, stdin bool, format string, params string, hashdb string check(db.ExecContext(context.Background(), staticAliases)) } + if (md) && (motherduck != "") { + check(db.ExecContext(context.Background(), "LOAD motherduck; ATTACH 'md:';")) + } + startTime := time.Now() rows, err := db.QueryContext(context.Background(), query) if err != nil {