Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit b76fe4c

Browse files
committed
added custom build instruction
1 parent b61efca commit b76fe4c

File tree

5 files changed

+172
-2
lines changed

5 files changed

+172
-2
lines changed

.devcontainer/Dockerfile

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# [Choice] Java version (use -bullseye variants on local arm64/Apple Silicon): 11, 17, 11-bullseye, 17-bullseye, 11-buster, 17-buster
2+
ARG VARIANT=17
3+
FROM mcr.microsoft.com/vscode/devcontainers/java:0-${VARIANT}
4+
5+
# [Optional] Clojure version
6+
ARG CLOJURE_VERSION=1.10.3
7+
8+
# [Optional] Clojure tools version
9+
ARG CLOJURE_CLI_VERSION=1.10.3.1075
10+
11+
# [Optional] Leiningen version
12+
ARG LEININGEN_VERSION="stable"
13+
14+
# [Optional] POLYLITH version
15+
ARG POLYLITH_VERSION="0.2.13-alpha"
16+
17+
# [Optional] Boot version
18+
ENV BOOT_VERSION=2.8.3
19+
20+
# [Optional] Clojure version used by Boot
21+
ENV BOOT_CLOJURE_VERSION=${CLOJURE_VERSION}
22+
23+
# [Option] Install Clojure CLI tool
24+
ARG INSTALL_CLOJURE_CLI="true"
25+
26+
# [Option] Install Boot
27+
ARG INSTALL_BOOT="true"
28+
29+
# [Option] Install Leiningen
30+
ARG INSTALL_LEININGEN="true"
31+
32+
# [Option] Install Polylith
33+
ARG INSTALL_POLYLITH="true"
34+
35+
RUN if [ "${INSTALL_CLOJURE_CLI}" = "true" ]; then \
36+
apt-get update \
37+
&& apt-get -y install rlwrap \
38+
&& curl -OL "https://download.clojure.org/install/linux-install-${CLOJURE_CLI_VERSION}.sh" \
39+
&& chmod +x linux-install-${CLOJURE_CLI_VERSION}.sh \
40+
&& /linux-install-${CLOJURE_CLI_VERSION}.sh \
41+
&& rm /linux-install-${CLOJURE_CLI_VERSION}.sh \
42+
&& su vscode -c "clj --version"; fi
43+
44+
RUN if [ "${INSTALL_BOOT}" = "true" ]; then \
45+
curl -OL "https://github.com/boot-clj/boot-bin/releases/download/latest/boot.sh" \
46+
&& chmod +x boot.sh \
47+
&& mv boot.sh /usr/local/sbin/boot \
48+
&& su vscode -c "boot -u"; fi
49+
50+
RUN if [ "${INSTALL_LEININGEN}" = "true" ]; then \
51+
curl -OL "https://raw.githubusercontent.com/technomancy/leiningen/${LEININGEN_VERSION}/bin/lein" \
52+
&& chmod +x lein \
53+
&& mv lein /usr/local/sbin; fi
54+
55+
# Cache Clojure and dependencies
56+
RUN if [ "${INSTALL_LEININGEN}" = "true" ]; then \
57+
su vscode -c " cd ~ \
58+
&& echo '(defproject dummy \"\" :dependencies [[org.clojure/clojure \"'${CLOJURE_VERSION}'\"]])' > project.clj \
59+
&& lein deps \
60+
&& rm project.clj"; fi
61+
62+
RUN if [ "${INSTALL_POLYLITH}" = "true" ]; then \
63+
curl -OL "https://github.com/polyfy/polylith/releases/download/v${POLYLITH_VERSION}/poly-${POLYLITH_VERSION}.jar" \
64+
&& mkdir -p /usr/local/polylith \
65+
&& mv poly-$POLYLITH_VERSION.jar /usr/local/polylith \
66+
&& echo '#!/bin/sh\nARGS=""\nwhile [ "$1" != "" ] ; do\n ARGS="$ARGS $1"\n shift\ndone\nexec "java" $JVM_OPTS "-jar" "/usr/local/polylith/poly-'$POLYLITH_VERSION'.jar" $ARGS\n' > /usr/local/sbin/poly \
67+
&& chmod +x /usr/local/sbin/poly \
68+
&& /usr/local/sbin/poly version; fi
69+
70+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
71+
ARG NODE_VERSION="lts/*"
72+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
73+
74+
# [Optional] Uncomment this section to install additional OS packages.
75+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
76+
# && apt-get -y install --no-install-recommends <your-package-list-here>
77+
78+
# [Optional] Uncomment this line to install global node packages.
79+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
80+
81+
# Clean up package lists
82+
RUN apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*

