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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 19 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 52 additions & 0 deletions
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

Lines changed: 10 additions & 0 deletions
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+
})

0 commit comments

Comments
 (0)