-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from DefangLabs/setup-samples
Reorg samples
- Loading branch information
Showing
582 changed files
with
1,278 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# HTTP Echo Server | ||
|
||
A very simple example of a Go service that listens on a port and returns information about the request. | ||
|
||
--- | ||
|
||
Title: Go HTTP Server | ||
|
||
Short Description: A simple Go application that echoes back the request | ||
|
||
Tags: go, http | ||
|
||
Languages: go |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 11 additions & 1 deletion
12
...es/golang/Fetch and Return JSON/README.md → samples/golang-rest-api/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
# Go HTTP Server with Fiscal Data API | ||
|
||
This is a simple HTTP server written in Go that serves two endpoints: / and /rates. The / endpoint responds with a JSON object containing the status, while the /rates endpoint fetches data from the Fiscal Data Treasury API and returns the response to the client. | ||
This is a simple HTTP server written in Go that serves two endpoints: / and /rates. The / endpoint responds with a JSON object containing the status, while the /rates endpoint fetches data from the Fiscal Data Treasury API and returns the response to the client. | ||
|
||
--- | ||
|
||
Title: Go + REST API | ||
|
||
Short Description: A simple Go application that fetches fiscal data from an API | ||
|
||
Tags: go, http, fiscal data, api, rest | ||
|
||
Languages: go |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Metabase + Postgres | ||
|
||
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. | ||
|
||
|
||
## Prerequisites | ||
1. Download <a href="https://github.com/defang-io/defang">Defang CLI</a> | ||
2. Have a managed database service configured and have the connection details ready. | ||
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>. | ||
|
||
## Local | ||
|
||
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. | ||
|
||
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`. | ||
|
||
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. | ||
|
||
## Deploying | ||
|
||
1. Open the terminal and type `defang login` | ||
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. | ||
3. Type `defang compose up` in the CLI. | ||
4. Your app will be running within a few minutes. | ||
|
||
--- | ||
|
||
Title: Metabase + Postgres | ||
|
||
Short Description: A simple metabase configuration with a Postgres database | ||
|
||
Tags: metabase, postgres, analytics, database | ||
|
||
Languages: sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
version: '3.9' | ||
services: | ||
metabase: | ||
environment: | ||
- MB_DB_TYPE=postgres | ||
- MB_DB_DBNAME=metabase | ||
- MB_DB_PORT=5432 | ||
- MB_DB_USER=metabase | ||
- MB_DB_PASS=metabase | ||
- MB_DB_HOST=postgres | ||
depends_on: | ||
postgres: | ||
condition: service_healthy | ||
|
||
postgres: | ||
image: "postgres:latest" | ||
environment: | ||
POSTGRES_DB: metabase | ||
POSTGRES_USER: metabase | ||
POSTGRES_PASSWORD: metabase | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data | ||
healthcheck: | ||
test: ["CMD", "pg_isready", "-U", "metabase"] | ||
interval: 10s | ||
timeout: 10s | ||
retries: 10 | ||
deploy: | ||
resources: | ||
reservations: | ||
cpus: "0.5" | ||
memory: 1024M | ||
|
||
volumes: | ||
postgres_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
version: '3.9' | ||
name: metabase | ||
services: | ||
metabase: | ||
image: "metabase/metabase:latest" | ||
ports: | ||
- mode: ingress | ||
target: 3000 | ||
published: 3000 | ||
healthcheck: | ||
test: ["CMD", "curl", "-f", "http://localhost:3000/api/health" ] | ||
interval: 1m30s | ||
timeout: 30s | ||
retries: 5 | ||
environment: | ||
- MB_DB_TYPE=postgres | ||
- MB_DB_DBNAME | ||
- MB_DB_PORT | ||
- MB_DB_USER | ||
- MB_DB_PASS | ||
- MB_DB_HOST | ||
deploy: | ||
resources: | ||
reservations: | ||
cpus: "0.5" | ||
memory: 1024M |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.