Skip to content

Commit 4542f17

Browse files
committed
feat(srv): update
1 parent 6c746f4 commit 4542f17

File tree

2 files changed

+42
-22
lines changed
  • tutorials
    • hosting-django-webapp-serverless-containers
    • hosting-go-gin-webapp-serverless-containers

2 files changed

+42
-22
lines changed

β€Žtutorials/hosting-django-webapp-serverless-containers/index.mdxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ To host a [Django](https://www.djangoproject.com/) web application on **Scaleway
8989

9090
### Build the app image and push it to Scaleway Container Registry
9191

92-
Before building and pushing your image, ensure you have [created a Scaleway Container Registry namespace](/container-registry/how-to/create-namespace/), and [logged into it with the Docker CLI](/container-registry/how-to/connect-docker-cli/)
92+
Before building and pushing your image, ensure you have [created a Scaleway Container Registry namespace](/container-registry/how-to/create-namespace/), and [logged into it with the Docker CLI](/container-registry/how-to/connect-docker-cli/).
9393

9494
1. Create a `Dockerfile` at the root of your Django app:
9595
```dockerfile

β€Žtutorials/hosting-go-gin-webapp-serverless-containers/index.mdxβ€Ž

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import Requirements from '@macros/iam/requirements.mdx'
2626
- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
2727
- Installed [Docker](https://docs.docker.com/get-started/get-docker/) or [Docker Engine](https://docs.docker.com/engine/install/)
2828
- [Created a Scaleway Container Registry namespace](/container-registry/how-to/create-namespace/) and [logged into it](/container-registry/how-to/connect-docker-cli/)
29+
- [Installed go 1.23 or newer](https://go.dev/doc/install)
2930

3031

3132
## Create and host a basic Go Gin web application
@@ -47,52 +48,71 @@ Gin is a lightweight, high-performance web framework for Go, ideal for building
4748
go mod init my-gin-app
4849
```
4950

50-
3. Create a `main.go` file with a basic Gin server:
51+
3. Create a `main.go` file, then add the code below to it to create a basic Gin server:
5152
```go
5253
package main
5354

5455
import "github.com/gin-gonic/gin"
5556

5657
func main() {
5758
r := gin.Default()
59+
r.LoadHTMLGlob("templates/*")
5860

59-
// Define a simple route
6061
r.GET("/", func(c *gin.Context) {
61-
c.JSON(200, gin.H{
62-
"message": "Hello from Gin on Scaleway!",
63-
})
62+
c.HTML(200, "index.html", nil)
6463
})
6564

66-
// Start server on 0.0.0.0:8080
6765
r.Run("0.0.0.0:8080")
6866
}
6967
```
7068

71-
4. Install Gin:
69+
4. Create a `templates` folder to store HTTP files.
70+
7271
```bash
73-
go get -u github.com/gin-gonic/gin
72+
mkdir templates
7473
```
7574

76-
5. Test the app locally:
77-
```bash
78-
go run main.go
75+
5. Create an `index.html` file in the `templates` folder, then add the code below to it:
76+
77+
```html
78+
<!DOCTYPE html>
79+
<html lang="en">
80+
<head>
81+
<meta charset="UTF-8" />
82+
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
83+
<title>Hello</title>
84+
<style>
85+
body {
86+
font-family: sans-serif;
87+
text-align: center;
88+
margin: 0;
89+
padding: 100px 20px;
90+
background: #fafafa;
91+
color: #333;
92+
}
93+
</style>
94+
</head>
95+
<body>
96+
<h1>Hello from Gin 🌿</h1>
97+
<p>A minimal page, fast and clean, running on Scaleway Serverless Containers.</p>
98+
</body>
99+
</html>
79100
```
80-
Visit [http://localhost:8080](http://localhost:8080) to see the JSON response.
81101

82-
6. Your project structure should now look like:
102+
6. Run the following command to install the Gin package:
103+
```bash
104+
go get -u github.com/gin-gonic/gin
83105
```
84-
my-gin-app/
85-
β”œβ”€β”€ main.go
86-
β”œβ”€β”€ go.mod
87-
β”œβ”€β”€ go.sum
88-
└── (optional) Dockerfile
106+
107+
7. Test the app locally:
108+
```bash
109+
go run main.go
89110
```
111+
Visit [http://localhost:8080](http://localhost:8080) to see the homepage of your web app.
90112

91113
### Build the app image and push it to Scaleway Container Registry
92114

93-
Before building and pushing your image, ensure you have:
94-
- [Created a Scaleway Container Registry namespace](/container-registry/how-to/create-namespace/)
95-
- [Logged into it with Docker CLI](/container-registry/how-to/connect-docker-cli/)
115+
Before building and pushing your image, ensure you have [created a Scaleway Container Registry namespace](/container-registry/how-to/create-namespace/), and [logged into it with the Docker CLI](/container-registry/how-to/connect-docker-cli/).
96116

97117
1. Create a `Dockerfile` at the root of your project:
98118
```dockerfile

0 commit comments

Comments
Β (0)