Skip to content

Commit d3638e8

Browse files
authored
Optimize docker configs (#26)
1 parent 09966b3 commit d3638e8

File tree

8 files changed

+42
-25
lines changed

8 files changed

+42
-25
lines changed

.dockerignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.idea
2-
node_modules
3-
docker-compose.*
1+
**/.idea
2+
**/node_modules
3+
**/docker-compose.*
44
.dockerignore

.github/workflows/e2e-tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ jobs:
2828
- name: Run Sample App in Docker
2929
run: |
3030
cp .env.docker.example .env.docker &&
31-
npm run docker:up -- -d &&
32-
while ! nc -z localhost 4400; do sleep 1; done
31+
npm run docker:e2e:up -- --wait
3332
3433
- name: Install Chrome v111
3534
uses: browser-actions/setup-chrome@v1

docker-compose.local-dist.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
services:
2+
metabase:
3+
volumes:
4+
- type: bind
5+
source: ./local-dist/metabase.jar
6+
target: /app/metabase.jar
7+
read_only: true
8+
bind:
9+
create_host_path: false

docker-compose.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
services:
22
metabase:
3-
build:
4-
context: .
5-
dockerfile: metabase/Dockerfile
3+
image: metabase/metabase-enterprise:v1.55.x
64
environment:
7-
MB_CONFIG_FILE_PATH: "./app/init-config.yml"
5+
MB_CONFIG_FILE_PATH: "./app/config.yml"
86
MB_JETTY_PORT: "${MB_PORT}"
97
MB_EDITION: "ee"
108
MB_SITE_URL: "http://localhost:${MB_PORT}/"
@@ -19,6 +17,8 @@ services:
1917
retries: 10
2018
ports:
2119
- "${MB_PORT}:${MB_PORT}"
20+
volumes:
21+
- ./metabase/config.yml:/app/config.yml
2222

2323
next-sample-app-router:
2424
depends_on:
@@ -38,6 +38,11 @@ services:
3838
NEXT_PUBLIC_METABASE_INSTANCE_URL: "http://localhost:${MB_PORT}"
3939
METABASE_INSTANCE_URL: "http://metabase:${MB_PORT}"
4040
METABASE_JWT_SHARED_SECRET: "${METABASE_JWT_SHARED_SECRET}"
41+
healthcheck:
42+
test: curl --fail -X GET -I "http://localhost:${CLIENT_PORT_APP_ROUTER}/" || exit 1
43+
interval: 2s
44+
timeout: 2s
45+
retries: 5
4146
ports:
4247
- "${CLIENT_PORT_APP_ROUTER}:${CLIENT_PORT_APP_ROUTER}"
4348
volumes:
@@ -51,7 +56,7 @@ services:
5156
context: .
5257
dockerfile: ./next-sample-pages-router/Dockerfile
5358
args:
54-
PORT: "${CLIENT_PORT_APP_ROUTER}"
59+
PORT: "${CLIENT_PORT_PAGES_ROUTER}"
5560
NEXT_PUBLIC_METABASE_INSTANCE_URL: "http://localhost:${MB_PORT}"
5661
METABASE_INSTANCE_URL: "http://metabase:${MB_PORT}"
5762
METABASE_JWT_SHARED_SECRET: "${METABASE_JWT_SHARED_SECRET}"
@@ -61,6 +66,11 @@ services:
6166
NEXT_PUBLIC_METABASE_INSTANCE_URL: "http://localhost:${MB_PORT}"
6267
METABASE_INSTANCE_URL: "http://metabase:${MB_PORT}"
6368
METABASE_JWT_SHARED_SECRET: "${METABASE_JWT_SHARED_SECRET}"
69+
healthcheck:
70+
test: curl --fail -X GET -I "http://localhost:${CLIENT_PORT_PAGES_ROUTER}/" || exit 1
71+
interval: 2s
72+
timeout: 2s
73+
retries: 5
6474
ports:
6575
- "${CLIENT_PORT_PAGES_ROUTER}:${CLIENT_PORT_PAGES_ROUTER}"
6676
volumes:

metabase/Dockerfile

Lines changed: 0 additions & 11 deletions
This file was deleted.
File renamed without changes.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"scripts": {
66
"start": "npm run docker:up",
77
"docker:up": "docker compose --env-file .env.docker up",
8-
"docker:down": "docker compose --env-file .env.docker down --rmi all --volumes"
8+
"docker:e2e:up": "yarn docker:up",
9+
"docker:local-dist:up": "docker compose -f docker-compose.yml -f docker-compose.local-dist.yml --env-file .env.docker up",
10+
"docker:down": "docker compose --env-file .env.docker down",
11+
"docker:rm": "yarn docker:down --rmi all --volumes"
912
}
1013
}

readme.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,21 @@ This option should be used if you don't want to test Metabase Embedding SDK with
3131

3232
From the root directory:
3333
- Copy `.env.docker.example` to `.env.docker` and replace `<your_enterprise_token>` with your premium embedding token
34-
- Start all services in Docker with `yarn start`
34+
- Start all services in Docker with `yarn docker:up`
3535

3636
It will:
37-
- poll a Metabase image and run it
38-
- build and run both `next-sample-app-router` and `next-sample-pages-router` apps
37+
- Poll a Metabase image and run it
38+
- Build and run containers with both `next-sample-app-router` and `next-sample-pages-router` apps and run it
3939

4040
The pages router sample will start on port 4401 and the app router sample will start on port 4400.
4141

42+
#### Local development (For Metabase developers)
43+
44+
- To run containers with a locally built `metabase.jar`, copy it to the `./local-dist` folder as `./local-dist/metabase.jar`.
45+
- To run containers with a locally built Embedding SDK package, copy it to the `./local-dist` folder as `./local-dist/embedding-sdk`.
46+
- Run `yarn docker:local-dist:up` to start containers and use locally built dist from the `./local-dist` folder.
47+
- To remove containers and images completely run `yarn docker:rm`.
48+
4249
## Authentication
4350

4451
Both apps provide an endpoint for user authentication, replace the logic to match your authentication system.

0 commit comments

Comments
 (0)