-
Notifications
You must be signed in to change notification settings - Fork 260
feat(containers): mdbook tutorial #3856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8b3b1df
feat(containers): mdbook tutorial
thomas-tacquet b81f031
Merge branch 'main' into serverless-containers-mdbook
thomas-tacquet 544a217
polish text
thomas-tacquet 6f73431
syntax
thomas-tacquet 567b509
Apply suggestions from code review
thomas-tacquet 667fdc8
Apply suggestions from code review
thomas-tacquet c167ce6
indent
thomas-tacquet fdb0b70
docs(srv): documentation review
SamyOubouaziz 63611ee
docs(srv): update
SamyOubouaziz 3bd83d9
docs(srv): update
SamyOubouaziz 537bd41
docs(srv): fix 404s
SamyOubouaziz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
tutorials/deploy-mdbooks-serverless-containers/index.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| onf--- | ||
| meta: | ||
| title: Fast deployment of documentation on Serverless Containers with mdbooks | ||
| description: Step-by-step guide to deploy mdbooks on Serverless Containers. | ||
thomas-tacquet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| content: | ||
| h1: Deploying mdbooks on Serverless Containers | ||
thomas-tacquet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| paragraph: | ||
thomas-tacquet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| tags: docker container deploy serverless | ||
| hero: assets/scaleway-umami.webp | ||
| categories: | ||
| - containers | ||
| - container-registry | ||
| dates: | ||
| validation: | ||
thomas-tacquet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| posted: | ||
thomas-tacquet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| --- | ||
|
|
||
| Publish modern online books, for product, API documentation, tutorials, course material or anything that requires a clean, easily navigable and customizable presentation. | ||
|
|
||
| <Macro id="requirements" /> | ||
|
|
||
| - 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 | ||
| - Docker installed on your local machine | ||
|
|
||
| ## Why deploying on Serverless | ||
thomas-tacquet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Serverless products are perfect for cost efficiency with a pay-as-you go model and scales very well. | ||
thomas-tacquet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| With zero infrastructure management a lot of tools to integrate in CI/CD environments, `mdbooks` can benefits a lot of Serverless Containers. | ||
thomas-tacquet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Local setup | ||
|
|
||
| Follow [Istallation instructions](https://rust-lang.github.io/mdBook/guide/installation.html) of mdbooks. | ||
|
|
||
| Run: | ||
| - `mdbook init my-first-book` in order to create a sample book. | ||
| - `cd my-first-book` | ||
|
|
||
| Now you can edit the content of the book to publish. | ||
|
|
||
| It's recommanded to test the book using the command: `mdbook test`. | ||
|
|
||
| ## Prepare Container Registry | ||
|
|
||
| <Message type="note"> | ||
| We recommend using Scaleway Container Registry instead of external registries to avoid errors of rate limiting and risks regarding evolutions of CGU and pricing. | ||
| </Message> | ||
|
|
||
| 1. Create a file named `Dockerfile` in this folder containing the following code: | ||
|
|
||
| ```dockerfile | ||
SamyOubouaziz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| FROM debian:bookworm-slim | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Copy necessary files (add if you have custom files) | ||
| COPY book.toml /app/ | ||
| COPY src/* /app/src/ | ||
|
|
||
| # Install mdbooks binary | ||
| RUN apt-get -y update; apt-get -y install curl; | ||
| RUN mkdir /home/mdbooks | ||
| RUN curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.40/mdbook-v0.4.40-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=/home/mdbooks | ||
| ENV PATH="$PATH:/home/mdbooks" | ||
|
|
||
| # Serve the book: | ||
| # 0.0.0.0 is required to listen on public interface, otherwise mdbook will only listen for localhost | ||
| # 8080 port is used to match the Serverless Container settings. | ||
| ENTRYPOINT ["mdbook", "serve", "-n", "0.0.0.0", "-p", "8080" ] | ||
| ``` | ||
|
|
||
| 2. Open Container Registry product on Scaleway Console. | ||
thomas-tacquet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 3. Click **Create namespace**. A namespace is used to hold the image. | ||
|
|
||
| <Message type="note"> | ||
| A pop-up will appear with informations to log into your Container Registry Namespace. This will allow to push the image later. | ||
| </Message> | ||
|
|
||
| 4. Create the namespace and save the registry endpoint. It should be something like `rg.fr-par.scw.cloud/<namespace>` | ||
|
|
||
thomas-tacquet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ## Build and Push | ||
thomas-tacquet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 1. Run the command `docker build -t rg.<region>.scw.cloud/<namespace>/<image_name>:<tag_name> .` | ||
| * **region**: to get this information, check the namespace settings of the namespace you created. | ||
SamyOubouaziz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * **image_name**: use the name you want to identify your image, for example `mdbook`. | ||
| * **tag_name**: use tags to identify the version of your image, for example `v1`. | ||
|
|
||
| 2. Push the image: | ||
| `docker push rg.<region>.scw.cloud/<namespace>/<image_name>:<tag>` | ||
SamyOubouaziz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Deploy the Serverless Container | ||
|
|
||
| 1. Create a Serverless Container Namespace. [Link to console](https://console.scaleway.com/containers/namespaces/create) | ||
thomas-tacquet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 2. Configure the Serverless Containers. Important points are: | ||
| * **Image**: Select the Registry namespace, Container and Tag you created before using the dropdowns. | ||
| * **Name**: You can change the default name to use a more meaningful one. | ||
|
|
||
| You can keep default values of other parameters and fine-tune them later at anytime without downtime. | ||
|
|
||
| 3. Click "Deploy container" button and wait few seconds for the deployment. | ||
| 4. Congratulation you Serverless Container is deployed an ready :) | ||
|
|
||
| ## Going further | ||
|
|
||
| - Integrate in CI/CD | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.