Skip to content

Commit 8fd52b7

Browse files
authored
Add docker setup for running and e2e testing (#14)
Add docker setup for running and e2e testing
1 parent ba0588d commit 8fd52b7

19 files changed

+2568
-11
lines changed

.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
node_modules
3+
docker-compose.*
4+
.dockerignore

.env.docker.example

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
PREMIUM_EMBEDDING_TOKEN="<your_enterprise_token>"
2+
METABASE_JWT_SHARED_SECRET="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
3+
4+
MB_PORT=4300
5+
CLIENT_PORT=4400
6+
AUTH_PROVIDER_PORT=4500

.env.example

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# FRONTEND
2-
PORT=3100
2+
CLIENT_PORT=3100
33
VITE_METABASE_INSTANCE_URL="http://localhost:3000"
44
VITE_AUTH_PROVIDER_URI="http://localhost:9090/sso/metabase"
55

66
# BACKEND
7-
BACKEND_PORT=9090
8-
METABASE_INSTANCE_URL= "http://localhost:3000"
7+
AUTH_PROVIDER_PORT=9090
8+
METABASE_INSTANCE_URL="http://localhost:3000"
99
METABASE_JWT_SHARED_SECRET="TODO"

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
.env
2+
.env.docker
3+
.idea
4+
cypress
5+
local-dist/*
6+
!local-dist/.gitkeep
7+
node_modules
28
client/node_modules
39
server/node_modules

client/Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM node:22-bullseye AS runner
2+
3+
WORKDIR /app
4+
5+
COPY ./client ./client
6+
COPY ./local-dist ./local-dist
7+
8+
WORKDIR /app/client
9+
10+
RUN npm ci
11+
12+
RUN if [ -d "../local-dist/embedding-sdk" ]; then \
13+
echo "Local embedding-sdk dist is found in ../local-dist/embedding-sdk, installing it..."; \
14+
npm install file:../local-dist/embedding-sdk --install-links; \
15+
else \
16+
echo "Local embedding-sdk dist is not found in ../local-dist/embedding-sdk, skipping copy"; \
17+
fi
18+
19+
CMD ["npx", "vite", "--host"]

client/package-lock.json

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"start": "env-cmd -f ../.env vite",
88
"dev": "env-cmd -f ../.env vite",
99
"build": "env-cmd -f ../.env vite build",
10-
"lint": "eslint .",
11-
"preview": "vite preview"
10+
"preview": "env-cmd -f ../.env vite preview",
11+
"lint": "eslint ."
1212
},
1313
"dependencies": {
1414
"@metabase/embedding-sdk-react": "^0.52.15",

client/vite.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export default defineConfig({
66
plugins: [react()],
77
server: {
88
// eslint-disable-next-line no-undef
9-
port: process.env.PORT || 3100,
9+
port: process.env.CLIENT_PORT
1010
},
1111
});

docker-compose.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
services:
2+
metabase:
3+
build:
4+
context: .
5+
dockerfile: metabase/Dockerfile
6+
environment:
7+
MB_CONFIG_FILE_PATH: "./app/init-config.yml"
8+
MB_JETTY_PORT: "${MB_PORT}"
9+
MB_EDITION: "ee"
10+
MB_SITE_URL: "http://localhost:${MB_PORT}/"
11+
MB_JWT_SHARED_SECRET: "${METABASE_JWT_SHARED_SECRET}"
12+
MB_SETUP_TOKEN: "${PREMIUM_EMBEDDING_TOKEN}"
13+
MB_PREMIUM_EMBEDDING_TOKEN: "${PREMIUM_EMBEDDING_TOKEN}"
14+
healthcheck:
15+
test: curl --fail -X GET -I "http://localhost:${MB_PORT}/api/health" || exit 1
16+
interval: 15s
17+
timeout: 5s
18+
retries: 10
19+
ports:
20+
- "${MB_PORT}:${MB_PORT}"
21+
22+
client:
23+
depends_on:
24+
metabase:
25+
condition: service_healthy
26+
server:
27+
condition: service_started
28+
build:
29+
context: .
30+
dockerfile: ./client/Dockerfile
31+
environment:
32+
CLIENT_PORT: "${CLIENT_PORT}"
33+
VITE_METABASE_INSTANCE_URL: "http://localhost:${MB_PORT}"
34+
VITE_AUTH_PROVIDER_URI: "http://localhost:${AUTH_PROVIDER_PORT}/sso/metabase"
35+
ports:
36+
- "${CLIENT_PORT}:${CLIENT_PORT}"
37+
volumes:
38+
- ./client/src:/app/client/src
39+
40+
server:
41+
depends_on:
42+
metabase:
43+
condition: service_healthy
44+
build:
45+
context: .
46+
dockerfile: ./server/Dockerfile
47+
environment:
48+
AUTH_PROVIDER_PORT: "${AUTH_PROVIDER_PORT}"
49+
METABASE_INSTANCE_URL: "http://metabase:${MB_PORT}"
50+
METABASE_JWT_SHARED_SECRET: "${METABASE_JWT_SHARED_SECRET}"
51+
ports:
52+
- "${AUTH_PROVIDER_PORT}:${AUTH_PROVIDER_PORT}"

e2e/support/cypress.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const { defineConfig } = require('cypress')
2+
3+
module.exports = defineConfig({
4+
e2e: {
5+
baseUrl: `http://localhost:${process.env.CLIENT_PORT}`,
6+
supportFile: 'e2e/support/cypress.js',
7+
specPattern: 'e2e/test/**/*.cy.spec.js',
8+
defaultBrowser: 'chrome',
9+
},
10+
})

e2e/support/cypress.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "@testing-library/cypress/add-commands";

e2e/test/compatibility.cy.spec.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const TIMEOUT_MS = 20000;
2+
3+
describe("Embedding SDK: metabase-nodejs-react-sdk-embedding-sample compatibility", () => {
4+
it("should open an Interactive Question", () => {
5+
cy.visit({
6+
url: "/",
7+
});
8+
9+
expect(cy.findByText("Orders by product category", {timeout: TIMEOUT_MS}).should("exist"));
10+
});
11+
});

local-dist/.gitkeep

Whitespace-only changes.

metabase/Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM metabase/metabase-enterprise:v1.52.x
2+
3+
COPY ./metabase /app/
4+
COPY ./local-dist /app/local-dist
5+
6+
RUN if [ -f ./app/local-dist/metabase.jar ]; then \
7+
echo "Local metabase.jar is found in ./app/local-dist, running it..."; \
8+
cp ./app/local-dist/metabase.jar /app/metabase.jar; \
9+
else \
10+
echo "Local metabase.jar is not found in ./app/local-dist, skipping copy"; \
11+
fi

metabase/init-config.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 1
2+
config:
3+
users:
4+
- first_name: Rene
5+
last_name: Descartes
6+
password: foobarbaz
7+
8+
settings:
9+
enable-embedding-sdk: true
10+
jwt-enabled: true

0 commit comments

Comments
 (0)