Skip to content

Commit 18c5b38

Browse files
authored
Merge pull request #201 from flux-framework/add/devcontainer
add basic dev container to run flux and generate docs alongside
2 parents fc2bcb8 + fea6a78 commit 18c5b38

File tree

4 files changed

+102
-0
lines changed

4 files changed

+102
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM fluxrm/flux-sched:focal
2+
3+
LABEL maintainer="Vanessasaurus <@vsoch>"
4+
5+
# Pip not provided in this version
6+
USER root
7+
RUN apt-get update && apt-get install -y python3-venv
8+
COPY ./requirements.txt /requirements.txt
9+
COPY ./.github/dev-requirements.txt /dev-requirements.txt
10+
11+
ENV PYTHONPATH=/usr/lib/flux/python3.8
12+
13+
# For easier Python development.
14+
RUN python3 -m pip install IPython && \
15+
python3 -m pip install -r /requirements.txt && \
16+
python3 -m pip install -r /dev-requirements.txt
17+
18+
ENV PATH=/env/bin:${PATH}

.devcontainer/devcontainer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "Flux Core Python 3.6",
3+
"dockerFile": "Dockerfile",
4+
"context": "../",
5+
"customizations": {
6+
"vscode": {
7+
"settings": {
8+
"terminal.integrated.defaultProfile.linux": "bash",
9+
10+
// Ensure that Python autocomplete works out of the box
11+
"python.autoComplete.extraPaths": [
12+
"/usr/lib/flux/python3.8",
13+
"/usr/lib/python3.8/site-packages",
14+
],
15+
"python.analysis.extraPaths": [
16+
"/usr/lib/flux/python3.8",
17+
"/usr/lib/python3.8/site-packages",
18+
]
19+
},
20+
// Note to Flux Developers! We can add extensions here that you like
21+
"extensions": [
22+
"ms-python.python"
23+
],
24+
},
25+
},
26+
// Needed for git security feature
27+
"postStartCommand": "git config --global --add safe.directory /workspaces/flux-docs"
28+
}

.github/dev-requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pre-commit
2+
black
3+
isort
4+
flake8
5+
pytest
6+
cffi

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,56 @@ Edits should be made to the `.rst` files.
44
The documentation can be built with `make html` or `make man`.
55
The generated files will be found in the `_build` directory.
66

7+
## VSCode Development Container
8+
9+
We provide a VSCode [Development Container](https://code.visualstudio.com/docs/remote/containers)
10+
to provide an environment for you to easily work on the documentation, and ensure that Flux
11+
is installed to generate some of our Sphinx Gallery (TBA) tutorials. This works by way
12+
of the assets in [.devcontainer](https://code.visualstudio.com/docs/remote/containers#_create-a-devcontainerjson-file).
13+
14+
### Setup
15+
16+
You can follow the [tutorial](https://code.visualstudio.com/docs/remote/containers-tutorial) where you'll basically
17+
need to:
18+
19+
1. Install Docker
20+
2. Install the [Development Containers](vscode:extension/ms-vscode-remote.remote-containers) extension
21+
22+
Then you can go to the command palette (View -> Command Palette) and select `Dev Containers: Open Workspace in Container.`
23+
and select your cloned Flux Docs repository root. This will build a development environment from [fluxrm/flux-sched](https://hub.docker.com/r/fluxrm/flux-sched/tags).
24+
25+
While this uses the focal base, you are free to change the base image and rebuild if you need to test on another operating system!
26+
When your container is built, when you open `Terminal -> New Terminal` and you'll be in the container!
27+
You should be able to build docs:
28+
29+
```bash
30+
$ make html
31+
```
32+
33+
And then you can do as you would do on your host to start a local webserver:
34+
35+
```console
36+
..
37+
The HTML pages are in _build/html.
38+
39+
$ cd _build/html/
40+
$ python3 -m http.server 9999
41+
Serving HTTP on 0.0.0.0 port 9999 (http://0.0.0.0:9999/) ...
42+
```
43+
VSCode is smart enough to see you open the port and give you a button to click to open it in
44+
the browser! If not, you can open your browser to [http://localhost:9999/](http://localhost:9999/).
45+
We will provide further instructions here for building sphinx examples as they are added.
46+
47+
**Important** it's recommended that you commit (or otherwise write to the .git folder) from the outside
48+
of the container. This will allow you to sign commits with your (not mounted to the container) key,
49+
and will ensure the permissions of the commit are not done by a root user.
50+
If you accidentally do this and need to fix, you can run this from your terminal outside of VSCode:
51+
52+
```bash
53+
$ sudo chown -R $USER .git/
54+
# and then commit
55+
```
56+
757
## Installing Sphinx
858

959
Sphinx is used to generate man pages from the `.rst` files.

0 commit comments

Comments
 (0)