Skip to content

Commit 427f749

Browse files
authored
feat(containers): add vpc mongodb example (#114)
* feat(containers): add vpc mongodb example * fix: missing trademark
1 parent 8514601 commit 427f749

File tree

10 files changed

+476
-20
lines changed

10 files changed

+476
-20
lines changed

README.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Table of Contents:
3030
<!-- markdownlint-disable MD033 -->
3131

3232
| Example | Runtime | Deployment |
33-
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ---------------------- |
33+
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|------------------------|
3434
| **[Badge PHP](functions/badge-php/README.md)** <br/> A PHP function to generate repository badges. | php82 | [Serverless Framework] |
3535
| **[CORS Go](functions/cors-go/README.md)** <br/> A Go function which allows CORS requests. | go122 | [Serverless Framework] |
3636
| **[CORS Node](functions/cors-node/README.md)** <br/> A Node function which allows CORS requests. | node18 | [Serverless Framework] |
@@ -66,27 +66,28 @@ Table of Contents:
6666

6767
### 📦 Containers
6868

69-
| Example | Language | Deployment |
70-
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ---------------------- |
71-
| **[Container Bash Script](containers/bash-scheduled-job/README.md)** <br/> A Bash script runnning on a schedule using serverless containers. | Bash | [Serverless Framework] |
72-
| **[Function Handler Java](containers/function-handler-java/README.md)** <br/> A Java function handler deployed on CaaS. | Java | [Serverless Framework] |
73-
| **[NGINX CORS Private](containers/nginx-cors-private-python/README.md)** <br/> An NGINX proxy to allow CORS requests to a private container. | Python Flask | [Terraform] |
74-
| **[NGINX hello world](containers/nginx-hello-world/README.md)** <br/> A minimal example running the base NGINX image in a serverless container. | N/A | [Serverless Framework] |
75-
| **[Python hello world](containers/python-hello-world/README.md)** <br/> A minimal example running a Flask HTTP server in a serverless container. | Python | [Serverless Framework] |
76-
| **[Python S3 upload](containers/python-s3-upload/README.md)** <br/> A Python + Flask HTTP server that receives file uploads and writes them to S3. | Python | [Terraform] |
77-
| **[Terraform NGINX hello world](containers/terraform-nginx-hello-world/README.md)** <br/> A minimal example running the base NGINX image in a serverless container deployed with Terraform. | N/A | [Terraform] |
78-
| **[Triggers with Terraform](containers/terraform-triggers/README.md)** <br/> Configuring two SQS triggers, used to trigger two containers, one public, one private. | N/A | [Terraform] |
79-
| **[gRPC HTTP2 in Go](containers/grpc-http2-go/README.md)** <br/> A Go gRPC Container using http2 | Go/Protobuf | [CLI] |
80-
| **[Rust hello world](containers/rust-hello-world)** <br/> A simple Rust hello world Container | Rust | [CLI] |
81-
| **[.NET C#](containers/csharp-hello-world)** <br/> A .NET C# Container hello world | C# .NET | [CLI] |
82-
| **[Ruby Hello World](containers/ruby-hello-world/)** <br/> A simple Ruby Hello world Container | Ruby | [CLI] |
83-
| **[Deploy Memos app](containers/memos-terraform/)** <br/> A journaling application with its database deployed with Terraform | Terraform | [Terraform] |
84-
| **[Metabase on VPC](containers/vpc-metabase/README.md)** <br/> A Metabase instance running in a private network with a PostgreSQL database. | N/A | [Terraform] |
69+
| Example | Language | Deployment |
70+
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|------------------------|
71+
| **[Container Bash Script](containers/bash-scheduled-job/README.md)** <br/> A Bash script runnning on a schedule using serverless containers. | Bash | [Serverless Framework] |
72+
| **[Function Handler Java](containers/function-handler-java/README.md)** <br/> A Java function handler deployed on CaaS. | Java | [Serverless Framework] |
73+
| **[NGINX CORS Private](containers/nginx-cors-private-python/README.md)** <br/> An NGINX proxy to allow CORS requests to a private container. | Python Flask | [Terraform] |
74+
| **[NGINX hello world](containers/nginx-hello-world/README.md)** <br/> A minimal example running the base NGINX image in a serverless container. | N/A | [Serverless Framework] |
75+
| **[Python hello world](containers/python-hello-world/README.md)** <br/> A minimal example running a Flask HTTP server in a serverless container. | Python | [Serverless Framework] |
76+
| **[Python S3 upload](containers/python-s3-upload/README.md)** <br/> A Python + Flask HTTP server that receives file uploads and writes them to S3. | Python | [Terraform] |
77+
| **[Terraform NGINX hello world](containers/terraform-nginx-hello-world/README.md)** <br/> A minimal example running the base NGINX image in a serverless container deployed with Terraform. | N/A | [Terraform] |
78+
| **[Triggers with Terraform](containers/terraform-triggers/README.md)** <br/> Configuring two SQS triggers, used to trigger two containers, one public, one private. | N/A | [Terraform] |
79+
| **[gRPC HTTP2 in Go](containers/grpc-http2-go/README.md)** <br/> A Go gRPC Container using http2 | Go/Protobuf | [CLI] |
80+
| **[Rust hello world](containers/rust-hello-world)** <br/> A simple Rust hello world Container | Rust | [CLI] |
81+
| **[.NET C#](containers/csharp-hello-world)** <br/> A .NET C# Container hello world | C# .NET | [CLI] |
82+
| **[Ruby Hello World](containers/ruby-hello-world/)** <br/> A simple Ruby Hello world Container | Ruby | [CLI] |
83+
| **[Deploy Memos app](containers/memos-terraform/)** <br/> A journaling application with its database deployed with Terraform | Terraform | [Terraform] |
84+
| **[Metabase on VPC](containers/vpc-metabase/README.md)** <br/> A Metabase instance running in a private network with a PostgreSQL database. | N/A | [Terraform] |
85+
| **[MongoDB® on VPC](containers/vpc-mongodb/README.md)** <br/> A MongoDB® instance running in a private network with a sample application connecting to it. | TypeScript on Deno | [Terraform] |
8586

8687
### ⚙️ Jobs
8788

8889
| Example | Language | Deployment |
89-
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------------------------- |
90+
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|-----------------------------|
9091
| **[Serverless Jobs Hello World](jobs/terraform-hello-world/README.md)** <br/> An example of building a container image and running it as a Serverless Job using Terraform. | N/A | [Terraform]-[Console] |
9192
| **[Serverless MLOps](jobs/ml-ops/README.md)** <br/> An example of running a Serverless Machine Leaning workflow. | Python | [Terraform]-[Console]-[CLI] |
9293
| **[Auto Snapshot Instances](jobs/instances-snapshot/README.md)** <br/> Use Serverless Jobs to create snapshots of your instances | Go | [Console] |
@@ -97,15 +98,15 @@ Table of Contents:
9798
### 💬 Messaging and Queueing
9899

99100
| Example | Services | Language | Deployment |
100-
| ------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------- | -------- | ----------- |
101+
|--------------------------------------------------------------------------------------------------------------------------------------------------------|------------------|----------|-------------|
101102
| **[Manage large message](mnq/large-messages/README.md)** <br/> An example of infrastructure to manage large messages. | PaaS & S3 | Python | [Terraform] |
102103
| **[Serverless scraping](mnq/serverless-scraping/README.md)** <br/> An example of infrastructure to scrape the hackernews website. | PaaS & RDB | Python | [Terraform] |
103104
| **[SNS Instances Notification System](mnq/sns-instances-notification-system/README.md)** <br/> An example of infrastructure to use SNS with Instances. | PaaS & Instances | Golang | [Terraform] |
104105

105106
### 💜 Projects
106107

107108
| Example | Services | Language | Deployment |
108-
| ----------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -------- | ---------------------- |
109+
|-------------------------------------------------------------------------------------------------------------------------------------------|-------------|----------|------------------------|
109110
| **[Kong API Gateway](projects/kong-api-gateway/README.md)** <br/> Deploying a Kong Gateway on containers to provide routing to functions. | CaaS & FaaS | Python | [Serverless Framework] |
110111
| **[Serverless Gateway](https://github.com/scaleway/serverless-gateway)** <br/> Our serverless gateway for functions and containers. | API Gateway | Python | [Python API Framework] |
111112
| **[Monitoring Glaciers](projects/blogpost-glacier/README.md)** <br/> A project to monitor glaciers and the impact of global warming. | S3 & RDB | Golang | [Serverless Framework] |

containers/vpc-mongodb/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Serverless Containers with Scaleway Managed MongoDB®
2+
3+
A simple Deno application demonstrating how to connect to a Scaleway Managed MongoDB® instance using Mongoose. It relies on Scaleway's Private Networks for secure communication.
4+
5+
## Deploying
6+
7+
### Prerequisites
8+
9+
This Terraform pushes a Docker image to a Scaleway Container Registry before deploying the Serverless Container.
10+
11+
Make sure to log in to the Scaleway Container Registry beforehand:
12+
13+
```bash
14+
scw registry login
15+
```
16+
17+
### Deploy with Terraform
18+
19+
```bash
20+
terraform init
21+
terraform apply
22+
```
23+
24+
That's it! You should be able to access the deployed Serverless Container's endpoint from the Scaleway Console.
25+
26+
## Using the Application
27+
28+
Once deployed, you can interact with the application using HTTP requests.
29+
30+
```bash
31+
CONTAINER_URL="https://your-container-url"
32+
# Check MongoDB® connection
33+
curl $CONTAINER_URL/check_connection
34+
# Add some people
35+
curl $CONTAINER_URL/person/george
36+
curl $CONTAINER_URL/person/alice
37+
# List all people
38+
curl $CONTAINER_URL/people
39+
```
40+
41+
## Cleaning Up
42+
43+
Make sure to destroy the Terraform-managed infrastructure when you're done:
44+
45+
```bash
46+
terraform destroy
47+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Build stage
2+
FROM denoland/deno:latest AS builder
3+
WORKDIR /app
4+
COPY . .
5+
RUN deno cache main.ts
6+
7+
# Production stage
8+
FROM denoland/deno:latest
9+
WORKDIR /app
10+
COPY --from=builder /app .
11+
CMD ["deno", "run", "--allow-net", "--allow-env", "--allow-read", "--allow-write", "--allow-sys", "main.ts"]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"tasks": {
3+
"dev": "deno run --watch main.ts"
4+
},
5+
"imports": {
6+
"@std/assert": "jsr:@std/assert@1",
7+
"@std/random": "jsr:@std/random@^0.1.4",
8+
"mongoose": "npm:mongoose@^8.20.1"
9+
}
10+
}

containers/vpc-mongodb/app/deno.lock

Lines changed: 129 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)