|
| 1 | +--- |
| 2 | +title: Hosting websites and web apps with Serverless Containers |
| 3 | +description: This page provides guidelines on how to host and deploy a website or a web app using Scaleway Serverless Containers |
| 4 | +tags: deploy host website webapp next ruby node html static api containerize application docker dockerfile |
| 5 | +dates: |
| 6 | + validation: 2025-10-01 |
| 7 | + posted: 2025-10-01 |
| 8 | +--- |
| 9 | + |
| 10 | +import Requirements from '@macros/iam/requirements.mdx' |
| 11 | + |
| 12 | + |
| 13 | +<Requirements /> |
| 14 | + |
| 15 | +- A Scaleway account logged into the [console](https://console.scaleway.com) |
| 16 | +- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization |
| 17 | +- Installed [Docker](https://docs.docker.com/get-started/get-docker/) or [Docker Egine](https://docs.docker.com/engine/install/) |
| 18 | +- [Created a Scaleway Container Registry namespace](/container-registry/how-to/create-namespace/) and [logged into it](/container-registry/how-to/connect-docker-cli/) |
| 19 | + |
| 20 | + |
| 21 | +## Create and host a simple HTML static page |
| 22 | + |
| 23 | +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](/container-registry/), before deploying it to [Scaleway Serverless Containers](/serverless-containers/). |
| 24 | + |
| 25 | +1. In a terminal, run the command below to create a new folder and access it: |
| 26 | + |
| 27 | + ```sh |
| 28 | + mkdir my-static-website |
| 29 | + cd my-static-website |
| 30 | + ``` |
| 31 | + |
| 32 | +2. Create a new `index.html` file and add the example code below to it: |
| 33 | + |
| 34 | + ```html |
| 35 | + <!DOCTYPE html> |
| 36 | + <html lang="en"> |
| 37 | + <head> |
| 38 | + <meta charset="UTF-8"> |
| 39 | + <title>Simple HTML Page</title> |
| 40 | + </head> |
| 41 | + <body> |
| 42 | + <h1>Hello World</h1> |
| 43 | + <p>This is a simple paragraph.</p> |
| 44 | + </body> |
| 45 | + </html> |
| 46 | + ``` |
| 47 | + |
| 48 | +3. In the same folder, create a new `dockerfile` file and add the following code to it: |
| 49 | + |
| 50 | + ```dockerfile |
| 51 | + FROM nginx:alpine |
| 52 | + COPY ./my-website /usr/share/nginx/html |
| 53 | + EXPOSE 80 |
| 54 | + ``` |
| 55 | + |
| 56 | +4. Run the command below to build, tag, and push your image to the Scaleway Container registry: |
| 57 | + |
| 58 | + ```sh |
| 59 | + docker build --platform linux/amd64 \ |
| 60 | + --push \ |
| 61 | + -t <CONTAINER_REGISTRY_ENDPOINT>/my-static-website:latest . |
| 62 | + ``` |
| 63 | + |
| 64 | + <Message type="note"> |
| 65 | + You can find your Container Registry endpoint in the **Settings** tab of your Container Registry Endpoint in the [Scaleway console](https://console.scaleway.com/registry/namespaces) |
| 66 | + </Message> |
| 67 | + |
| 68 | +5. [Deploy a Serverless Container](/serverless-containers/how-to/deploy-container/) with the following parameters: |
| 69 | + |
| 70 | + - **Registry**: Scaleway Container Registry |
| 71 | + - **Registry namespace**: the Container Registry namespace you pushed your image to. |
| 72 | + - **Container port**: `8O` as it is the [port](/serverless-containers/reference-content/port-parameter-variable/) exposed in the dockerfile. |
| 73 | + - **Resources**: `100 mVCPU` and `256 MB` memory |
| 74 | + - **Autoscaling**: according to your needs. Refer to the [autoscaling documentation](/serverless-containers/reference-content/containers-autoscaling/) for more information. |
| 75 | + |
| 76 | + The deployment of your container can take up to a minute to complete. |
| 77 | + |
| 78 | +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. |
0 commit comments