Skip to content

Commit

Permalink
chore: Update Dockerfile to clean up and update gem versions
Browse files Browse the repository at this point in the history
  • Loading branch information
bamr87 committed Jun 4, 2024
1 parent 2c3d880 commit c3f8af7
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 50 deletions.
35 changes: 4 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,56 +1,29 @@
# Use an official Ruby runtime as a parent image
FROM ruby:2.7.4
# escape=\

# FROM starefossen/ruby-node:2-6-alpine

# Set environment variables
ENV GITHUB_GEM_VERSION 231
ENV JSON_GEM_VERSION 1.8.6

# Install Node.js
# RUN apt-get update -qq && apt-get install -y nodejs

# Set the working directory in the container to /app
WORKDIR /app
# WORKDIR /usr/src/app

# Add the current directory contents into the container at /app
ADD . /app

# Clean up
# RUN bundle clean

# Install specific versions of Jekyll and Bundler that are compatible with Ruby 2.7
# RUN gem install jekyll -v 3.9.0 && gem install bundler -v 1.17.3

# RUN gem install nokogiri -v 1.15.5
# RUN gem install github-pages -v 231
# RUN gem install faraday-net_http -v 3.0.2
# RUN gem install faraday -v 2.8.1
# RUN gem install bootstrap -v 5.3.3

# RUN apk --update add --virtual build_deps \
# build-base ruby-dev libc-dev linux-headers \
# && gem install --verbose --no-document \
# json:${JSON_GEM_VERSION} \
# github-pages:${GITHUB_GEM_VERSION} \
# jekyll-github-metadata \
# minitest \
# && apk del build_deps
# && apk add git \
# && mkdir -p /usr/src/app \
# && rm -rf /usr/lib/ruby/gems/*/cache/*.gem

# Install any needed packages specified in Gemfile
RUN gem update --system 3.3.22
RUN bundle update
RUN bundle install

# Clean up
RUN bundle clean --force

# Make port 4002 available to the world outside this container
EXPOSE 4002
# EXPOSE 4000 80


# Run Jekyll when the container launches
CMD ["bundle", "exec", "jekyll", "serve", "--host", "0.0.0.0"]
# CMD jekyll serve -d /_site --watch --force_polling -H 0.0.0.0 -P 4000
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: README - it-journey
description: it-journey
excerpt: it-journey
version: 0.0.0
version: 0.0.1
date-released: 2022-03-01
repo: https://github.com/bamr87/it-journey
tags:
Expand Down Expand Up @@ -103,7 +103,16 @@ docker build -t it-journey .
### Mac

```shell
docker run -p 4002:4002 -v /Users/bamr87/github/it-journey:/app it-journey
# run the docker image and mount the local directory to the container and open a bash shell
# Run the container in detached mode
docker run -d -p 4002:4002 -v ${GITHOME}/it-journey:/app --name my_container it-journey

# Start the container and run the CMD line from the Dockerfile
docker start my_container

# Attach to the running container
docker exec -it my_container /bin/bash

```

```shell
Expand Down
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ local_repo : *github_repository
repo_map : "_about/"
github_base_url : [*github_user, '.' , *site_domain] # the base hostname & protocol for your site, e.g. http://example.com
portfolio : [*github_user, '.', 'github.io']
level : 'her0'


## Maintainer Information----------------------------------------------------------

Expand Down
5 changes: 5 additions & 0 deletions _includes/zer0-env-var.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ <h2>Define Environment Variables</h2>
<td><input type="text" class="form-control" value="" required></td>
<td><button class="btn btn-danger removeRow">Remove</button></td>
</tr>
<tr>
<td><input type="text" class="form-control" value="ZREPO" required></td>
<td><input type="text" class="form-control" value="$GITHOME/$GIT_REPO" required></td>
<td><button class="btn btn-danger removeRow">Remove</button></td>
</tr>
</tbody>
</table>
<button class="btn btn-primary" id="addRow">Add Row</button>
Expand Down
Binary file added assets/images/zer0-checkpoint-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/zer0-checkpoint-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion assets/js/code-copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ document.addEventListener('DOMContentLoaded', function () {
button.innerText = copyText;
button.tabIndex = 1; // Add this line to make the button focusable with the keyboard
button.addEventListener('click', function () {
var code = pre.querySelector('code').innerText.trim();
var code = pre.querySelector('code').innerText
.split('\n')
.filter(line => !line.trim().startsWith('#'))
.join('\n')
.trim();
navigator.clipboard.writeText(code);
button.innerText = 'Copied';
setTimeout(function () {
Expand Down
81 changes: 65 additions & 16 deletions zer0.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: zer0
sub-title: 2 her0
description: Seed page with scripts, commands, instructions to build the most epic statically generated website in the universe.
version: 0.0.8
version: 0.0.9
tags:
- jekyll
- bootstrap5
Expand Down Expand Up @@ -111,15 +111,17 @@ Make sure you have the following installed on your machine:

brew install git
brew install gh
brew install docker
brew install --cask docker
brew install --cask visual-studio-code
```

## Environment

### Set your own environment variables

{% include zer0-env-var.html %}
{% if site.level == 'her0' %}
{% include zer0-env-var.html %}
{% endif %}

### Set the default environment variables

Expand All @@ -137,7 +139,7 @@ export ZREPO=$GITHOME/$GIT_REPO
```shell
#open Code to edit your shell profile and copy the environment variables

code ~/.zshrc
code ~/.zprofile
```

```shell
Expand Down Expand Up @@ -195,19 +197,20 @@ mkdir -p $ZREPO
```shell
# Initialize your github repository

gh repo create $GHUSER/$GIT_REPO --public --gitignore=jekyll --license=mit
gh repo create $GIT_REPO --gitignore Jekyll -l mit --public
```

```shell
# If new repo, initialize it

cd $ZREPO
git init
git remote add origin https://github.com/${GHUSER}/${GIT_REPO}.git
git pull origin main
curl https://raw.githubusercontent.com/bamr87/it-journey/master/zer0.md > README.md
git add README.md
git commit -m "Init zer0-mistakes"
git branch -M main
git remote add origin https://github.com/${GHUSER}/${GIT_REPO}.git
git push -u origin main
```

Expand All @@ -224,6 +227,8 @@ open https://github.com/${GHUSER}/${GIT_REPO}

<a id="repo-link"></a>

![Checkpoint 1](/assets/images/zer0-checkpoint-1.png)

## Initialize Jekyll

### Create Gemfile
Expand Down Expand Up @@ -258,41 +263,84 @@ echo "FROM ruby:2.7.4" >> Dockerfile
echo "# escape=\\" >> Dockerfile
echo "ENV GITHUB_GEM_VERSION 231" >> Dockerfile
echo "ENV JSON_GEM_VERSION 1.8.6" >> Dockerfile
echo "ENV GIT_REPO ${GIT_REPO}" >> Dockerfile
echo "WORKDIR /app" >> Dockerfile
echo "ADD . /app" >> Dockerfile
echo "RUN gem update --system 3.3.22" >> Dockerfile
echo "RUN bundle update" >> Dockerfile
echo "RUN bundle install" >> Dockerfile
echo "EXPOSE 4002" >> Dockerfile
echo "RUN bundle clean --force" >> Dockerfile
echo "EXPOSE 4000" >> Dockerfile
echo 'CMD ["bundle", "exec", "jekyll", "serve", "--host", "0.0.0.0"]' >> Dockerfile
```

```shell
docker build -t zer0-mistakes .
# build the docker image based on the Dockerfile
docker build -t ${GIT_REPO} .
```

```shell
docker run -p 4000:4000 -v $ZREPO:/app zer0-mistakes
# Run the container in detached mode
docker run -d -p 4000:4000 -v ${ZREPO}:/app --name zer0_container ${GIT_REPO}

# Start the container and run the CMD line from the Dockerfile
docker start zer0_container

# Attach to the running container
docker exec -it zer0_container /bin/bash
```

## Initialize Jekyll - MacOS
## Checkpoint - Jekyll Initialized

```shell
open http://localhost:4000/
```

![](/assets/images/zer0-checkpoint-2.png)

## Install Jekyll

Install [jekyll](https://jekyllrb.com/docs/installation/)

```shell
cd $ZREPO
jekyll new ./ --force
bundle install
```

## Checkpoint - Jekyll Initialized
![](../assets/images/jekyll-serve-1.png)

```shell
# If running MacOS
bundle add webrick
bundle install
code _config.yml
```

```yaml
title: zer0-mistakes
email: [email protected]
description: >- # this means to ignore newlines until "baseurl:"
Write an awesome description for your new site here. You can edit this
line in _config.yml. It will appear in your document head meta (for
Google search results) and in your feed.xml site description.
baseurl: null # the subpath of your site, e.g. /blog
url: null # the base hostname & protocol for your site, e.g. http://example.com
twitter_username: bamr87
github_username: bamr87
```
<!-- TODO: add favicon instructions for branding -->
```shell
jekyll serve
cd $ZREPO
wget https://raw.githubusercontent.com/bamr87/it-journey/master/favicon.ico
```

## Install Jekyll

Install [jekyll](https://jekyllrb.com/docs/installation/)

```shell
docker run jekyll new ./ --force
bundle install
```

## Checkpoint - Jekyll Initialized
Expand Down Expand Up @@ -325,6 +373,7 @@ wget https://raw.githubusercontent.com/bamr87/it-journey/master/favicon.ico
## Checkpoint 1

```shell

bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32 java
```

Expand All @@ -333,11 +382,11 @@ https://jekyllrb.com/docs/themes/#overriding-theme-defaults

```shell
# find theme path

bundle info --path minima
JEKYLL_THEME=$(bundle info --path minima)
echo $JEKYLL_THEME
cd $JEKYLL_THEME

```

### Copy theme repo
Expand Down

0 comments on commit c3f8af7

Please sign in to comment.