Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion serverless/containers/how-to/secure-a-container.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ secret:

Add the following [resource description](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/resources/container) in Terraform:

```
```hcl
secret_environment_variables = { "key" = "secret" }
```

Expand Down
6 changes: 3 additions & 3 deletions tutorials/encode-videos-using-serverless-jobs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This tutorial demonstrates the process of encoding videos retrieved from Object

- A Scaleway account logged into the [console](https://console.scaleway.com)
- [Owner](/identity-and-access-management/iam/concepts/#owner) status or [IAM permissions](/identity-and-access-management/iam/concepts/#permission) allowing you to perform actions in the intended Organization
- An [Object Storage bucket](/storage/object/how-to/create-a-bucket/)
- An [Object Storage bucket](/storage/object/how-to/create-a-bucket/)
- A valid [API key](/identity-and-access-management/iam/how-to/create-api-keys/)
- Installed [Docker engine](https://docs.docker.com/engine/install/)

Expand Down Expand Up @@ -72,7 +72,7 @@ The initial step involves defining a Docker image for interacting with the S3 Ob
This Dockerfile uses `linuxserver/ffmpeg` as a base image bundled with FFMPEG along with a variety of encoding codecs and installs [MinIO](https://min.io/) as a command-line S3 client to copy files over Object Storage.

3. Build and [push the image](/containers/container-registry/how-to/push-images/) to your Container Registry:
```
```bash
docker build . -t <registry and image name>
docker push <registry and image name>
```
Expand Down Expand Up @@ -125,7 +125,7 @@ Once the run status is **Succeeded**, the encoded video can be found in your S3
<Message type="note">
Your job can also be triggered through the [Scaleway API](https://www.scaleway.com/en/developers/api/serverless-jobs/#path-job-definitions-run-an-existing-job-definition-by-its-unique-identifier-this-will-create-a-new-job-run) using the same environment variables:

```
```bash
curl -X POST \
-H "X-Auth-Token: <API Key>" \
-H "Content-Type: application/json" \
Expand Down
2 changes: 1 addition & 1 deletion tutorials/snapshot-instances-jobs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Serverless Jobs rely on containers to run in the cloud, and therefore require a

1. Create a `Dockerfile`, and add the following code to it:

```docker
```dockerfile
# Using apline/golang image
FROM golang:1.22-alpine

Expand Down
68 changes: 34 additions & 34 deletions tutorials/strapi-app-serverless-containers-sqldb/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ You can either deploy your application:
2. Run the command below to make sure the environment variables are properly set:

```sh
scw info
scw info
```

This command displays your access key and secret key in the last two lines of the output. The `ORIGIN` column should display `env (SCW_ACCESS_KEY)` and `env (SCW_SECRET_KEY)`, and not `default profile`.

```bash
KEY VALUE ORIGIN
(...)
Expand Down Expand Up @@ -77,16 +77,16 @@ You can either deploy your application:
&& psql -h $DATABASE_HOST -p $DATABASE_PORT \
-d $DATABASE_NAME -U $DATABASE_USERNAME
```
An input field with the name of your database should display:
An input field with the name of your database should display:
```
psql (15.3, server 16.1 (Debian 16.1-1.pgdg120+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_128_GCM_SHA256, compression: off)
Type "help" for help.
Type "help" for help.

tutorial-strapi-blog-db=>
```
</Message>

### Running Strapi locally

1. Create a Strapi blog template
Expand All @@ -95,7 +95,7 @@ You can either deploy your application:
--dbclient=postgres --dbhost=$DATABASE_HOST \
--dbport=$DATABASE_PORT --dbname=$DATABASE_NAME \
--dbusername=$DATABASE_USERNAME \
--dbpassword=$DATABASE_PASSWORD --dbssl=true
--dbpassword=$DATABASE_PASSWORD --dbssl=true
```

2. Access the folder you just created:
Expand All @@ -120,7 +120,7 @@ You can either deploy your application:
touch Dockerfile
```
2. Add the code below to your file, save it, and exit.
```bash
```docker
# Creating a multi-stage build for production
FROM node:20-alpine as build
RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev vips-dev git > /dev/null 2>&1
Expand Down Expand Up @@ -189,12 +189,12 @@ You can either deploy your application:
├── jsconfig.json
├── package.json
├── README.md
└── yarn.lock
└── yarn.lock
```

5. Build your application container:
```bash
docker build -t my-strapi-blog .
docker build -t my-strapi-blog .
```
<Message type="tip">
The docker build image process can take a few minutes, particularly during the `npm install` step, since Strapi requires around 1 GB of node modules to be built.
Expand Down Expand Up @@ -281,7 +281,7 @@ You can either deploy your application:
```
When the status appears as `ready`, you can access the Strapi Administration Panel via your browser.
</Message>

3. Copy the endpoint URL displayed next to the `DomainName` property, and paste it into your browser. The main Strapi page displays. Click "Open the administration" or add `/admin` to your browser URL to access the Strapi Administration Panel.

4. (Optional) You can check that Strapi APIs are working with the following command, or by accessing `https://{container_url}/api/articles` in your browser:
Expand Down Expand Up @@ -319,7 +319,7 @@ However, your Strapi container currently connects to your database with your [us

To secure your deployment, we will now add a dedicated [IAM application](/identity-and-access-management/iam/concepts/#application), give it the minimum required permissions, and provide its credentials to your Strapi container.

1. Run the following command to create an [IAM application](/identity-and-access-management/iam/concepts/#application) and export it as a variable:
1. Run the following command to create an [IAM application](/identity-and-access-management/iam/concepts/#application) and export it as a variable:
```bash
export SCW_APPLICATION_ID=$(scw iam application create name=tutorial-strapi-blog -o json | jq -r '.id')
```
Expand Down Expand Up @@ -364,10 +364,10 @@ To secure your deployment, we will now add a dedicated [IAM application](/identi
secret-environment-variables.5.value=$JWT_SECRET redeploy=true
```

6. Refresh your browser page displaying the Strapi Administration Panel. An updated version displays.
6. Refresh your browser page displaying the Strapi Administration Panel. An updated version displays.

You have now deployed a full serverless Strapi blog example!

## Going further with containers

- Inspect your newly created resources in the Scaleway console:
Expand Down Expand Up @@ -399,11 +399,11 @@ To secure your deployment, we will now add a dedicated [IAM application](/identi
2. Run the command below to make sure the environment variables are properly set:

```sh
scw info
scw info
```

This command displays your access_key and secret_key in the two last lines of the output. The `ORIGIN` column should display `env (SCW_ACCESS_KEY)` and `env (SCW_SECRET_KEY)`, and not `default profile`.

```bash
KEY VALUE ORIGIN
(...)
Expand Down Expand Up @@ -512,12 +512,12 @@ To secure your deployment, we will now add a dedicated [IAM application](/identi
├── jsconfig.json
├── package.json
├── README.md
└── yarn.lock
└── yarn.lock
```

8. Build your application container:
```bash
docker build -t my-strapi-blog .
docker build -t my-strapi-blog .
```
<Message type="tip">
The docker build image process can take a few minutes, particularly during the `npm install` step since Strapi requires around 1 GB of node modules to be built.
Expand Down Expand Up @@ -545,15 +545,15 @@ To secure your deployment, we will now add a dedicated [IAM application](/identi
docker push $REGISTRY_ENDPOINT/my-strapi-blog:latest
```


### Creating the Terraform configuration

1. Run the following command to create a new folder to store your Terraform files, and access it:
```bash
cd ..
mkdir terraform-strapi-blog &&
cd terraform-strapi-blog
```
```

2. Create an empty `main.tf` Terraform file inside the folder.

Expand All @@ -565,7 +565,7 @@ To secure your deployment, we will now add a dedicated [IAM application](/identi
```

3. Add the following code to your `main.tf` file:
```json
```hcl
terraform {
required_providers {
scaleway = {
Expand All @@ -577,12 +577,12 @@ To secure your deployment, we will now add a dedicated [IAM application](/identi
}
required_version = ">= 0.13"
}

variable "REGISTRY_ENDPOINT" {
type = string
description = "Container Registry endpoint where your application container is stored"
}

variable "DEFAULT_PROJECT_ID" {
type = string
description = "Project ID where your resources will be created"
Expand All @@ -606,12 +606,12 @@ To secure your deployment, we will now add a dedicated [IAM application](/identi
for_each = toset(local.secrets)
length = 16
}

resource scaleway_container_namespace main {
name = "tutorial-strapi-blog-tf"
description = "Namespace created for full serverless Strapi blog deployment"
}

resource scaleway_container main {

name = "tutorial-strapi-blog-tf"
Expand All @@ -628,7 +628,7 @@ To secure your deployment, we will now add a dedicated [IAM application](/identi
privacy = "public"
protocol = "http1"
deploy = true

environment_variables = {
"DATABASE_CLIENT"="postgres",
"DATABASE_USERNAME" = scaleway_iam_application.app.id,
Expand All @@ -648,11 +648,11 @@ To secure your deployment, we will now add a dedicated [IAM application](/identi
"JWT_SECRET" = random_bytes.generated_secrets["jwt_secret"].base64
}
}

resource scaleway_iam_application "app" {
name = "tutorial-strapi-blog-tf"
}

resource scaleway_iam_policy "db_access" {
name = "tutorial-strapi-policy-tf"
description = "Gives tutorial Strapi blog access to Serverless SQL Database"
Expand All @@ -662,17 +662,17 @@ To secure your deployment, we will now add a dedicated [IAM application](/identi
permission_set_names = ["ServerlessSQLDatabaseReadWrite"]
}
}

resource scaleway_iam_api_key "api_key" {
application_id = scaleway_iam_application.app.id
}

resource scaleway_sdb_sql_database "database" {
name = "tutorial-strapi-tf"
min_cpu = 0
max_cpu = 8
}

output "database_connection_string" {
// Output as an example, you can give this string to your application
value = format("postgres://%s:%s@%s",
Expand All @@ -682,7 +682,7 @@ To secure your deployment, we will now add a dedicated [IAM application](/identi
)
sensitive = true
}

output "container_url" {
// Output as an example, you can give this string to your application
value = scaleway_container.main.domain_name
Expand Down Expand Up @@ -718,7 +718,7 @@ The Terraform file creates several resources:
```
Edit the `ADMIN_EMAIL` and `ADMIN_PASSWORD` values with your own email and password. Optionally, you can also edit `ADMIN_FIRSTNAME` and `ADMIN_LASTNAME` values to change the default admin first and last name.
<Message type="note">
Strapi admin password requires at least 8 characters including one uppercase, one lowercase, one number, and one special character.
Strapi admin password requires at least 8 characters including one uppercase, one lowercase, one number, and one special character.
If the admin password or email does not meet the requirements, the container will not start.
</Message>

Expand Down Expand Up @@ -813,7 +813,7 @@ Once you are done, run the following command to stop all your resources:
- **Fine-tune deployment options** such as autoscaling, targeted regions, and more. You can find more information by typing `scw container deploy --help` in your terminal, or by referring to the [dedicated documentation](/serverless/containers/how-to/manage-a-container/)

- Create a secondary production environment by duplicating your built container, building it in `NODE_ENV=production` environment, running `npm run start`, and plugging it onto another **Serverless SQL Database**. For instance, this will allow you to edit content-types which is not possible in production.

## Troubleshooting

If you happen to encounter any issues, first check that you meet all the requirements.
Expand All @@ -827,7 +827,7 @@ If you happen to encounter any issues, first check that you meet all the require
UpdatedAt 1 year ago
Description -
```
<Message type="tip">
<Message type="tip">
You can also find and compare your Project and Organization ID in the [Scaleway console settings](https://console.scaleway.com/project/settings).
</Message>
- You have **Docker Engine** installed. Running the `docker -v` command in a terminal should display your currently installed docker version:
Expand Down