|
| 1 | +# Ruby hello world |
| 2 | + |
| 3 | +This example demonstrates the deployment of a simple Ruby http service on Scaleway Serverless Containers. |
| 4 | + |
| 5 | +For this example, we will use the CLI to deploy the container, but you can use [other methods](https://www.scaleway.com/en/docs/serverless/containers/reference-content/deploy-container/). |
| 6 | + |
| 7 | +## Workflow |
| 8 | + |
| 9 | +Here are the different steps we are going to proceed: |
| 10 | + |
| 11 | +- Quick set-up of Container Registry to host our Ruby container |
| 12 | +- Deploy the Serverless Container |
| 13 | +- Test the container |
| 14 | + |
| 15 | +## Deployment |
| 16 | + |
| 17 | +### Requirements |
| 18 | + |
| 19 | +To complete the actions presented below, you must have: |
| 20 | +- installed and configured the [Scaleway CLI](https://www.scaleway.com/en/docs/developer-tools/scaleway-cli/quickstart/) |
| 21 | +- installed [Docker](https://docs.docker.com/engine/install/) to build the image |
| 22 | + |
| 23 | +### Building the image |
| 24 | + |
| 25 | +1. Run the following command in a terminal to create Container Registry namespace to store the image: |
| 26 | + |
| 27 | + ```bash |
| 28 | + scw registry namespace create name=hello-ruby |
| 29 | + ``` |
| 30 | + |
| 31 | + The registry namespace information displays. |
| 32 | + |
| 33 | +1. Copy the namespace endpoint (in this case, `rg.fr-par.scw.cloud/hello-ruby`). |
| 34 | + |
| 35 | +1. Log into the Container Registry namespace you created using Docker: |
| 36 | + |
| 37 | + ```bash |
| 38 | + docker login rg.fr-par.scw.cloud/hello-ruby -u nologin --password-stdin <<< "$SCW_SECRET_KEY" |
| 39 | + ``` |
| 40 | + |
| 41 | + At this point, you have correctly set up Docker to be able to push your image online. |
| 42 | + |
| 43 | +1. In a terminal, access this directory (containing the Dockerfile), and run the following command to build and tag the image: |
| 44 | + |
| 45 | + ```bash |
| 46 | + docker build --platform linux/amd64 -t rg.fr-par.scw.cloud/hello-ruby/ruby:v1 . |
| 47 | + ``` |
| 48 | + |
| 49 | +1. Tag and push the image to the registry namespace: |
| 50 | + |
| 51 | + ```bash |
| 52 | + docker push rg.fr-par.scw.cloud/hello-ruby/ruby:v1 |
| 53 | + ``` |
| 54 | + |
| 55 | +### Deploying the image |
| 56 | + |
| 57 | +In a terminal, run the following command to create a Serverless Containers namespace: |
| 58 | + |
| 59 | + ```bash |
| 60 | + scw container namespace create name=hello |
| 61 | + ``` |
| 62 | + The namespace information displays. |
| 63 | + |
| 64 | +1. Copy the namespace ID. |
| 65 | + |
| 66 | +1. Run the following command to create and deploy the container: |
| 67 | + |
| 68 | + ```bash |
| 69 | + scw container container create namespace-id=<PREVIOUS_NAMESPACE_ID> name=hello registry-image=rg.fr-par.scw.cloud/hello-ruby/ruby:v1 |
| 70 | + ``` |
| 71 | + The container information displays. |
| 72 | + |
| 73 | +1. Copy the DomainName (endpoint) to test your container, you can put the endpoint in your web browser for testing. |
0 commit comments