Skip to content

Commit 0cc7c35

Browse files
committed
add readme
1 parent 1dc7eaf commit 0cc7c35

File tree

4 files changed

+83
-43
lines changed

4 files changed

+83
-43
lines changed

samples/other/metabase/README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
1-
# Deploy Metabase with Defang
1+
# Metabase + Postgres
22

3-
This is a simple example of how to deploy Metabase with Defang.
3+
Metabase is a simple and powerful analytics tool which lets anyone learn and make decisions from their company’s data. This sample demonstrates how to deploy Metabase with Defang. In development, we run a postgres container and in production, we use a managed postgres service. To build the sample, we used Neon, because of their simplicity and generous free tier.
44

5-
Note that this is a very simple example and should not be used in production. If you want to run a basic production setup, you need a database (e.g. PostgreSQL). You can set the `MB_DB_CONNECTION_URI` secret using `defang secret set --name MB_DB_CONNECTION_URI` and uncomment the `secrets` section of the `docker-compose.yml` file.
5+
6+
## Prerequisites
7+
1. Download <a href="https://github.com/defang-io/defang">Defang CLI</a>
8+
2. Have a managed database service configured and have the connection details ready.
9+
3. (optional) If you are using <a href="https://docs.defang.io/docs/concepts/defang-byoc">Defang BYOC</a>, make sure you have properly <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html">authenticated your AWS account</a>.
10+
11+
## Local
12+
13+
For development, we use a Postgres container. The Postgres container is defined in the `compose.dev.yml` file. The Metabase container is defined in the `compose.yml` file, with some overrides in the `compose.dev.yml` file so it can correctly connect to the development database container.
14+
15+
To start the development environment, run `docker compose -f ./compose.yml -f ./compose.dev.yml up`. This will start the Postgres container and the Metabase container. Metabase will be available at `http://localhost:3000`.
16+
17+
Since Metabase is a self contained application, there isn't an actual development process, but you can use the development environment to see how Metabase works.
18+
19+
## Deploying
20+
21+
1. Open the terminal and type `defang login`
22+
2. Add your database connection details using `defang config` by typing `defang config set <CONFIG_VAL>` where `<CONFIG_VAL>` is the each of the following `MB_DB_DBNAME`, `MB_DB_HOST`, `MB_DB_PORT`, `MB_DB_USER`, `MB_DB_PASS` (to set the database name, host, port, user, and password respectively). For example `defang config set MB_DB_DBNAME` and pasting your database name.
23+
3. Type `defang compose up` in the CLI.
24+
4. Your app will be running within a few minutes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: '3.9'
2+
services:
3+
metabase:
4+
environment:
5+
- MB_DB_TYPE=postgres
6+
- MB_DB_DBNAME=metabase
7+
- MB_DB_PORT=5432
8+
- MB_DB_USER=metabase
9+
- MB_DB_PASS=metabase
10+
- MB_DB_HOST=postgres
11+
depends_on:
12+
postgres:
13+
condition: service_healthy
14+
15+
postgres:
16+
image: "postgres:latest"
17+
environment:
18+
POSTGRES_DB: metabase
19+
POSTGRES_USER: metabase
20+
POSTGRES_PASSWORD: metabase
21+
volumes:
22+
- postgres_data:/var/lib/postgresql/data
23+
healthcheck:
24+
test: ["CMD", "pg_isready", "-U", "metabase"]
25+
interval: 10s
26+
timeout: 10s
27+
retries: 10
28+
deploy:
29+
resources:
30+
reservations:
31+
cpus: "0.5"
32+
memory: 1024M
33+
34+
volumes:
35+
postgres_data:

samples/other/metabase/compose.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '3.9'
2+
name: metabase
3+
services:
4+
metabase:
5+
image: "metabase/metabase:latest"
6+
ports:
7+
- mode: ingress
8+
target: 3000
9+
published: 3000
10+
healthcheck:
11+
test: ["CMD", "curl", "-f", "http://localhost:3000/api/health" ]
12+
interval: 1m30s
13+
timeout: 30s
14+
retries: 5
15+
environment:
16+
- MB_DB_TYPE="postgres"
17+
- MB_DB_DBNAME
18+
- MB_DB_PORT
19+
- MB_DB_USER
20+
- MB_DB_PASS
21+
- MB_DB_HOST
22+
deploy:
23+
resources:
24+
reservations:
25+
cpus: "0.5"
26+
memory: 1024M

samples/other/metabase/docker-compose.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)