Skip to content

Explore a collection of articles where I dive into small projects and the latest tech trends. I share hands-on experiences, insights, and tutorials on emerging technologies and programming. Perfect for developers and tech enthusiasts eager to learn and innovate alongside me.

Notifications You must be signed in to change notification settings

wambitz/tech-blog

Repository files navigation

Tech Blog on GitHub pages

Create your Docker image

This will allow you to install Jekyll locally for testing and not have to worry Ruby dependencies.

docker build -t tech-blog .

Create a New Jekyll Site

Host Terminal

This will create the tech-blog default content in the local host workspace and install all the template files for later to be mounted in /srv/jekyll.

docker run --rm --name tech-blog -v ${PWD}:/srv/jekyll tech-blog jekyll new . 

# Use "--force" if you want to overwrite existent content, i.e.
# docker run --rm --name tech-blog -v ${PWD}:/srv/jekyll tech-blog jekyll new . --force

Devcontainer

If you desire to do this manually inside the container it is possible to use the devcontainer to achieve the same result.

After creating your image use F1 or Shift + Ctrl + P and type Open in devcontainer.

Once you have a terminal open type:

jekyll new .

# Same as mention in the previous section use "--force" if content was created previously.
# jekyll new . --force

Test locally with the Jekyll Server

Host Terminal

Run in development mode, this will reload your page as you make changes.

NOTE: Installing dependencies separately i.e., running bundle install and then jekyll serve will not work.

Both instructions need to be run together, otherwise jekyll cannot find the gems.

docker run --rm --name tech-blog -v ${PWD}:/srv/jekyll -p 4000:4000 tech-blog bash -c "bundle install && bundle exec jekyll serve --host 0.0.0.0 --livereload"

Open your web browser and paste the URL: http://localhost:4000/tech-blog

Docker compose

For simplicity docker-compose.yml contains this configuration:

docker-compose up -d

To remove and stop the containers:

docker-compose down

Open your web browser and paste the URL: http://localhost:4000/tech-blog

Devcontainer

bundle install
bundle exec jekyll serve --host 0.0.0.0 --livereload # Add --draft to show drafts as posts

Important: Use http://localhost:4001/tech-blog instead of 4000

Create GitHub Page

Follow the GitHub official documentation.

Known Issues:

It looks like the gems are correctly installed in the Docker container once bundle install is manually run within an interactive session. However, when running the jekyll serve command directly via docker run, the container isn not finding the gems that were supposedly installed.

Understanding the Problem: The issue is likely due to the fact that when bundle install is run in an interactive session, the gems are installed in the container's filesystem. However, when jekyll serve is run in a non-interactive Docker command, it's possible that the gems aren't being recognized because they weren't installed in the current session or due to some caching or volume mapping issues.

About

Explore a collection of articles where I dive into small projects and the latest tech trends. I share hands-on experiences, insights, and tutorials on emerging technologies and programming. Perfect for developers and tech enthusiasts eager to learn and innovate alongside me.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published