Skip to content

Commit e1a0f55

Browse files
committed
What’s Next?
1 parent 2aec573 commit e1a0f55

16 files changed

Lines changed: 314 additions & 14 deletions

File tree

‎content/en/labs/a8.whats-next.md‎

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
---
2+
title: What's Next?
3+
slug: whats-next
4+
---
5+
6+
## Improve Development Environment
7+
8+
> [!assignment]
9+
> Add missing files like `.dockerignore`, tests, validations for pagination, search filters for the list endpoint, and maybe add a new binary application to import books from a CSV file...
10+
11+
### Development `Dockerfile`
12+
13+
Add a new file `book_service/Dockerfile`.
14+
15+
```dockerfile
16+
FROM rust:1.97-slim
17+
WORKDIR /build/crates/book_service
18+
19+
ENV CARGO_TARGET_DIR=/build/target
20+
21+
RUN mkdir -p /service
22+
23+
RUN --mount=type=bind,source=src,target=src \
24+
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
25+
--mount=type=bind,from=workspace_root,source=Cargo.lock,target=/build/Cargo.lock \
26+
--mount=type=bind,from=workspace_root,source=Cargo.toml,target=/build/Cargo.toml \
27+
--mount=type=bind,source=toasty,target=toasty \
28+
--mount=type=bind,source=Toasty.toml,target=Toasty.toml \
29+
--mount=type=cache,target=/build/target/ \
30+
--mount=type=cache,target=/usr/local/cargo/registry/ \
31+
<<EOF
32+
set -e
33+
cargo build --locked --release
34+
cp /build/target/release/app /service/app
35+
cp /build/target/release/migration /service/migration
36+
cp -r ./toasty /service/toasty/
37+
cp ./Toasty.toml /service/Toasty.toml
38+
EOF
39+
40+
WORKDIR /service
41+
CMD ["/service/app"]
42+
43+
EXPOSE 3000
44+
```
45+
46+
### Update `compose.yml`
47+
48+
Update `book_service/compose.yml`.
49+
50+
```yaml
51+
services:
52+
app:
53+
image: book-service-app
54+
env_file: .env
55+
build:
56+
context: .
57+
dockerfile: Dockerfile
58+
additional_contexts:
59+
workspace_root: ../..
60+
depends_on:
61+
db:
62+
condition: service_healthy
63+
ports:
64+
- "3000:3000"
65+
command: [ "sh", "-c", "/service/migration migration apply && /service/app" ]
66+
restart: always
67+
68+
# db
69+
```
70+
71+
## Improve for Production
72+
73+
### Production `Dockerfile`
74+
75+
Add a new file `book_service/prod.Dockerfile`.
76+
77+
```dockerfile
78+
FROM rust:1.97-slim AS builder
79+
80+
ARG CARGO_BUILD_TARGET=aarch64-unknown-linux-musl
81+
82+
RUN apt-get update && apt-get install -y --no-install-recommends \
83+
build-essential musl-tools && rm -rf /var/lib/apt/lists/*
84+
85+
RUN rustup target add ${CARGO_BUILD_TARGET}
86+
87+
WORKDIR /build/crates/book_service
88+
89+
ENV CARGO_TARGET_DIR=/build/target \
90+
CARGO_BUILD_TARGET=${CARGO_BUILD_TARGET}
91+
92+
RUN mkdir -p /service
93+
94+
RUN --mount=type=bind,source=src,target=src \
95+
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \
96+
--mount=type=bind,from=workspace_root,source=Cargo.lock,target=/build/Cargo.lock \
97+
--mount=type=bind,from=workspace_root,source=Cargo.toml,target=/build/Cargo.toml \
98+
--mount=type=bind,source=toasty,target=toasty \
99+
--mount=type=bind,source=Toasty.toml,target=Toasty.toml \
100+
--mount=type=cache,target=/build/target/ \
101+
--mount=type=cache,target=/usr/local/cargo/registry/ \
102+
<<EOF
103+
set -e
104+
cargo build --locked --release
105+
cp /build/target/${CARGO_BUILD_TARGET}/release/app /service/app
106+
cp /build/target/${CARGO_BUILD_TARGET}/release/migration /service/migration
107+
cp -r ./toasty /service/toasty/
108+
cp ./Toasty.toml /service/Toasty.toml
109+
EOF
110+
111+
# ==============================================================================
112+
FROM gcr.io/distroless/static-debian13:nonroot
113+
WORKDIR /service
114+
115+
COPY --from=builder /service/app /service/app
116+
COPY --from=builder /service/migration /service/migration
117+
COPY --from=builder /service/Toasty.toml /service/Toasty.toml
118+
COPY --from=builder /service/toasty /service/toasty/
119+
120+
CMD ["/service/app"]
121+
```
122+
123+
### Add `mimalloc`
124+
125+
Run `cargo add mimalloc` from the book_service folder. Then update `book_service/src/bin/app.rs`.
126+
127+
```rust
128+
use book_service::{AppConf, AppState, models::*, routes};
129+
use mimalloc::MiMalloc;
130+
use tracing::info;
131+
use tracing_subscriber::{EnvFilter, layer::SubscriberExt, util::SubscriberInitExt};
132+
133+
#[global_allocator]
134+
static GLOBAL: MiMalloc = MiMalloc;
135+
136+
#[tokio::main]
137+
```

