Skip to content

Commit

Permalink
Dev Container Implementation and README.md Updates (#47)
Browse files Browse the repository at this point in the history
* 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
Jaffa-Cakes and tobyscott25 authored Feb 13, 2024
1 parent 5d23a7e commit 0b2d6a9
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 8 deletions.
12 changes: 12 additions & 0 deletions .devcontainer/Dockerfile
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
5 changes: 5 additions & 0 deletions .devcontainer/book.sh
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'
40 changes: 40 additions & 0 deletions .devcontainer/devcontainer.json
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"
]
}
24 changes: 24 additions & 0 deletions .devcontainer/docker-compose.yml
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
38 changes: 30 additions & 8 deletions README.md
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

0 comments on commit 0b2d6a9

Please sign in to comment.