.devcontainer/devcontainer.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/clojure
3+
{
4+
"name": "Clojure (Community)",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"args": {
8+
// Update the VARIANT arg to pick a Java version.
9+
// Append -bullseye or -buster to pin to an OS version.
10+
// Use the -bullseye variants on local arm64/Apple Silicon.
11+
"VARIANT": "17",
12+
// Options
13+
"CLOJURE_VERSION": "1.10.3",
14+
"INSTALL_CLOJURE_CLI": "true",
15+
"INSTALL_BOOT": "true",
16+
"INSTALL_LEININGEN": "true",
17+
"INSTALL_POLYLITH": "true",
18+
"NODE_VERSION": "lts/*"
19+
}
20+
},
21+
22+
// Configure tool-specific properties.
23+
"customizations": {
24+
// Configure properties specific to VS Code.
25+
"vscode": {
26+
// Set *default* container specific settings.json values on container create.
27+
"settings": {
28+
},
29+
30+
// Add the IDs of extensions you want installed when the container is created.
31+
"extensions": [
32+
"vscjava.vscode-java-pack",
33+
"borkdude.clj-kondo",
34+
"betterthantomorrow.calva"
35+
]
36+
}
37+
},
38+
39+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
40+
// "forwardPorts": [],
41+
42+
// Use 'postCreateCommand' to run commands after the container is created.
43+
// "postCreateCommand": "java -version",
44+
45+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
46+
"remoteUser": "vscode"
47+
}

README.md

+42
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,45 @@ Next, in the settings page of DuckDB of Metabase Web UI you could set your DB fi
107107
```
108108

109109
The same way you could mount the dir with parquet files into container and make SQL queries to this files using directory in your container.
110+
111+
## How to build the DuckDB .jar plugin yourself
112+
113+
1. Install VS Code with [DevContainer](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension (see [details](https://code.visualstudio.com/docs/devcontainers/containers))
114+
2. Create some folder, let's say `duckdb_plugin`
115+
3. Clone the `metabase_duckdb_driver` repository into `duckdb_plugin` folder
116+
4. Copy `.devcontainer` from `duckdb_plugin/metabase_duckdb_driver` into `duckdb_plugin`
117+
5. Clone the `metabase` repository of version you need into `duckdb_plugin` folder
118+
6. Now content of the `duckdb_plugin` folder should looks like this:
119+
```
120+
..
121+
.devcontainer
122+
metabase
123+
metabase_duckdb_driver
124+
```
125+
7. Add duckdb record to the deps file `duckdb_plugin/metabase/modules/drivers/deps.edn`
126+
The end of the file sholud looks like this:
127+
```
128+
...
129+
metabase/sqlserver {:local/root "sqlserver"}
130+
metabase/vertica {:local/root "vertica"}
131+
metabase/duckdb {:local/root "duckdb"}}} <- add this!
132+
```
133+
8. Set the DuckDB version you need in the `duckdb_plugin/metabase_duckdb_driver/deps.edn`
134+
9. Create duckdb driver directory in the cloned metabase sourcecode:
135+
```
136+
> mkdir -p duckdb_plugin/metabase/modules/drivers/duckdb
137+
```
138+
10. Copy the `metabase_duckdb_driver` source code into created dir
139+
```
140+
> cp -rf duckdb_plugin/metabase_duckdb_driver/* duckdb_plugin/metabase/modules/drivers/duckdb/
141+
```
142+
11. Open `duckdb_plugin` folder in VSCode using DevContainer extension (vscode will offer to open this folder using devcontainer). Wait until all stuff will be loaded. At the end you will get the terminal opened directly in the VS Code, smth like this:
143+
```
144+
vscode ➜ /workspaces/duckdb_plugin $
145+
```
146+
12. Build the plugin
147+
```
148+
vscode ➜ /workspaces/duckdb_plugin $ cd metabase
149+
vscode ➜ /workspaces/duckdb_plugin $ clojure -X:build:drivers:build/driver :driver :duckdb
150+
```
151+
13. jar file of DuckDB plugin will be generated here duckdb_plugin/metabase/resources/modules/duckdb.metabase-driver.jar

resources/metabase-plugin.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
info:
22
name: Metabase DuckDB Driver
3-
version: 1.0.0-SNAPSHOT-0.1.11
3+
version: 1.0.0-SNAPSHOT-0.1.12
44
description: Allows Metabase to connect to DuckDB databases.
55
contact-info:
66
name: Alexander Golubov

src/metabase/driver/duckdb.clj

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(ns metabase.driver.duckdb
22
(:require [clojure.java.jdbc :as jdbc]
3-
[honey.sql :as hsql]
43
[medley.core :as m]
54
[metabase.driver :as driver]
65
[metabase.driver.sql-jdbc.connection :as sql-jdbc.conn]

0 commit comments

Comments
 (0)