‎data/en/labs/sidebar.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
- title: Database and DB Migrations
1111
- title: Routes and Error Responses
1212
- title: Form Validation
13-
- title: OpenAPI Specification
13+
- title: OpenAPI Specification
14+
- title: What's Next?

‎docs/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!doctype html><html lang=en-US><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="Rust Programming Language Tutorials for Everyone!"><meta name=author content="Dumindu Madunuwan"><meta name=theme-color content="#ffffff" media="(prefers-color-scheme: light)"><meta name=theme-color content="#101010" media="(prefers-color-scheme: dark)"><title>Learning Rust · Rust Programming Language Tutorials for Everyone!</title><link rel=canonical href=https://learning-rust.github.io/><link rel=stylesheet href=/assets/css/home.min.2f64b534694f7783ee00c07c45f130ef260d59af33aefe9e41a6606a53c5de38.css integrity><link href=https://learning-rust.github.io/pagefind/pagefind-component-ui.css rel=stylesheet><link rel=manifest href=/manifest.json><link rel=icon href=/favicon/favicon.ico><link rel=icon href=/favicon/favicon-16x16.png sizes=16x16 type=image/png><link rel=icon href=/favicon/favicon-32x32.png sizes=32x32 type=image/png><link rel=apple-touch-icon href=/favicon/apple-touch-icon.png sizes=180x180><script async src="https://www.googletagmanager.com/gtag/js?id=G-FZHQCXSZ89"></script><script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag("js",new Date),gtag("config","G-FZHQCXSZ89")</script><meta property="og:title" content="Learning Rust"><meta property="og:description" content="Learning Rust - Rust Programming Language Tutorials for Everyone!"><meta property="og:type" content="article"><meta property="og:url" content="https://learning-rust.github.io/"><meta property="og:image" content="https://learning-rust.github.io/og.jpg"><meta property="og:site_name" content="Learning Rust"><meta name=twitter:card content="summary_large_image"><meta name=twitter:title content="Learning Rust"><meta name=twitter:description content="Learning Rust - Rust Programming Language Tutorials for Everyone!"><meta name=twitter:image content="https://learning-rust.github.io/og.jpg"><script type=application/ld+json>{"@context":"https://schema.org","@type":"Article","headline":"Learning Rust","description":"Learning Rust - Rust Programming Language Tutorials for Everyone!","image":"https:\/\/learning-rust.github.io\/og.jpg","author":{"@type":"Person","name":"Dumindu Madunuwan","url":"https:\/\/github.com\/dumindu"},"publisher":{"@type":"Organization","name":"Learning Rust","logo":{"@type":"ImageObject","url":"https:\/\/learning-rust.github.io\/"}},"dateModified":"2026-08-18T14:17:40Z","mainEntityOfPage":{"@type":"WebPage","@id":"https:\/\/learning-rust.github.io\/"}}</script></head><body><div id=content-wrapper><header id=site-header><div id=site-header-logo><a href=https://learning-rust.github.io/><img height=52px src=https://learning-rust.github.io/logo.svg alt="Site Logo"></a></div><div id=site-header-actions><div id=search-box><pagefind-modal-trigger compact=true></pagefind-modal-trigger><pagefind-modal></pagefind-modal></div><div id=theme-dropdown class=dropdown><button class=dropdown-btn aria-haspopup=menu aria-label="Select the theme">
1+
<!doctype html><html lang=en-US><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="Rust Programming Language Tutorials for Everyone!"><meta name=author content="Dumindu Madunuwan"><meta name=theme-color content="#ffffff" media="(prefers-color-scheme: light)"><meta name=theme-color content="#101010" media="(prefers-color-scheme: dark)"><title>Learning Rust · Rust Programming Language Tutorials for Everyone!</title><link rel=canonical href=https://learning-rust.github.io/><link rel=stylesheet href=/assets/css/home.min.2f64b534694f7783ee00c07c45f130ef260d59af33aefe9e41a6606a53c5de38.css integrity><link href=https://learning-rust.github.io/pagefind/pagefind-component-ui.css rel=stylesheet><link rel=manifest href=/manifest.json><link rel=icon href=/favicon/favicon.ico><link rel=icon href=/favicon/favicon-16x16.png sizes=16x16 type=image/png><link rel=icon href=/favicon/favicon-32x32.png sizes=32x32 type=image/png><link rel=apple-touch-icon href=/favicon/apple-touch-icon.png sizes=180x180><script async src="https://www.googletagmanager.com/gtag/js?id=G-FZHQCXSZ89"></script><script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag("js",new Date),gtag("config","G-FZHQCXSZ89")</script><meta property="og:title" content="Learning Rust"><meta property="og:description" content="Learning Rust - Rust Programming Language Tutorials for Everyone!"><meta property="og:type" content="article"><meta property="og:url" content="https://learning-rust.github.io/"><meta property="og:image" content="https://learning-rust.github.io/og.jpg"><meta property="og:site_name" content="Learning Rust"><meta name=twitter:card content="summary_large_image"><meta name=twitter:title content="Learning Rust"><meta name=twitter:description content="Learning Rust - Rust Programming Language Tutorials for Everyone!"><meta name=twitter:image content="https://learning-rust.github.io/og.jpg"><script type=application/ld+json>{"@context":"https://schema.org","@type":"Article","headline":"Learning Rust","description":"Learning Rust - Rust Programming Language Tutorials for Everyone!","image":"https:\/\/learning-rust.github.io\/og.jpg","author":{"@type":"Person","name":"Dumindu Madunuwan","url":"https:\/\/github.com\/dumindu"},"publisher":{"@type":"Organization","name":"Learning Rust","logo":{"@type":"ImageObject","url":"https:\/\/learning-rust.github.io\/"}},"dateModified":"2026-08-18T20:02:39Z","mainEntityOfPage":{"@type":"WebPage","@id":"https:\/\/learning-rust.github.io\/"}}</script></head><body><div id=content-wrapper><header id=site-header><div id=site-header-logo><a href=https://learning-rust.github.io/><img height=52px src=https://learning-rust.github.io/logo.svg alt="Site Logo"></a></div><div id=site-header-actions><div id=search-box><pagefind-modal-trigger compact=true></pagefind-modal-trigger><pagefind-modal></pagefind-modal></div><div id=theme-dropdown class=dropdown><button class=dropdown-btn aria-haspopup=menu aria-label="Select the theme">
22
<span><svg class="icon" height="20" viewBox="0 -960 960 960" width="20"><path d="M480-96q-79 0-149-30t-122.5-82.5T126-331 96-480q0-80 30.5-149.5t84-122 125-82.5T488-864q78 0 146.5 27T754-763t80.5 110T864-518q0 96-67 163t-163 67h-68q-8 0-14 5t-6 13q0 15 15 25t15 53q0 37-27 66.5T480-96zm0-384zm-173.5 18.5Q324-479 324-504t-17.5-42.5T264-564t-42.5 17.5T204-504t17.5 42.5T264-444t42.5-17.5zm120-144Q444-623 444-648t-17.5-42.5T384-708t-42.5 17.5T324-648t17.5 42.5T384-588t42.5-17.5zm192 0Q636-623 636-648t-17.5-42.5T576-708t-42.5 17.5T516-648t17.5 42.5T576-588t42.5-17.5zm120 144Q756-479 756-504t-17.5-42.5T696-564t-42.5 17.5T636-504t17.5 42.5T696-444t42.5-17.5zM480-168q11 0 17.5-8.5T504-192q0-16-15-28t-15-50 26.5-64 64.5-26h69q66 0 112-46t46-112q0-115-88.5-194.5T488-792q-134 0-227 91t-93 221 91 221 221 91z"/></svg>
33
</span><span><svg class="icon" height="20" viewBox="0 -960 960 960" width="20"><path d="m480-246 85.91-85.91Q577-343 591.5-343t25.5 11 11 25.5-10.93 25.43L505-169q-5.4 5-11.7 7.5t-13.5 2.5-13.5-2.5T455-169L342.93-281.07Q332-292 332.5-306.5T344-332t25.5-11 25.47 11.09L480-246zm0-468-85.91 85.91Q383-617 368.5-617T343-628t-11-25.5 10.93-25.43L455-791q5.4-5 11.7-7.5t13.5-2.5 13.5 2.5T505-791l112.07 112.07Q628-668 628-654t-11 25-25.5 11-25.59-10.97L480-714z"/></svg></span></button><ul role=menu class=dropdown-menu><li role=menuitem><button title=Light class=color-scheme data-value=light style=background:#fff;color:#000>
44
<span style=color:#000>Aa</span></button></li><li role=menuitem><button title=dark class=color-scheme data-value=dark style=background:#101010;color:#fff>

