Skip to content

Commit

Permalink
Sync from docker/docs@2f0e1ef by PCIT
Browse files Browse the repository at this point in the history
  • Loading branch information
khs1994 committed Nov 1, 2023
1 parent c431722 commit de9dec0
Show file tree
Hide file tree
Showing 11 changed files with 393 additions and 59 deletions.
2 changes: 1 addition & 1 deletion SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@
* [Rust Language Specific Guide](content/language/rust/_index.md)
* [Build Your Rust Image](content/language/rust/build-images.md)
* [Configure CI CD For Your Rust Application](content/language/rust/configure-ci-cd.md)
* [Deploy Your Rust App](content/language/rust/deploy.md)
* [Test Your Rust Deployment](content/language/rust/deploy.md)
* [Develop Your Rust Application](content/language/rust/develop.md)
* [Run Your Rust Image As A Container](content/language/rust/run-containers.md)
* [Language Specific Guides Overview](content/language/_index.md)
Expand Down
47 changes: 23 additions & 24 deletions assets/css/code.css
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
.prose {
pre {
@apply rounded-sm border border-gray-light-200 p-3 dark:border-gray-dark-400;
}
:not(pre) > code {
display: inline-block;
margin: 0 !important;
white-space: nowrap;
font-weight: 400;
padding: 0 4px;
border: 1px solid;
border-radius: theme("spacing.1");
background: theme("colors.gray.light.200");
border-color: theme("colors.gray.light.300");
.dark & {
background: theme("colors.gray.dark.200");
border-color: theme("colors.gray.dark.300");
}
}
code::before {
content: "";
}
code::after {
content: "";
.highlight, :not(pre) > code {
font-size: .875em;
border: 1px solid;
border-radius: theme("spacing.1");
border-color: theme("colors.gray.light.300");
.dark & {
background: theme("colors.gray.dark.200");
border-color: theme("colors.gray.dark.300");
}
}

.highlight {
@apply p-3 my-4 overflow-x-auto;
background: theme("colors.white");
}

:not(pre) > code {
background: theme("colors.gray.light.200");
display: inline-block;
margin: 0;
white-space: nowrap;
font-weight: 400;
padding: 0 4px;
}

.chroma {
/* LineTableTD */
.lntd {
Expand Down Expand Up @@ -380,6 +378,7 @@
}
/* GenericPrompt */
.gp {
user-select: none;
color: #8f5902;
}
/* GenericStrong */
Expand Down
4 changes: 2 additions & 2 deletions assets/css/tables.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.prose table {
@apply block overflow-x-auto;
@apply block overflow-x-auto text-base;
thead tr {
@apply bg-gray-light-300 dark:bg-gray-dark-300
}
tbody tr:nth-of-type(2n) {
@apply bg-gray-light-200 dark:bg-gray-dark-200
}
th, td {
@apply p-2 !important;
@apply p-2;
}
}
3 changes: 3 additions & 0 deletions assets/css/typography.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.prose {
li {
@apply mt-1 mb-1;
& > :first-child, & > :last-child {
@apply m-0;
}
}
a {
font-weight: 400;
Expand Down
10 changes: 10 additions & 0 deletions assets/js/src/vars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const codeblocks = document.querySelectorAll(".highlight")

for (const codeblock of codeblocks) {
codeblock.innerHTML = codeblock.innerHTML
.replaceAll(
/<([A-Z_]+)>/g,
`<var class="text-violet-light dark:text-violet-dark"
>$1</var>`
)
}
5 changes: 2 additions & 3 deletions content/language/rust/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ toc_max: 2

The Rust language-specific guide teaches you how to create a containerized Rust application using Docker. In this guide, you'll learn how to:

* Create a sample Rust application
* Create a new Dockerfile which contains instructions required to build a Rust image
* Containerize a Rust application
* Build an image and run the newly built image as a container
* Set up volumes and networking
* Orchestrate containers using Compose
* Use containers for development
* Configure a CI/CD pipeline for your application using GitHub Actions
* Deploy your application to the cloud
* Deploy your containerized Rust application locally to Kubernetes to test and debug your deployment

After completing the Rust modules, you should be able to containerize your own Rust application based on the examples and instructions provided in this guide.

Expand Down
122 changes: 117 additions & 5 deletions content/language/rust/configure-ci-cd.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,128 @@ keywords: rust, CI/CD, local, development
description: Learn how to Configure CI/CD for your application
---

## Get started with GitHub Actions
## Prerequisites

{{< include "gha-tutorial.md" >}}
Complete the previous sections of this guide, starting with [Develop your Rust application](develop.md). You must have a [GitHub](https://github.com/signup) account and a [Docker](https://hub.docker.com/signup) account to complete this section.

## Overview

In this section, you'll learn how to set up and use GitHub Actions to build and push your Docker image to Docker Hub. You will complete the following steps:

1. Create a new repository on GitHub.
2. Define the GitHub Actions workflow.
3. Run the workflow.

## Step one: Create the repository

Create a GitHub repository, configure the Docker Hub secrets, and push your source code.

1. [Create a new repository](https://github.com/new) on GitHub.

2. Open the repository **Settings**, and go to **Secrets and variables** >
**Actions**.

3. Create a new secret named `DOCKER_USERNAME` and your Docker ID as value.

4. Create a new [Personal Access Token (PAT)](../../security/for-developers/access-tokens.md/#create-an-access-token) for Docker Hub. You can name this token `rust-docker`.

5. Add the PAT as a second secret in your GitHub repository, with the name
`DOCKERHUB_TOKEN`.

6. In your local repository on your machine, run the following command to change
the origin to the repository you just created. Make sure you change
`your-username` to your GitHub username and `your-repository` to the name of
the repository you created.

```console
$ git remote set-url origin https://github.com/your-username/your-repository.git
```

7. Run the following commands to stage, commit, and push your local repository to GitHub.

```console
$ git add -A
$ git commit -m "my commit"
$ git push -u origin main
```

## Step two: Set up the workflow

Set up your GitHub Actions workflow for building, testing, and pushing the image
to Docker Hub.

1. Go to your repository on GitHub and then select the **Actions** tab.

2. Select **set up a workflow yourself**.

This takes you to a page for creating a new GitHub actions workflow file in
your repository, under `.github/workflows/main.yml` by default.

3. In the editor window, copy and paste the following YAML configuration.

```yaml
name: ci
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest
```

For more information about the YAML syntax used here, see [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions).

## Step three: Run the workflow

Save the workflow file and run the job.

1. Select **Commit changes...** and push the changes to the `main` branch.

After pushing the commit, the workflow starts automatically.

2. Go to the **Actions** tab. It displays the workflow.

Selecting the workflow shows you the breakdown of all the steps.

3. When the workflow is complete, go to your
[repositories on Docker Hub](https://hub.docker.com/repositories).

If you see the new repository in that list, it means the GitHub Actions
successfully pushed the image to Docker Hub.

## Summary

In this section, you have learned how to set up GitHub Actions workflow to an existing Docker project, optimize your workflow to improve build times and reduce the number of pull requests, and finally, you learned how to push only specific versions to Docker Hub. You can also set up nightly tests against the latest tag, test each PR, or do something more elegant with the tags you are using and make use of the Git tag for the same tag in your image.
In this section, you learned how to set up a GitHub Actions workflow for your Rust application.

Related information:
- [Introduction to GitHub Actions](../../build/ci/github-actions/index.md)
- [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)

## Next steps

Next, learn how you can deploy your application.
Next, learn how you can locally test and debug your workloads on Kubernetes before deploying.

{{< button text="Deploy your app" url="deploy.md" >}}
{{< button text="Test your deployment" url="./deploy.md" >}}
Loading

0 comments on commit de9dec0

Please sign in to comment.