Hosting a static website with Serverless Containers
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- Installed Docker or Docker Egine
- Created a Scaleway Container Registry namespace and logged into it
Create and host a simple HTML static page
To host a static HTML page on Serverless Containers, you first need to create a simple HTML page that will serve as your website. Next, you will write a Dockerfile to containerize your application, specifying how your HTML file should be served. You will then build the container image locally, and push it to the Scaleway Container Registry, before deploying it to Scaleway Serverless Containers.
-
In a terminal, run the command below to create a new folder and access it:
mkdir my-static-website cd my-static-website -
Create a new
index.htmlfile and add the example code below to it:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Simple HTML Page</title> </head> <body> <h1>Hello World</h1> <p>This is a simple paragraph.</p> </body> </html> -
In the same folder, create a new
dockerfilefile and add the following code to it:FROM nginx:alpine COPY ./my-static-website /usr/share/nginx/html EXPOSE 80 -
Run the command below to build, tag, and push your image to the Scaleway Container registry:
docker build \ --platform linux/amd64 \ --push \ -t <CONTAINER_REGISTRY_ENDPOINT>/my-static-website:latest . -
Deploy a Serverless Container with the following parameters:
- Registry: Scaleway Container Registry
- Registry namespace: the Container Registry namespace you pushed your image to.
- Container port:
8Oas it is the port exposed in the dockerfile. - Resources:
100 mVCPUand256 MBmemory - Autoscaling: set a minimum scale of
1to avoid cold starts (optional).
The deployment of your container can take up to a minute to complete.
-
Once your container is ready, click the container endpoint from its Overview tab. Your web page displays, and is available to anyone with the link.
Going further
- You can host a website composed of multiple pages in the
my-static-websitefolder. - You can add a custom domain name to your website.
- You can host dynamic websites using dedicated frameworks for high-quality web applications.
Visit our Help Center and find the answers to your most frequent questions.
Visit Help Center