‎docs/index.xml‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,25 @@ explicit panic&lt;/code&gt;&lt;/pre&gt;
14301430
&lt;/span&gt;
14311431
&lt;/div&gt;
14321432
&lt;div class="alert-body"&gt;
1433-
&lt;p&gt;We&amp;rsquo;ll discuss this in the &lt;a href="https://learning-rust.github.io/docs/vectors/#length-and-capacity" &gt;Length and Capacity&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Why Rust?</title><link>https://learning-rust.github.io/docs/why-rust/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learning-rust.github.io/docs/why-rust/</guid><description>&lt;h2 id="history-of-rust"&gt;History of Rust&lt;/h2&gt;
1433+
&lt;p&gt;We&amp;rsquo;ll discuss this in the &lt;a href="https://learning-rust.github.io/docs/vectors/#length-and-capacity" &gt;Length and Capacity&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>What's Next?</title><link>https://learning-rust.github.io/labs/whats-next/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learning-rust.github.io/labs/whats-next/</guid><description>&lt;h2 id="improve-development-environment"&gt;Improve Development Environment&lt;/h2&gt;
1434+
1435+
1436+
&lt;div class="alert alert-assignment"&gt;
1437+
&lt;div class="alert-header"&gt;
1438+
1439+
1440+
1441+
&lt;svg xmlns="http://www.w3.org/2000/svg" height="20px" viewBox="0 -960 960 960" width="20px"&gt;&lt;path d="M216-144q-29.7 0-50.85-21.15Q144-186.3 144-216v-528q0-29.7 21.15-50.85Q186.3-816 216-816h171q8-31 33.5-51.5T480-888q34 0 59.5 20.5T573-816h171q29.7 0 50.85 21.15Q816-773.7 816-744v528q0 29.7-21.15 50.85Q773.7-144 744-144H216Zm0-72h528v-528H216v528Zm108-72h216q15.3 0 25.65-10.29Q576-308.58 576-323.79t-10.35-25.71Q555.3-360 540-360H324q-15.3 0-25.65 10.29Q288-339.42 288-324.21t10.35 25.71Q308.7-288 324-288Zm0-156h312q15.3 0 25.65-10.29Q672-464.58 672-479.79t-10.35-25.71Q651.3-516 636-516H324q-15.3 0-25.65 10.29Q288-495.42 288-480.21t10.35 25.71Q308.7-444 324-444Zm0-156h312q15.3 0 25.65-10.29Q672-620.58 672-635.79t-10.35-25.71Q651.3-672 636-672H324q-15.3 0-25.65 10.29Q288-651.42 288-636.21t10.35 25.71Q308.7-600 324-600Zm173-175q7-7 7-17t-7-17q-7-7-17-7t-17 7q-7 7-7 17t7 17q7 7 17 7t17-7ZM216-216v-528 528Z"/&gt;&lt;/svg&gt;
1442+
1443+
1444+
&lt;span&gt;
1445+
1446+
Assignment
1447+
1448+
&lt;/span&gt;
1449+
&lt;/div&gt;
1450+
&lt;div class="alert-body"&gt;
1451+
&lt;p&gt;Add missing files like &lt;code&gt;.dockerignore&lt;/code&gt;, tests, validations for pagination, search filters for the list endpoint, and maybe add a new binary application to import books from a CSV file&amp;hellip;&lt;/p&gt;</description></item><item><title>Why Rust?</title><link>https://learning-rust.github.io/docs/why-rust/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learning-rust.github.io/docs/why-rust/</guid><description>&lt;h2 id="history-of-rust"&gt;History of Rust&lt;/h2&gt;
14341452
&lt;p&gt;Rust was initially designed and developed by former Mozilla employee &lt;strong&gt;&lt;a href="https://github.com/graydon" target="_blank" &gt;Graydon Hoare&lt;/a&gt;&lt;/strong&gt; as a personal project. Mozilla began sponsoring the project in 2009 and announced it in 2010. But the first stable release, Rust 1.0, was released on May 15, 2015.&lt;/p&gt;
14351453
&lt;p&gt;Since Rust 1.0, major updates have been released as &lt;a href="https://learning-rust.github.io/docs/cargo-crates-and-basic-project-structure/#rust-editions" &gt;&lt;code&gt;Editions&lt;/code&gt;&lt;/a&gt; approximately every three years: Rust 2015 (with the release of Rust 1.0) , Rust 2018, Rust 2021, and Rust 2024, all maintaining backward compatibility.&lt;/p&gt;</description></item><item><title>Workspaces</title><link>https://learning-rust.github.io/docs/workspaces/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://learning-rust.github.io/docs/workspaces/</guid><description>&lt;h2 id="rust-workspaces"&gt;Rust Workspaces&lt;/h2&gt;
14361454
&lt;ul&gt;

0 commit comments

Comments
 (0)