How to build and push a container image
This page explains how to create a simple Dockerfile to containerize your applications for deployment using Scaleway Serverless Jobs.
How to Write a DockerfileLink to this anchor
-
Create a file named
Dockerfile
in your project directory. -
Add the following content to your Dockerfile, adjusting the base image and commands according to your application:
# Use the official Golang image to create a build artifact.FROM golang:1.24-alpine AS builder# Create the main.go file with the Go source codeRUN echo 'package mainimport "fmt"func main() {fmt.Println("Hello from Scaleway Serverless Jobs!")}' > main.go# Build the Go appRUN go build -o main .# Start a new stage from scratchFROM alpine:latest# Copy the Pre-built binary file from the previous stageCOPY --from=builder /app/main .# Command to run the executableCMD ["./main"]
FROM python:3.13-slim# Single-line Python script as entrypointCMD ["python", "-c", "print('Hello from Scaleway Serverless Jobs!')"]
FROM rust:1.86-slim# Pre-compile a Rust binary during buildRUN echo 'fn main() { println!("Hello from Scaleway Serverless Jobs!"); }' > main.rs && \rustc main.rs# Run the pre-compiled binaryCMD ["./main"]
How to build and push your image from your DockerfileLink to this anchor
-
Open a terminal and navigate to the directory containing your Dockerfile.
-
Run the following command to build your Docker image:
docker build -t my-application . -
Run the command below to log in to your Scaleway account in the terminal. Make sure that you replace the placeholder values with your own.
docker login rg.fr-par.scw.cloud/your-container-registry-namespace -u nologin --password-stdin <<< "$SCW_SECRET_KEY" -
Tag your Docker image so it matches your Scaleway registry’s format:
docker tag my-application:latest rg.fr-par.scw.cloud/your-container-registry-namespace/my-application:latest -
Push the Docker image to the Scaleway Container Registry:
docker push rg.fr-par.scw.cloud/your-container-registry-namespace/my-application:latest
You can now access your container image from the Scaleway Container Registry, and deploy a Serverless Job from this image.