Skip to content

Commit a901d61

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/linda-django' into linda-django
resolve conflicts
2 parents 8d3f4d9 + b9603bb commit a901d61

File tree

26 files changed

+542
-135
lines changed

26 files changed

+542
-135
lines changed

.github/workflows/deploy-changed-samples.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ jobs:
8181
TEST_MB_DB_PASS: ${{ secrets.TEST_MB_DB_PASS }}
8282
TEST_MB_DB_PORT: ${{ secrets.TEST_MB_DB_PORT }}
8383
TEST_MB_DB_USER: ${{ secrets.TEST_MB_DB_USER }}
84+
TEST_MONGO_INITDB_ROOT_USERNAME: ${{ secrets.TEST_MONGO_INITDB_ROOT_USERNAME }}
85+
TEST_MONGO_INITDB_ROOT_PASSWORD: ${{ secrets.TEST_MONGO_INITDB_ROOT_PASSWORD }}
8486
TEST_NC_DB: ${{ secrets.TEST_NC_DB }}
8587
TEST_NC_S3_ENDPOINT: ${{ secrets.TEST_NC_S3_ENDPOINT }}
8688
TEST_NC_S3_BUCKET_NAME: ${{ secrets.TEST_NC_S3_BUCKET_NAME }}
@@ -90,6 +92,7 @@ jobs:
9092
TEST_OPENAI_KEY: ${{ secrets.TEST_OPENAI_KEY }}
9193
TEST_POSTGRES_PASSWORD: ${{ secrets.TEST_POSTGRES_PASSWORD }}
9294
TEST_QUEUE: ${{ secrets.TEST_QUEUE }}
95+
TEST_SECRET_KEY: ${{ secrets.TEST_SECRET_KEY }}
9396
TEST_SECRET_KEY_BASE: ${{ secrets.TEST_SECRET_KEY_BASE }}
9497
TEST_SESSION_SECRET: ${{ secrets.TEST_SESSION_SECRET }}
9598
TEST_SLACK_CHANNEL_ID: ${{ secrets.TEST_SLACK_CHANNEL_ID }}

samples/fastapi-postgres/README.md

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,52 @@ This sample project demonstrates how to deploy FastAPI with PostgreSQL with Defa
99
1. Download <a href="https://github.com/defang-io/defang">Defang CLI</a>
1010
2. (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>.
1111

12-
## Deploying
12+
## Development
1313

14-
1. Open the terminal and type `defang login`
15-
2. Type `defang compose up` in the CLI.
16-
3. Your app will be running within a few minutes.
14+
To run the development container(s) locally, do:
1715

18-
## Local Development
16+
```bash
17+
docker compose -f compose.dev.yaml up --build
18+
```
1919

20-
1. Run `docker compose -f compose.dev.yaml up --build`
20+
Or to run the production container(s) locally, do:
21+
22+
```bash
23+
POSTGRES_PASSWORD=postgres docker compose up --build
24+
```
25+
26+
## Configuration
27+
28+
For this sample, you will need to provide the following [configuration](https://docs.defang.io/docs/concepts/configuration):
29+
30+
> Note that if you are using the 1-click deploy option, you can set these values as secrets in your GitHub repository and the action will automatically deploy them for you.
31+
32+
### `POSTGRES_PASSWORD`
33+
``` bash
34+
defang config set POSTGRES_PASSWORD
35+
```
36+
37+
## Deployment
38+
39+
> [!NOTE]
40+
> Download [Defang CLI](https://github.com/DefangLabs/defang)
41+
42+
### Defang Playground
43+
44+
Deploy your application to the Defang Playground by opening up your terminal and typing:
45+
```bash
46+
defang compose up
47+
```
48+
49+
### BYOC (AWS)
50+
51+
If you want to deploy to your own cloud account, you can use Defang BYOC:
52+
53+
1. [Authenticate your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html), and check that you have properly set your environment variables like `AWS_PROFILE`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`.
54+
2. Run in a terminal that has access to your AWS environment variables:
55+
```bash
56+
defang --provider=aws compose up
57+
```
2158

2259
---
2360

samples/fastapi-postgres/compose.dev.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ services:
33
extends:
44
file: compose.yaml
55
service: fastapi
6-
restart: unless-stopped
7-
ports:
8-
- "8000:8000"
96
environment:
107
- DATABASE_URL=postgres://postgres:postgres@db:5432/postgres
118
volumes:
@@ -15,8 +12,9 @@ services:
1512
command: fastapi dev main.py --host 0.0.0.0
1613

1714
db:
18-
image: postgres:15
19-
restart: unless-stopped
15+
extends:
16+
file: compose.yaml
17+
service: db
2018
environment:
2119
- POSTGRES_USER=postgres
2220
- POSTGRES_PASSWORD=postgres

samples/fastapi-postgres/compose.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,23 @@ services:
77
ports:
88
- mode: ingress
99
target: 8000
10+
published: 8000
1011
environment:
11-
- DATABASE_URL
12+
- DB_URL=postgres://postgres:${POSTGRES_PASSWORD}@db:5432/postgres
13+
depends_on:
14+
- db
1215
#deploy:
1316
# resources:
1417
# reservations:
1518
# memory: 256M
19+
20+
db:
21+
image: postgres:15
22+
restart: unless-stopped
23+
environment:
24+
- POSTGRES_USER=postgres
25+
- POSTGRES_PASSWORD
26+
- POSTGRES_DB=postgres
27+
ports:
28+
- mode: host
29+
target: 5432

samples/fastapi-postgres/fastapi/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from databases import Database
99
from dotenv import load_dotenv
1010

11-
load_dotenv()
11+
load_dotenv()
1212

13-
database_url = os.getenv("DATABASE_URL")
13+
database_url = os.getenv("DB_URL")
1414
print(f"Connecting to database at: {database_url}")
1515
database = Database(database_url)
1616

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
uwsgi
2-
fastapi
2+
fastapi[standard]
33
uvicorn
44
asyncpg
55
databases
66
python-dotenv
7+
jinja2
8+
python-multipart

samples/fastapi/README.md

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,49 @@ This sample project demonstrates how to deploy FastAPI with Defang.
66

77
## Prerequisites
88

9-
1. Download <a href="https://github.com/defang-io/defang">Defang CLI</a>
10-
2. (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>.
11-
12-
## Deploying
13-
14-
1. Open the terminal and type `defang login`
15-
2. Type `defang compose up` in the CLI.
16-
3. Your app will be running within a few minutes.
9+
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
10+
2. (Optional) If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc) authenticate with your cloud provider account
11+
3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/)
1712

1813
## Development
1914

20-
To run your FastAPI app locally, you'll need to have Docker installed on your machine. You can then run:
15+
To run the application locally, you can use the following command:
2116

2217
```bash
2318
docker compose -f compose.yaml -f compose.dev.yaml up --build
2419
```
2520

26-
That will start your FastAPI app on `http://localhost:8000` with hot reloading enabled.
21+
## Configuration
22+
23+
For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration).
24+
25+
If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`.
26+
27+
```bash
28+
defang config set API_KEY
29+
```
30+
31+
## Deployment
32+
33+
> [!NOTE]
34+
> Download [Defang CLI](https://github.com/DefangLabs/defang)
35+
36+
### Defang Playground
37+
38+
Deploy your application to the Defang Playground by opening up your terminal and typing:
39+
```bash
40+
defang compose up
41+
```
42+
43+
### BYOC (AWS)
44+
45+
If you want to deploy to your own cloud account, you can use Defang BYOC:
46+
47+
1. [Authenticate your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html), and check that you have properly set your environment variables like `AWS_PROFILE`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`.
48+
2. Run in a terminal that has access to your AWS environment variables:
49+
```bash
50+
defang --provider=aws compose up
51+
```
2752

2853
---
2954

samples/golang-http-form/README.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,51 @@
44

55
This Go application demonstrates a simple form submission using the standard net/http library. Users can input their first name into a form, and upon submission, they will be greeted personally by the application.
66

7-
## Features
7+
## Prerequisites
88

9-
1. Simple form to submit a user's first name.
10-
2. Personalized greeting displayed in response to the form submission
9+
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
10+
2. (Optional) If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc) authenticate with your cloud provider account
11+
3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/)
1112

