Skip to content

Commit b4abcae

Browse files
committed
docs(SRV): update
1 parent 2980a76 commit b4abcae

File tree

1 file changed

+55
-28
lines changed

1 file changed

+55
-28
lines changed

pages/serverless-jobs/how-to/build-push-container-image.mdx

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,55 +22,82 @@ This page explains how to create a simple Dockerfile to containerize your applic
2222

2323
2. Add the following content to your Dockerfile, adjusting the base image and commands according to your application:
2424

25+
<Tabs id="dockerfile-examples">
26+
<TabsTab label="Go">
2527
```dockerfile
26-
# Use an official base image
27-
FROM python:3.9-slim
28+
# Use the official Golang image to create a build artifact.
29+
FROM golang:1.24-alpine AS builder
2830

29-
# Set the working directory in the container
30-
WORKDIR /app
31+
# Create the main.go file with the Go source code
32+
RUN echo 'package main
3133
32-
# Copy the current directory contents into the container at /app
33-
COPY . /app
34+
import "fmt"
3435
35-
# Install any needed packages specified in requirements.txt
36-
RUN pip install --no-cache-dir -r requirements.txt
36+
func main() {
37+
fmt.Println("Hello from Scaleway Serverless Jobs!")
38+
}' > main.go
3739

38-
# Make port 80 available to the world outside this container
39-
EXPOSE 80
40+
# Build the Go app
41+
RUN go build -o main .
4042

41-
# Define environment variable
42-
ENV NAME World
43+
# Start a new stage from scratch
44+
FROM alpine:latest
4345

44-
# Run app.py when the container launches
45-
CMD ["python", "app.py"]
46+
# Copy the Pre-built binary file from the previous stage
47+
COPY --from=builder /app/main .
48+
49+
# Command to run the executable
50+
CMD ["./main"]
51+
```
52+
</TabsTab>
53+
<TabsTab label="Python">
54+
```dockerfile
55+
FROM python:3.13-slim
56+
57+
# Single-line Python script as entrypoint
58+
CMD ["python", "-c", "print('Hello from Scaleway Serverless Jobs!')"]
59+
```
60+
</TabsTab>
61+
<TabsTab label="Rust">
62+
```dockerfile
63+
FROM rust:1.86-slim
64+
65+
# Pre-compile a Rust binary during build
66+
RUN echo 'fn main() { println!("Hello from Scaleway Serverless Jobs!"); }' > main.rs && \
67+
rustc main.rs
68+
69+
# Run the pre-compiled binary
70+
CMD ["./main"]
4671
```
72+
</TabsTab>
73+
</Tabs>
4774

4875
## How to build and push your image from your dockerfile
4976

5077
1. Open a terminal and navigate to the directory containing your Dockerfile.
5178

5279
2. Run the following command to build your Docker image:
5380

54-
```bash
55-
docker build -t my-application .
56-
```
81+
```bash
82+
docker build -t my-application .
83+
```
5784

58-
3. Log in to your Scaleway account in the terminal:
85+
3. Run the command below to log in to your Scaleway account in the terminal. Do not forget to replace the placeholder with your Container Registry namespace endpoint:
5986

60-
```
61-
docker login -u <your-email> --password-stdin
62-
```
87+
```
88+
docker login rg.fr-par.scw.cloud/your-container-registry-namespace -u nologin --password-stdin <<< "$SCW_SECRET_KEY"
89+
```
6390

6491
4. Tag your Docker image so it matches your Scaleway registry's format:
6592

66-
```
67-
docker tag my-application
68-
```
93+
```
94+
docker tag my-application:latest rg.fr-par.scw.cloud/your-container-registry-namespace/my-application:latest
95+
```
6996

7097
5. Push the Docker image to the Scaleway Container Registry:
7198

72-
```
73-
docker push
74-
```
99+
```
100+
docker push rg.fr-par.scw.cloud/your-container-registry-namespace/my-application:latest
101+
```
75102

76-
You can now access your container image from the [Scaleway Container Registry](https://console.scaleway.com/)
103+
You can now access your container image from the [Scaleway Container Registry](https://console.scaleway.com/registry/namespaces), and [deploy a Serverless Job](/serverless-jobs/reference-content/deploy-job/) from this image.

0 commit comments

Comments
 (0)