-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> * Update README.md Co-authored-by: Toby Scott <[email protected]> * Update README.md Co-authored-by: Toby Scott <[email protected]> * Update README.md Co-authored-by: Toby Scott <[email protected]> * Update README.md Co-authored-by: Toby Scott <[email protected]> * Update README.md Co-authored-by: Toby Scott <[email protected]> * Update Dockerfile --------- Co-authored-by: Toby Scott <[email protected]>
- Loading branch information
1 parent
5d23a7e
commit 0b2d6a9
Showing
5 changed files
with
111 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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,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 |
This file contains 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,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' |
This file contains 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,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" | ||
] | ||
} |
This file contains 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,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 |
This file contains 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 |
---|---|---|
@@ -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 |