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:
Jedd Dryden
2024-02-14 10:06:42 +11:00
committed by GitHub
parent 5d23a7e35a
commit 0b2d6a9c23
5 changed files with 111 additions and 8 deletions

12
.devcontainer/Dockerfile Normal file
View 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
View 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'

View 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"
]
}

View 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

View File

@@ -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 ```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. 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.
Install mdbook admonish using:
```sh ```sh
cargo install mdbook-admonish cargo install mdbook-admonish --version 1.*
``` ```
and then run the book with and then run the book with
```sh ```sh
mdbook serve 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