12-
## Essential Setup Files
13+
## Development
1314

14-
1. A [Dockerfile](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/).
15-
2. A [compose file](https://docs.defang.io/docs/concepts/compose) to define and run multi-container Docker applications (this is how Defang identifies services to be deployed). (compose.yaml file)
15+
To run the application locally, you can use the following command:
1616

17-
## Prerequisite
17+
```bash
18+
docker compose up --build
19+
```
1820

19-
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
20-
2. If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc), make sure you have properly [authenticated your AWS account (optional)](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html)
21+
## Configuration
22+
23+
For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration).
24+
25+
If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`.
26+
27+
```bash
28+
defang config set API_KEY
29+
```
30+
31+
## Deployment
32+
33+
> [!NOTE]
34+
> Download [Defang CLI](https://github.com/DefangLabs/defang)
35+
36+
### Defang Playground
37+
38+
Deploy your application to the Defang Playground by opening up your terminal and typing:
39+
```bash
40+
defang compose up
41+
```
42+
43+
### BYOC (AWS)
2144

22-
## A Step-by-Step Guide
45+
If you want to deploy to your own cloud account, you can use Defang BYOC:
2346

24-
1. Open the terminal and type `defang login`
25-
2. Type `defang compose up` in the CLI
26-
3. Your app should be up and running with Defang in minutes!
47+
1. [Authenticate your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html), and check that you have properly set your environment variables like `AWS_PROFILE`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`.
48+
2. Run in a terminal that has access to your AWS environment variables:
49+
```bash
50+
defang --provider=aws compose up
51+
```
2752

2853
---
2954

samples/golang-http/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,52 @@
44

55
A very simple example of a Go service that listens on a port and returns information about the request.
66

7+
## Prerequisites
8+
9+
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
10+
2. (Optional) If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc) authenticate with your cloud provider account
11+
3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/)
12+
13+
## Development
14+
15+
To run the application locally, you can use the following command:
16+
17+
```bash
18+
docker compose up --build
19+
```
20+
21+
## Configuration
22+
23+
For this sample, you will not need to provide [configuration](https://docs.defang.io/docs/concepts/configuration).
24+
25+
If you wish to provide configuration, see below for an example of setting a configuration for a value named `API_KEY`.
26+
27+
```bash
28+
defang config set API_KEY
29+
```
30+
31+
## Deployment
32+
33+
> [!NOTE]
34+
> Download [Defang CLI](https://github.com/DefangLabs/defang)
35+
36+
### Defang Playground
37+
38+
Deploy your application to the Defang Playground by opening up your terminal and typing:
39+
```bash
40+
defang compose up
41+
```
42+
43+
### BYOC (AWS)
44+
45+
If you want to deploy to your own cloud account, you can use Defang BYOC:
46+
47+
1. [Authenticate your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html), and check that you have properly set your environment variables like `AWS_PROFILE`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`.
48+
2. Run in a terminal that has access to your AWS environment variables:
49+
```bash
50+
defang --provider=aws compose up
51+
```
52+
753
---
854

955
Title: Go HTTP Server

samples/golang-mongodb-atlas/README.md

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

0 commit comments

Comments
 (0)