Skip to content

Commit 7bc7c9f

Browse files
committed
Merge branch 'main' into 174-platformatic-sample
2 parents e7366f3 + e58c6fd commit 7bc7c9f

34 files changed

+6205
-7
lines changed

.github/workflows/check-sample.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- name: Run Checks
2222
id: checks
2323
run: |
24+
. <(curl -Ls https://s.defang.io/install)
2425
./scripts/check-sample-files.sh > checklist.txt
2526
./scripts/check-modified-samples.sh > modified.txt
2627
echo "@@ MODIFIED @@"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Browse through the [./samples](./samples) directory, or search and browse in the
66

77
## Adding Samples
88

9-
To start working on a new sample, run `. ./scripts/new-sample.sh` from the root of the repository. This will create a new sample directory, with some basic scaffolding to get you started. Look for `#REMOVE_ME_AFTER_EDITING` in your new project to look for things that you should probably be changing/checking per sample. Feel free to remove files, like `compose.dev.yaml` if they aren't necessary for your sample.
9+
To start working on a new sample, run `. ./scripts/new-sample` from the root of the repository. This will create a new sample directory, with some basic scaffolding to get you started. Look for `#REMOVE_ME_AFTER_EDITING` in your new project to look for things that you should probably be changing/checking per sample. Feel free to remove files, like `compose.dev.yaml` if they aren't necessary for your sample.

samples/flask/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This sample is a simple Flask app that demonstrates how to create a TODO app usi
3131

3232
Title: Flask
3333

34-
Short Description: A basic Flask to o app.
34+
Short Description: A basic Flask to do app.
3535

3636
Tags: Flask, Python
3737

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM mcr.microsoft.com/devcontainers/typescript-node:22-bookworm
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"build": {
3+
"dockerfile": "Dockerfile",
4+
"context": ".."
5+
},
6+
"features": {
7+
"ghcr.io/defanglabs/devcontainer-feature/defang-cli:1.0.4": {},
8+
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
9+
}
10+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
15+
steps:
16+
- name: Checkout Repo
17+
uses: actions/checkout@v4
18+
19+
- name: Deploy
20+
uses: DefangLabs/[email protected]
21+
with:
22+
config-env-vars: POSTGRES_PASSWORD
23+
env:
24+
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}

samples/nextjs-postgres/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Next.js & Postgres
2+
3+
[1-click deploy](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-nextjs-postgres-template%26template_owner%3DDefangSamples)
4+
5+
This is a sample Next.js application that uses Postgres as a database. It is a simple example that demonstrates how to connect to a Postgres database from a Next.js application: on each request it takes the user's IP address, geo-locates it, and stores the result in the database, then displays the last 20 results on the home page.
6+
7+
## Prerequisites
8+
9+
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
10+
2. (Optional) If you are using [Defang BYOC](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) authenticated with your AWS 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 -f compose.dev.yaml up
19+
```
20+
21+
## Configuration
22+
23+
For this sample, you will need to provide the following [configuration](https://docs.defang.io/docs/concepts/configuration). 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.
24+
25+
### `POSTGRES_PASSWORD`
26+
A password that will be used to connect to the Postgres database.
27+
28+
29+
## Deploying
30+
31+
1. Open the terminal and type `defang login`
32+
2. Use the [`defang config`](https://docs.defang.io/docs/concepts/compose#configuration) command to setup environment variables.
33+
3. Type `defang compose up` in the CLI.
34+
4. Your app will be running within a few minutes.
35+
36+
---
37+
38+
Title: Next.js & Postgres
39+
40+
Short Description: A sample Next.js application that uses Postgres as a database.
41+
42+
Tags: Next.js, Postgres, Database, Node.js
43+
44+
Languages: TypeScript, JavaScript
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Ignore node_modules and npm debug log
2+
node_modules
3+
npm-debug.log
4+
5+
# Ignore build output
6+
.next
7+
out
8+
9+
# Ignore local environment variables
10+
.env
11+
.env.local
12+
.env.development.local
13+
.env.test.local
14+
.env.production.local
15+
16+
# Ignore logs
17+
logs
18+
*.log
19+
20+
# Ignore OS-specific files
21+
.DS_Store
22+
Thumbs.db
23+
24+
# Ignore editor directories and files
25+
.vscode
26+
.idea
27+
*.suo
28+
*.ntvs*
29+
*.njsproj
30+
*.sln
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["next/core-web-vitals", "next/typescript"]
3+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
.yarn/install-state.gz
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts

0 commit comments

Comments
 (0)