Skip to content

Commit c0f9d3d

Browse files
Created a Dockerfile for previewing docs locally
1 parent 5c5ab18 commit c0f9d3d

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM rocker/rstudio:latest
2+
3+
RUN apt-get update \
4+
&& apt-get install -y \
5+
libudunits2-dev \
6+
libgdal-dev
7+
8+
RUN echo "alias l='ls -al'" >> /root/.bashrc
9+
10+
RUN Rscript -e 'install.packages("blogdown")'
11+
RUN Rscript -e 'install.packages("ggplot2")'
12+
RUN Rscript -e 'install.packages("ggthemes")'
13+
RUN Rscript -e 'install.packages("reticulate")'
14+
15+
COPY . /terraref/tutorials
16+
17+
WORKDIR /terraref/tutorials
18+
19+
EXPOSE 3000
20+
21+
CMD Rscript -e 'bookdown::render_book("index.Rmd")' \
22+
&& cd docs \
23+
&& echo 'Starting a web server on http://localhost:3000/ to preview the documentation...' \
24+
&& python -m SimpleHTTPServer 3000

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,38 @@ Although we provide a few pre-configured computing environments, Workbench is de
3939
**To get started**, follow the [Workbench Quick Start](https://htmlpreview.github.io/?https://github.com/terraref/tutorials/blob/master/workbench/ndslabs_workbench_intro.html).
4040

4141
This will walk you through the process of getting started with the first tutorials on how to access data.
42+
43+
44+
## To generate this documentation locally
45+
46+
If you would like to contribute to this documentation you can preview your
47+
changes by running the following command:
48+
49+
```bash
50+
Rscript -e 'bookdown::render_book("index.Rmd")'
51+
```
52+
53+
The output will be in the `docs` folder.
54+
55+
There is also a Dockerfile for convenience. It requires installing Docker on
56+
your computer:
57+
58+
- [Docker for Mac](https://download.docker.com/mac/stable/Docker.dmg)
59+
- [Docker for Windows](https://download.docker.com/win/stable/Docker%20for%20Windows%20Installer.exe)
60+
61+
Build the image:
62+
63+
```bash
64+
docker build -t terraref-tutorials:local .
65+
```
66+
67+
Run the container:
68+
69+
```bash
70+
docker run --rm -p 3000:3000 terraref-tutorials:tutorials
71+
```
72+
73+
This will generate the documentation and start a local web server to preview
74+
your changes. Open the preview URL in your browser: <http://localhost:3000/>
75+
76+
Run `docker kill tutorial-preview` to kill the web server container.

0 commit comments

Comments
 (0)