Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: docker container #203

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

harmw
Copy link

@harmw harmw commented Aug 19, 2024

This puts the entire book in a docker container, which is useful for those wanting to start their Rust journey in moments of limited to no internet connectivity ✈️

It also makes it possible to start learning (with the book) without needing to build this project first, which on my Mac was quite the trouble.

It builds on amd64, seems aarch64 is not possible (yet) as some of the required dependencies are not available in the required target architecture.

Minor note: I'm not using depot but volta to manage the nodejs stuff, as I found that to be simpler and closer to home.

@harmw
Copy link
Author

harmw commented Aug 20, 2024

@willcrichton please let me know what you think 👍🏻

&& apt install -y rustup curl wget gcc git nginx \
&& chown -R ubuntu /opt/rust-book

USER ubuntu
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why run all these commands as ubuntu rather than root?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly just to be the same uid as when the container runs and file permissions are thus properly set

&& mdbook-quiz --version \
&& mdbook-aquascope --version

RUN echo \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the echo \?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Readability, this way all commands line up nicely (personal preference)

@willcrichton
Copy link
Collaborator

Thanks @harmw! It's great to have a Docker build for people who want the latest version. Fwiw, for people who just want an offline version of the book, it's probably simpler to just clone the latest build:

git clone https://github.com/cognitive-engineering-lab/rust-book -b gh-pages --depth 1

But it's nice to have a Docker image too.

@harmw
Copy link
Author

harmw commented Aug 20, 2024 via email

@harmw
Copy link
Author

harmw commented Aug 26, 2024

@willcrichton did a quick check and running from gh-pages throws errors in safari; mainly access-control-allow-origin and cors. Haven't looked into some quick fix though 😅

@willcrichton
Copy link
Collaborator

willcrichton commented Aug 26, 2024

@harmw you will need to serve the book through a local file server rather than a file:// URL. For example:

python3 -m http.server &
open http://localhost:8000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants