Skip to content

Commit

Permalink
Merge branch 'jordan/rails' of github.com:DefangLabs/samples into jor…
Browse files Browse the repository at this point in the history
…dan/rails
  • Loading branch information
raphaeltm committed Sep 19, 2024
2 parents b349051 + 29796be commit 3f1e625
Show file tree
Hide file tree
Showing 127 changed files with 3,624 additions and 1,111 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check-sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- name: Run Checks
id: checks
run: |
. <(curl -Ls https://s.defang.io/install)
./scripts/check-sample-files.sh > checklist.txt
./scripts/check-modified-samples.sh > modified.txt
echo "@@ MODIFIED @@"
Expand Down
1 change: 0 additions & 1 deletion samples/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion samples/angular-express/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
6 changes: 3 additions & 3 deletions samples/bullmq-bullboard-redis/compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ services:
- QUEUE=testqueue
command: npx nodemon index.mjs

redis:
redisx:
extends:
file: compose.yaml
service: redis

service: redisx

2 changes: 1 addition & 1 deletion samples/csharp-dotnet/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/django-postgres/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/django-postgres/app/crm_platform/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
ALLOWED_HOSTS = ['*']

CSRF_TRUSTED_ORIGINS = [
'https://*.prod1.defang.dev',
'https://*.defang.dev',
'http://localhost:8000',
]

Expand Down
2 changes: 1 addition & 1 deletion samples/django/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
4 changes: 2 additions & 2 deletions samples/django/app/defang_sample/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@

# CSRF
CSRF_TRUSTED_ORIGINS = [
'https://*.prod1.defang.dev'
'https://*.defang.dev'
]

if DEBUG:
CSRF_TRUSTED_ORIGINS = [
'http://localhost:8000',
]
]
2 changes: 1 addition & 1 deletion samples/elysia/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/fastapi-postgres/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/fastapi/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/feathersjs/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/flask/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/golang-http-form/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/golang-http/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/golang-mongodb-atlas/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/golang-openai/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/golang-rest-api/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/golang-s3/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/golang-slackbot/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/hasura/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/huginn/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/imgproxy/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/javalin/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/langchain/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/metabase/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/nextjs-blog/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/nextjs-boilerplate/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
2 changes: 1 addition & 1 deletion samples/nextjs-documentation/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/defang-github-action@v1.0.4
uses: DefangLabs/defang-github-action@v1.1.0
22 changes: 0 additions & 22 deletions samples/nextjs-github-actions/README.md

This file was deleted.

15 changes: 0 additions & 15 deletions samples/nextjs-github-actions/compose.yaml

This file was deleted.

1 change: 1 addition & 0 deletions samples/nextjs-postgres/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM mcr.microsoft.com/devcontainers/typescript-node:22-bookworm
10 changes: 10 additions & 0 deletions samples/nextjs-postgres/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"features": {
"ghcr.io/defanglabs/devcontainer-feature/defang-cli:1.0.4": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
}
}
24 changes: 24 additions & 0 deletions samples/nextjs-postgres/.github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Deploy

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Deploy
uses: DefangLabs/[email protected]
with:
config-env-vars: POSTGRES_PASSWORD
env:
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
44 changes: 44 additions & 0 deletions samples/nextjs-postgres/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Next.js & Postgres

[![1-click-deploy](https://defang.io/deploy-with-defang.png)](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-nextjs-postgres-template%26template_owner%3DDefangSamples)

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.

## Prerequisites

1. Download [Defang CLI](https://github.com/DefangLabs/defang)
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
3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/)

## Development

To run the application locally, you can use the following command:

```bash
docker compose -f compose.dev.yaml up
```

## Configuration

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.

### `POSTGRES_PASSWORD`
A password that will be used to connect to the Postgres database.


## Deploying

1. Open the terminal and type `defang login`
2. Use the [`defang config`](https://docs.defang.io/docs/concepts/compose#configuration) command to setup environment variables.
3. Type `defang compose up` in the CLI.
4. Your app will be running within a few minutes.

---

Title: Next.js & Postgres

Short Description: A sample Next.js application that uses Postgres as a database.

Tags: Next.js, Postgres, Database, Node.js

Languages: TypeScript, JavaScript
Loading

0 comments on commit 3f1e625

Please sign in to comment.