Skip to navigationSkip to main contentSkip to footerScaleway DocsAsk our AI
Ask our AI

Hosting a static website with Serverless Containers

deploy
host
website
webapp
html
static
containerize
application
docker
dockerfile

Before you start

To complete the actions presented below, you must have:

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.

  1. In a terminal, run the command below to create a new folder and access it:

    mkdir my-static-website
    cd my-static-website
  2. Create a new index.html file 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>
  3. In the same folder, create a new dockerfile file and add the following code to it:

    FROM nginx:alpine
    COPY ./my-static-website /usr/share/nginx/html
    EXPOSE 80
  4. 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 .
    Note

    You can find your Container Registry endpoint in the Settings tab of your Container Registry Endpoint in the Scaleway console

  5. 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: 8O as it is the port exposed in the dockerfile.
    • Resources: 100 mVCPU and 256 MB memory
    • Autoscaling: set a minimum scale of 1 to avoid cold starts (optional).

    The deployment of your container can take up to a minute to complete.

  6. 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-website folder.
  • You can add a custom domain name to your website.
  • You can host dynamic websites using dedicated frameworks for high-quality web applications.
Questions?

Visit our Help Center and find the answers to your most frequent questions.

Visit Help Center
No Results