mirror of
https://github.com/leptos-rs/book.git
synced 2025-12-27 07:35:38 -05:00
Dev Container Implementation and README.md Updates (#47)
* Implemented Dev Container * Added extra extensions * Improved `README.md` * Typo * Update .devcontainer/Dockerfile Co-authored-by: Toby Scott <hi@tobyscott.dev> * Update README.md Co-authored-by: Toby Scott <hi@tobyscott.dev> * Update README.md Co-authored-by: Toby Scott <hi@tobyscott.dev> * Update README.md Co-authored-by: Toby Scott <hi@tobyscott.dev> * Update README.md Co-authored-by: Toby Scott <hi@tobyscott.dev> * Update README.md Co-authored-by: Toby Scott <hi@tobyscott.dev> * Update Dockerfile --------- Co-authored-by: Toby Scott <hi@tobyscott.dev>
This commit is contained in:
12
.devcontainer/Dockerfile
Normal file
12
.devcontainer/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM rust:1
|
||||
|
||||
# Install MDBook and other CLI tools
|
||||
RUN rustup component add rustfmt clippy && \
|
||||
cargo install mdbook --version 0.4.* && \
|
||||
cargo install mdbook-admonish --version 1.*
|
||||
|
||||
# Tell git to trust "dubious" ownership
|
||||
RUN git config --global --add safe.directory /repository
|
||||
|
||||
# Entry directory for non-vscode containers based on this image
|
||||
WORKDIR /repository
|
||||
5
.devcontainer/book.sh
Executable file
5
.devcontainer/book.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
# This script is executed from the root of the repository in the book container.
|
||||
|
||||
# Serve the MDBook
|
||||
mdbook serve -n '0.0.0.0' -p '3000'
|
||||
40
.devcontainer/devcontainer.json
Normal file
40
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "Leptos Book",
|
||||
"dockerComposeFile": ["docker-compose.yml"],
|
||||
"service": "devcontainer",
|
||||
"workspaceFolder": "/repository",
|
||||
"shutdownAction": "stopCompose",
|
||||
"initializeCommand": "echo 'Starting devcontainer...'",
|
||||
"forwardPorts": ["book:3000"],
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
// Docker
|
||||
"ms-azuretools.vscode-docker",
|
||||
// Copilot
|
||||
"github.copilot",
|
||||
"github.copilot-chat",
|
||||
// Github
|
||||
"github.vscode-pull-request-github",
|
||||
// Prettier
|
||||
"esbenp.prettier-vscode",
|
||||
// Rust
|
||||
"rust-lang.rust-analyzer",
|
||||
"vadimcn.vscode-lldb",
|
||||
// TOML Highlighting
|
||||
"tamasfe.even-better-toml",
|
||||
// Markdown Tools
|
||||
"yzhang.markdown-all-in-one"
|
||||
],
|
||||
"settings": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true,
|
||||
"editor.formatOnPaste": true,
|
||||
"editor.tabSize": 4
|
||||
}
|
||||
}
|
||||
},
|
||||
"mounts": [
|
||||
"source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind"
|
||||
]
|
||||
}
|
||||
24
.devcontainer/docker-compose.yml
Normal file
24
.devcontainer/docker-compose.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
version: "3.8"
|
||||
|
||||
name: leptos-book
|
||||
|
||||
services:
|
||||
devcontainer:
|
||||
build:
|
||||
context: ./..
|
||||
dockerfile: .devcontainer/Dockerfile
|
||||
volumes:
|
||||
- ./..:/repository
|
||||
# VSCode needs a second to be able to attach to the container
|
||||
command: /bin/sh -c "while sleep 1000; do :; done"
|
||||
|
||||
book:
|
||||
build:
|
||||
context: ./../
|
||||
dockerfile: .devcontainer/Dockerfile
|
||||
volumes:
|
||||
- ./..:/repository
|
||||
expose:
|
||||
- 3000
|
||||
# Run the book
|
||||
command: .devcontainer/book.sh
|
||||
38
README.md
38
README.md
@@ -1,23 +1,45 @@
|
||||
This project contains the core of a new introductory guide to Leptos.
|
||||
# Leptos Book
|
||||
|
||||
It is built using `mdbook`. You can view a local copy by installing `mdbook`
|
||||
- [Leptos Book](#leptos-book)
|
||||
- [Introduction](#introduction)
|
||||
- [Building the Book](#building-the-book)
|
||||
- [Optional: VSCode Dev Container](#vscode-dev-container)
|
||||
|
||||
## Introduction
|
||||
|
||||
This project contains the core of a new introductory guide to Leptos. Pull requests for any typos, clarification, or improvements are always welcome.
|
||||
|
||||
You can find the live version of this book on the [Leptos Website](https://book.leptos.dev/).
|
||||
|
||||
## Building the Book
|
||||
|
||||
It is built using [`mdbook`](https://crates.io/crates/mdbook). You can view a local copy by installing `mdbook` with Cargo.
|
||||
|
||||
```sh
|
||||
cargo install mdbook
|
||||
cargo install mdbook --version 0.4.*
|
||||
```
|
||||
|
||||
This book also uses an mdbook preprocessor called `mdbook-admonish` to style blocks of text like notes, warnings, etc.
|
||||
|
||||
Install mdbook admonish using:
|
||||
This book also uses an mdbook preprocessor called [`mdbook-admonish`](https://crates.io/crates/mdbook-admonish) to style blocks of text like notes, warnings, etc.
|
||||
|
||||
```sh
|
||||
cargo install mdbook-admonish
|
||||
cargo install mdbook-admonish --version 1.*
|
||||
```
|
||||
|
||||
|
||||
and then run the book with
|
||||
|
||||
```sh
|
||||
mdbook serve
|
||||
```
|
||||
|
||||
It should be available at `http://localhost:3000`.
|
||||
It should now be available at [`http://localhost:3000`](http://localhost:3000).
|
||||
|
||||
## Optional: VSCode Dev Container
|
||||
|
||||
You can optionally build and run it in the example [VSCode Dev Container](https://code.visualstudio.com/docs/devcontainers/containers), which will automatically install all dependencies, build the book, and serve it at [`http://localhost:3000`](http://localhost:3000) with live reloading.
|
||||
|
||||
Install Docker and the official [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension, then open the project in VSCode and "Reopen in dev container" when prompted.
|
||||
|
||||
For more info, see: https://code.visualstudio.com/remote/advancedcontainers/use-docker-kubernetes
|
||||
|
||||
To run Docker commands inside the dev container, see: https://code.visualstudio.com/remote/advancedcontainers/use-docker-kubernetes
|
||||
|
||||
Reference in New Issue
Block a user