Jump toUpdate content
Uploading your container using the Serverless.com framework
The Scaleway functions plugin for Serverless Framework allows users to deploy their functions and containers to Scaleway Containers with a simple serverless deploy.
Serverless Framework handles everything from creating namespaces to container deployment by calling APIs endpoint under the hood.
Create the following directory:
~/my-srvless-projects. Then, change into it.
Create a simple docker template by running:
serverless create --template-url https://github.com/scaleway/serverless-scaleway-functions/tree/master/examples/container-schedule --path myService
You can find other Scaleway templates on our Github.
Do not edit the
plugins parameters, as these allow you to use the Scaleway provider.
serverless.yml file determines the configuration of a namespace that contains one or more containers with the same runtime. In the following example, we use one container and a
runtime: python3, node10, node14, golang
# Global Environment variables - used in every containers in the namespace
# the path to the credentials file needs to be absolute
# Local environment variables - used only in given container
rate: '1 * * * *'
The different parameters available are:
service: your namespace name
provider.env: the environment variables attached to your namespace are injected into all your namespace containers
scwToken: the Scaleway token you got in prerequisites
scwProject: the Scaleway Project ID
package.patterns: usually, this parameter does not need to be configured. It allows you to include or exclude directories from the deployment
containers: Configuration of your containers. It is a
ymldictionary, with the key being the containers’ name
directory(Required): directory which contains your Dockerfile and scripts
env(Optional): environment variables specifics for the current container
minScale(Optional): number of running container instances continuously (default: 0)
maxScale(Optional): maximum number of instances this container can scale to (default: 20)
memoryLimit: the RAM allocated to the container instances.
events(Optional): List of events that trigger your containers (e.g, trigger a container based on a schedule with
List your containers under the
custom.containers parameter in your
Specify the relative path of the application directory (containing the Dockerfile, and all files related to the application to deploy) of each container:
# Environment only available in this container
The directory that contains your Dockerfile and scripts is called
my-container-directory. See other files that should be included below:
│ ├── Dockerfile
│ ├── requirements.txt
│ ├── server.py
│ └── (...)
│ ├── serverless-scaleway-functions
│ └── (...)
Scaleway’s platform will automatically inject a PORT environment variable on which your server should be listening for incoming traffic. By default, this PORT is 8080 and it can not be changed for now.
events, you may link your containers to specific triggers. For the moment, the feature is limited to
CRON Schedule (time-based).
We do not include HTTP triggers in our event types, as an HTTP endpoint is created for every container. Triggers are just another way to trigger your Containers, but you will always be able to execute your code via HTTP.
Below is a list of supported triggers for Scaleway Serverless, and the configuration parameters required to deploy them:
- schedule: Triggers your container based on CRON schedules
rate: the CRON Schedule (UNIX Format) on which your containers will be executed
input: key-value mapping to define arguments that will be passed to your container’s event object during execution.
To link a Trigger to your container, you can define an
events key in your container:
# Events key
rate: '1 * * * *'
You can find other examples of trigger configurations on the Scaleway Serverless Github page
serverless logs command allows you to watch the logs of a specific container.
--function option and the container’s name to the
serverless logs command to fetch the logs of a specific container.
serverless logs --function <container_name>
To remove a project run the following command:
This removes all your containers, as well as your Scaleway Containers’ namespace.