Skip to content

Commit 3924c1c

Browse files
authored
feat(containers): add memory limit value (#13)
1 parent 0a0bf0a commit 3924c1c

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

README.md

+10-12
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
You can can setup this namespace with our cli `scw containers namespace create` command.
3434

3535
- (optional) Setup a `SCW_DNS_ZONE` within your repository `Secrets` section and set its value with your Scaleway account DNS zone.
36-
How To add [Custom Domains](https://www.scaleway.com/en/docs/compute/containers/how-to/add-a-custom-domain-to-a-container/).
37-
In this automation process, we will use the DNS zone of your Scaleway account. Each zone will be based on the container name created and based on the tag of your Image.
38-
Your path registry is `rg.fr-par.scw.cloud/test/images:latest`, your container name tag will be `latest` and your DNS zone will be `latest.${SCW_DNS_ZONE}`.
36+
How To add [Custom Domains](https://www.scaleway.com/en/docs/compute/containers/how-to/add-a-custom-domain-to-a-container/).
37+
In this automation process, we will use the DNS zone of your Scaleway account. Each zone will be based on the container name created and based on the tag of your Image.
38+
Your path registry is `rg.fr-par.scw.cloud/test/images:latest`, your container name tag will be `latest` and your DNS zone will be `latest.${SCW_DNS_ZONE}`.
3939

4040
## 🔌 Usage
4141

@@ -48,6 +48,7 @@ Your path registry is `rg.fr-par.scw.cloud/test/images:latest`, your container n
4848
| type | deploy (default value ) |
4949
| scw_registry | rg.fr-par.scw.cloud/test/images:latest |
5050
| scw_container_port | 80 (default value ) |
51+
| scw_memory_limit | 256 (default value ) |
5152

5253
```bash
5354
on: [push]
@@ -102,11 +103,11 @@ jobs:
102103

103104
### dns deploy
104105

105-
| input name | value |
106-
| ------------------------- | -------------------------------------- |
107-
| type | deploy |
108-
| scw_registry | rg.fr-par.scw.cloud/test/images:latest |
109-
| scw_dns | containers.test.fr |
106+
| input name | value |
107+
| ------------ | -------------------------------------- |
108+
| type | deploy |
109+
| scw_registry | rg.fr-par.scw.cloud/test/images:latest |
110+
| scw_dns | containers.test.fr |
110111

111112
Actually, prefix of your dns will use the default value: "name of you created container"
112113
This created containers will be based on the tag name of the registry.
@@ -142,7 +143,6 @@ jobs:
142143
| scw_dns | containers.test.fr |
143144
| scw_dns_prefix (optional) | testing |
144145

145-
146146
```bash
147147
on: [push]
148148

@@ -165,7 +165,6 @@ jobs:
165165
scw_dns: containers.test.fr
166166
```
167167

168-
169168
## 🐳 Docker
170169

171170
If you want to use this flow outside of Github Actions, you can use the Docker Image.
@@ -179,5 +178,4 @@ docker run -it --rm \
179178
-e INPUT_SCW_DNS=containers.test.fr \
180179
-e INPUT_TYPE=deploy \
181180
phiphi/scaleway-containers-deploy:latest
182-
```
183-
181+
```

action.yaml

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ inputs:
1111
scw_secret_key:
1212
description: "secret key ( https://console.scaleway.com/project/credentials )"
1313
required: true
14-
# scw_project_id:
15-
# description: "Project ID"
16-
# required: true
1714
scw_containers_namespace_id:
1815
description: "default namespace id where your container will be deploy, if this not required, this action will create a namespace and we need projectID to be set."
1916
required: true
@@ -24,6 +21,10 @@ inputs:
2421
description: "Default port where your docker container expose"
2522
required: false
2623
default: "80"
24+
scw_memory_limit:
25+
description: "Memory limit in MB ( 128 | 256 | 512 | 1024 | 2048 )"
26+
required: false
27+
default: "256"
2728
scw_dns:
2829
description: "DNS name where your container will be available"
2930
required: false
@@ -53,10 +54,10 @@ runs:
5354
- ${{ inputs.type }}
5455
- ${{ inputs.scw_access_key }}
5556
- ${{ inputs.scw_secret_key }}
56-
# - ${{ inputs.scw_project_id }}
5757
- ${{ inputs.scw_containers_namespace_id }}
5858
- ${{ inputs.scw_registry }}
5959
- ${{ inputs.scw_container_port }}
60+
- ${{ inputs.scw_memory_limit }}
6061
- ${{ inputs.scw_dns }}
6162
- ${{ inputs.scw_dns_prefix }}
6263
# - ${{ inputs.scw_debug }}

container.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,11 @@ func CreateContainerAndDeploy(
188188

189189
api := container.NewAPI(client)
190190

191-
port, _ := strconv.ParseInt(envOr(EnvContainerPort, "80"), 10, 32)
191+
port, _ := strconv.ParseInt(envOr(EnvContainerPort, fmt.Sprint(Port)), 10, 32)
192+
memoryLimit, _ := strconv.ParseInt(envOr(EnvMemoryLimit, fmt.Sprint(MemoryLimit)), 10, 32)
192193

193194
Port := uint32(port)
195+
MemoryLimit := uint32(memoryLimit)
194196

195197
createdContainer, err := api.CreateContainer(&container.CreateContainerRequest{
196198
Description: &Description,

main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const (
1919
EnvPathRegistry = "INPUT_SCW_REGISTRY"
2020
EnvProjectID = "INPUT_SCW_PROJECT_ID"
2121
EnvSecretKey = "INPUT_SCW_SECRET_KEY"
22+
EnvMemoryLimit = "INPUT_SCW_MEMORY_LIMIT"
2223
)
2324

2425
var (
@@ -27,7 +28,7 @@ var (
2728
MinScale uint32 = 1
2829
MaxScale uint32 = 5
2930
MaxConcurrency uint32 = 5
30-
MemoryLimit uint32 = 1024
31+
MemoryLimit uint32 = 256
3132
Timeout scw.Duration = scw.Duration{
3233
Seconds: 60,
3334
Nanos: 0,

0 commit comments

Comments
 (0)