Skip to content
This repository has been archived by the owner on Nov 13, 2022. It is now read-only.

Latest commit

 

History

History
115 lines (77 loc) · 4.61 KB

DEVELOPMENT.md

File metadata and controls

115 lines (77 loc) · 4.61 KB

Development Guide

You can run your fastpages blog on your local machine, and view any changes you make to your posts, including Jupyter Notebooks and Word documents, live. The live preview requires that you have Docker installed on your machine. Follow the instructions on this page if you need to install Docker.

Seeing All Commands In The Terminal

There are many different docker-compose commands that are necessary to manage the lifecycle of the fastpages Docker containers. To make this easier, we aliased common commands in a Makefile.

You can quickly see all available commands by running this command in the root of your repository:

make

Basic usage: viewing your blog

All of the commands in this block assume that you're in your blog root directory. To run the blog with live preview:

make server

When you run this command for the first time, it'll build the required Docker images, and the process might take a couple minutes.

This command will build all the necessary containers and run the following services:

  1. A service that monitors any changes in ./_notebooks/*.ipynb/ and ./_word/*.docx;*.doc and rebuild the blog on change.
  2. A Jupyter Notebook server — use this to write and edit your posts. You must see your terminal logs to find the link, which will start with https://127.0.0.1:8888
  3. A Jekyll server on https://127.0.0.1:4000 — use this to preview your blog.

The services will output to your terminal. If you close the terminal or hit Ctrl-C, the services will stop. If you want to run the services in the background:

# run all services in the background
make server-detached

# stop the services
make stop

If you need to restart just the Jekyll server, and it's running in the background — you can do make restart-jekyll.

Note that the blog won't autoreload on change, you'll have to refresh your browser manually.

If containers won't start: try make build first, this would rebuild all the containers from scratch, This might fix the majority of update problems.

To get the Jupyter Notebook Token: look for the Jupyter Notebook link in the output log of make server command, it'll post the link with the token param in it. If you're running containers in background, you can get the token by running the following command:

# assuming you're running containers in background with docker-compose up -d
# attach to bash in jupyter container
make bash-nb

# get notebook list & token
jupyter notebook list

Converting the pages locally

If you just want to convert your notebooks and word documents to .md posts in _posts, this command will do it for you:

make convert

You can launch just the jekyll server with make server.

Visual Studio Code integration

If you're using VSCode with the Docker extension, you can run three containers from the sidebar: fastpages_jupyter_1,fastpages_watcher_1, and fastpages_jekyll_1. The containers will only show up in the list after you run or build them for the first time. So if they're not in the list — try make build in the console.

Advanced usage

Rebuild all the containers

If you changed files in _action_files directory, you might need to rebuild the containers manually, without cache.

make build

Removing all the containers

Want to start from scratch and remove all the containers?

make remove

Attaching a shell to a container

You can attach a terminal to a running service:

# If the container is already running:

# attach to a bash shell in the jekyll service
make bash-jekyll

# attach to a bash shell in the jupyter / watcher service.
# they're essentially running the same software inside.
make bash-nb

Note: you can use docker-compose run instead of make bash-nb or make bash-jekyll to start a service and then attach to it. Or you can run all your services in the background, make server-detached, and then use make bash-nb or make bash-jekyll as in the examples above.