Skip to content

Commit

Permalink
Switch localhost setup to vscode dev containers & update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
bill-c-martin committed Nov 11, 2022
1 parent 400ed0b commit cfece2f
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 11 deletions.
26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "Jekyll",
"image": "mcr.microsoft.com/devcontainers/jekyll:0-buster",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "latest"
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
// Jekyll server
4000,
// Live reload server
35729
],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "sh .devcontainer/post-create.sh"

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
22 changes: 22 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

# Install the version of Bundler.
if [ -f Gemfile.lock ] && grep "BUNDLED WITH" Gemfile.lock > /dev/null; then
cat Gemfile.lock | tail -n 2 | grep -C2 "BUNDLED WITH" | tail -n 1 | xargs sudo gem install bundler -v
fi

# If there's a Gemfile, then run `bundle install`
# It's assumed that the Gemfile will install Jekyll too
if [ -f Gemfile ]; then
bundle install
fi

yellow=$(tput setaf 3)
normal=$(tput sgr0)

printf "\n"
printf "%40s\n" "${yellow}********************************************************************************"
printf "%40s\n" "Don't forget to start the server after pressing any key to continue:"
printf "%40s\n" "bundle exec jekyll serve"
printf "%40s\n" "********************************************************************************${normal}"
printf "\n"
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Demo: [bill-c-martin.github.com](https://bill-c-martin.github.io)

Requires no servers or hosting, and runs straight from your GitHub repo.
Requires no servers or hosting, and runs straight from your GitHub repo on GitHub Pages.

## Quick Setup

Expand All @@ -12,26 +12,37 @@ Requires no servers or hosting, and runs straight from your GitHub repo.

## Localhost Setup

1. Clone the above repo, which you forked, to your localhost
2. Install `ruby-2.7` and `rubygems-2.7`. Despite what [Jekyll's docs say](https://jekyllrb.com/docs/installation/), you have to install Ruby `2.7.*`, otherwise you will get a [pathutil error](https://stackoverflow.com/questions/65539326/is-the-pathutil-ruby-gem-compatible-with-jekyll-v3-9-0-and-ruby-v3-0-0) in the next step.
Localhost setup uses VS Code Dev Containers.

3. Install jekyll packages inside this repo:
> **Note**
> If you don't want to use Docker or VS Code, [an older version of this README](https://github.com/bill-c-martin/bill-c-martin.github.io/blob/c8ff940d5b8776e1cc6fa9b906c066f06da580a5/README.md) has manual ruby & gem installation instructions.
```bash
cd /path/to/your-github-username.github.io/
gem install jekyll bundler
bundle-2.7 install
```
### Prerequisites

- Docker (For Windows, also install: wsl, Ubuntu, and Docker Desktop)
- VS Code
- VS Code extensions:
- Dev Containers
- Markdown All in One (recommended)
- GitHub Markdown Preview (recommended)
- markdownlint (recommended)

### Instructions

1. Clone the above repo, which you forked, to your localhost
2. Open the repo in VS Code and click the "Reopen in Container" button that pops up
> **Note:**
> Or run `Dev Containers: Open Folder in Container...` in the command palette (`Ctrl+Shift+P`)
3. When the container is done provisioning, hit any key to continue
4. Start the web server:

```bash
bundle-2.7 exec jekyll serve
bundle exec jekyll serve
```

5. Go to [http://localhost:4000](http://localhost:4000) and verify it runs locally.

The localhost site will show changes in real time.
The localhost site will show changes in real-time.

If you modify `_config.yml` though, you'll need to `ctrl+c` and restart the web server.

Expand Down

0 comments on commit cfece2f

Please sign in to comment.