You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/hosting-django-webapp-serverless-containers/index.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,7 +89,7 @@ To host a [Django](https://www.djangoproject.com/) web application on **Scaleway
89
89
90
90
### Build the app image and push it to Scaleway Container Registry
91
91
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/).
93
93
94
94
1. Create a `Dockerfile` at the root of your Django app:
Copy file name to clipboardExpand all lines: tutorials/hosting-go-gin-webapp-serverless-containers/index.mdx
+41-21Lines changed: 41 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@ import Requirements from '@macros/iam/requirements.mdx'
26
26
-[Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
27
27
- Installed [Docker](https://docs.docker.com/get-started/get-docker/) or [Docker Engine](https://docs.docker.com/engine/install/)
28
28
-[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)
29
30
30
31
31
32
## 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
47
48
go mod init my-gin-app
48
49
```
49
50
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:
51
52
```go
52
53
package main
53
54
54
55
import"github.com/gin-gonic/gin"
55
56
56
57
funcmain() {
57
58
r:= gin.Default()
59
+
r.LoadHTMLGlob("templates/*")
58
60
59
-
// Define a simple route
60
61
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)
64
63
})
65
64
66
-
// Start server on 0.0.0.0:8080
67
65
r.Run("0.0.0.0:8080")
68
66
}
69
67
```
70
68
71
-
4. Install Gin:
69
+
4. Create a `templates` folder to store HTTP files.
70
+
72
71
```bash
73
-
go get -u github.com/gin-gonic/gin
72
+
mkdir templates
74
73
```
75
74
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:
<p>A minimal page, fast and clean, running on Scaleway Serverless Containers.</p>
98
+
</body>
99
+
</html>
79
100
```
80
-
Visit [http://localhost:8080](http://localhost:8080) to see the JSON response.
81
101
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
83
105
```
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
89
110
```
111
+
Visit [http://localhost:8080](http://localhost:8080) to see the homepage of your web app.
90
112
91
113
### Build the app image and push it to Scaleway Container Registry
92
114
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/).
96
116
97
117
1. Create a `Dockerfile` at the root of your project:
0 commit comments