Skip to content

Commit ab5be99

Browse files
committed
Merge branch 'main' into 18-nocodb-sample
2 parents c792333 + 85da770 commit ab5be99

File tree

137 files changed

+1999
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+1999
-155
lines changed

.github/workflows/check-sample.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ jobs:
2626
echo "@@ MODIFIED @@"
2727
cat modified.txt
2828
29-
- name: Validate Compose Files with Defang CLI
30-
run: |
31-
. <(curl -Ls https://s.defang.io/install)
32-
cat modified.txt | xargs -n1 defang compose config -C > /dev/null
29+
# TODO: Uncomment the following lines to validate the Compose files
30+
# once we figure out how to prevent it from erroring on warnings.
31+
# - name: Validate Compose Files with Defang CLI
32+
# run: |
33+
# . <(curl -Ls https://s.defang.io/install)
34+
# cat modified.txt | xargs -n1 defang compose config -C > /dev/null
3335

3436
- name: Add checklist to PR description
3537
uses: actions/github-script@v5

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Defang Samples
22

3-
Samples to show you how to create and deploy apps with Defang.
3+
Samples to show you how to develop, deploy, and debug cloud applications with Defang.
44

55
Browse through the [./samples](./samples) directory, or search and browse in the [docs](https://docs.defang.io/docs/samples).
6+
7+
## Adding Samples
8+
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.

samples/angular-express/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ Title: Angular & Node.js
3737

3838
Short Description: A full-stack application using Angular for the frontend and Node.js with Socket.IO for the backend, containerized with Docker.
3939

40-
Tags: angular, nodejs, Socket.IO
40+
Tags: Angular, Node.js, Socket.IO, TypeScript, JavaScript
4141

42-
Languages: typescript, javascript
42+
Languages: nodejs

samples/bullmq-bullboard-redis/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ To add a job to the queue, you can go to the `/add` route of the `api` service.
88

99
The `worker` service is the queue processor that will process the jobs added to the queue. You can see in the `compose.yaml` file that the `worker` service is set to scale to 2 instances. This means that there will be 2 workers processing jobs from the queue. You can set this to your desired number of workers, but we wanted to show how you can increase the number of workers to handle more jobs.
1010

11-
1211
## Prerequisites
1312

1413
1. Download <a href="https://github.com/defang-io/defang">Defang CLI</a>
@@ -21,7 +20,6 @@ The `worker` service is the queue processor that will process the jobs added to
2120
3. Type `defang compose up` in the CLI.
2221
4. Your app will be running within a few minutes.
2322

24-
2523
## Local Development
2624

2725
1. Run `docker compose -f compose.dev.yaml up`
@@ -32,6 +30,6 @@ Title: BullMQ & BullBoard & Redis
3230

3331
Short Description: A sample project with BullMQ, BullBoard, and Redis.
3432

35-
Tags: BullMQ, BullBoard, Redis, Express, Node.js, Message Queue
33+
Tags: BullMQ, BullBoard, Redis, Express, Node.js, Message Queue, JavaScript
3634

37-
Languages: nodejs, javascript
35+
Languages: nodejs

samples/bullmq-bullboard-redis/compose.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ services:
1414
- QUEUE
1515
depends_on:
1616
- redis
17+
#deploy:
18+
# resources:
19+
# reservations:
20+
# memory: 256M
1721

1822
api:
1923
restart: unless-stopped
@@ -29,6 +33,10 @@ services:
2933
- QUEUE
3034
depends_on:
3135
- redis
36+
#deploy:
37+
# resources:
38+
# reservations:
39+
# memory: 256M
3240

3341
worker:
3442
restart: unless-stopped
@@ -44,6 +52,10 @@ services:
4452
test: ["CMD", "wget", "-q", "--spider", "127.0.0.1:3000"]
4553
depends_on:
4654
- redis
55+
#deploy:
56+
# resources:
57+
# reservations:
58+
# memory: 256M
4759

4860
redisx:
4961
image: redis:6.2

samples/csharp-dotnet/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# ASP.NET Core & JavaScript Task Manager
2+
3+
This project is a simple task manager application using ASP.NET Core for the backend and JavaScript for client-side component rendering. We show case how to deploy it to both defang and docker for both prod and dev environments.
4+
5+
## NOTE
6+
7+
This sample showcases how you could deploy a full-stack application with ASP.NET Core and JavaScript using Defang. The Docker setup ensures the app can be easily built and tested during development.
8+
9+
## Essential Setup Files
10+
11+
1. Download [Defang CLI](https://github.com/defang-io/defang)
12+
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
13+
3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/)
14+
15+
## Prerequisites
16+
17+
1. Download [Defang CLI](https://github.com/defang-io/defang)
18+
2. (Optional) If you are using [Defang BYOC](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) make sure you have properly authenticated your AWS account
19+
3. [ASP.NET Core](https://dotnet.microsoft.com/download/dotnet-core)
20+
21+
## A Step-by-Step Guide for deployment
22+
23+
1. Open the terminal and type `defang login`
24+
2. Type `defang compose up` in the CLI
25+
3. Your app should be up and running with Defang in minutes!
26+
27+
## Development
28+
29+
For development, we use two local containers, one for the frontend service and one for the backend service in ASP.NET Core. It also uses Caddy as a web server for serving static files. To run the sample locally after cloning the repository, you can run on Docker by doing:
30+
31+
`docker compose -f compose.dev.yaml up`
32+
33+
---
34+
35+
Title: ASP.NET Core & JavaScript Task Manager
36+
37+
Short Description: A task manager using ASP.NET Core for the backend and JavaScript for the frontend, containerized with Docker.
38+
39+
Tags: ASP.NET Core, JavaScript, C#
40+
41+
Languages: C#, JavaScript
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bin/
2+
obj/
3+
.vs/
4+
.vscode/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin/
2+
obj/
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use the official .NET SDK image for building the application
2+
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
3+
WORKDIR /app
4+
5+
# Copy csproj and restore as distinct layers
6+
COPY *.csproj ./
7+
RUN dotnet restore
8+
9+
# Copy everything else and build
10+
COPY . ./
11+
RUN dotnet publish -c Release -o out
12+
13+
# Use the official .NET runtime image for running the application
14+
FROM mcr.microsoft.com/dotnet/aspnet:7.0
15+
WORKDIR /app
16+
COPY --from=build-env /app/out .
17+
18+
# Expose port 80
19+
EXPOSE 80
20+
21+
# Start the application
22+
ENTRYPOINT ["dotnet", "csharp-dotnet.dll"]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@page
2+
@model csharp_dotnet.Pages.IndexModel
3+
@{
4+
ViewData["Title"] = "Task Manager";
5+
}
6+
7+
<div class="text-center">
8+
<h1 class="display-4">Task Manager</h1>
9+
<input type="text" id="taskInput" placeholder="Add a new task" />
10+
<button onclick="addTask()">Add Task</button>
11+
<ul id="taskList"></ul>
12+
</div>
13+
14+
<script>
15+
let tasks = [];
16+
17+
function addTask() {
18+
const taskInput = document.getElementById('taskInput');
19+
const task = taskInput.value.trim();
20+
if (task) {
21+
tasks.push(task);
22+
taskInput.value = '';
23+
renderTasks();
24+
}
25+
}
26+
27+
function removeTask(index) {
28+
tasks.splice(index, 1);
29+
renderTasks();
30+
}
31+
32+
function renderTasks() {
33+
const taskList = document.getElementById('taskList');
34+
taskList.innerHTML = '';
35+
tasks.forEach((task, index) => {
36+
const li = document.createElement('li');
37+
li.textContent = task + ' ';
38+
const removeButton = document.createElement('button');
39+
removeButton.textContent = 'Remove';
40+
removeButton.onclick = () => removeTask(index);
41+
li.appendChild(removeButton);
42+
taskList.appendChild(li);
43+
});
44+
}
45+
</script>

0 commit comments

Comments
 (0)