Skip to content

Commit 0e9d3a4

Browse files
authored
Add Dockerfile for easy installation on local machine (#532)
1 parent c09d3ee commit 0e9d3a4

File tree

6 files changed

+106
-1
lines changed

6 files changed

+106
-1
lines changed

.github/workflows/deploy-image.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
- name: Buildx
19+
uses: docker/setup-buildx-action@v1
20+
21+
- name: Login
22+
uses: docker/login-action@v1
23+
with:
24+
username: ${{ secrets.DOCKER_USERNAME }}
25+
password: ${{ secrets.DOCKER_PASSWORD }}
26+
27+
- name: Build and push
28+
uses: docker/build-push-action@v2
29+
with:
30+
context: .
31+
push: true
32+
tags: amirpourmand/al-folio

Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM jekyll/jekyll
2+
Label MAINTAINER Amir Pourmand
3+
#install imagemagick tool for convert command
4+
RUN apk add --no-cache --virtual .build-deps \
5+
libxml2-dev \
6+
shadow \
7+
autoconf \
8+
g++ \
9+
make \
10+
&& apk add --no-cache imagemagick-dev imagemagick
11+
WORKDIR /srv/jekyll
12+
ADD Gemfile /srv/jekyll/
13+
RUN bundle install

README.md

+42-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,48 @@ Why Jekyll? Read [Andrej Karpathy's blog post](https://karpathy.github.io/2014/0
119119

120120
### Installation
121121

122-
#### Local setup
122+
#### Local setup using Docker (Recommended on Windows)
123+
124+
You need to do these step to get `al-folio` up and running in your local machine:
125+
126+
- Install [docker](https://docs.docker.com/get-docker/)
127+
- Clone your repository
128+
129+
```bash
130+
git clone [email protected]:<your-username>/<your-repo-name>.git
131+
cd <your-repo-name>
132+
```
133+
134+
Then you can use Dockerhub prebuilt image to run your website. Note that for the first time it would download an image of size 300MB or so.
135+
136+
```bash
137+
bin/dockerhub_run.sh
138+
```
139+
140+
> Currently, you should opt this method, only if you are using newest version of al-folio. If you are using an old version. You should build your own image.
141+
142+
<details><summary>(click to expand) <strong>Build your own docker image (more advanced):</strong></summary>
143+
144+
First, download the necessary modules and install them into a docker image called `al-folio:Dockerfile` (this command will build an image which is used to run your website afterwards. Note that you only need to do this step once. After you have the image, you no longer need to do this anymore):
145+
146+
147+
\```bash
148+
bin/docker_build_image.sh
149+
\```
150+
151+
Run the website!
152+
153+
\```bash
154+
bin/docker_run.sh
155+
\```
156+
157+
> To change port number, you can edit `docker_run.sh` file.
158+
159+
> If you want to update jekyll, install new ruby packages, etc., all you have to do is build the image again using `docker_build_image.sh`! It will download ruby and jekyll and install all ruby packages again from scratch.
160+
161+
</details>
162+
163+
#### Local Setup (Standard)
123164

124165
Assuming you have [Ruby](https://www.ruby-lang.org/en/downloads/) and [Bundler](https://bundler.io/) installed on your system (*hint: for ease of managing ruby gems, consider using [rbenv](https://github.com/rbenv/rbenv)*), first [fork](https://guides.github.com/activities/forking/) the theme from `github.com:alshedivat/al-folio` to `github.com:<your-username>/<your-repo-name>` and do the following:
125166

bin/docker_build_image.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FILE=Gemfile.lock
2+
if [ -f "$FILE" ]; then
3+
rm $FILE
4+
fi
5+
docker build -t "al-folio:latest" .

bin/docker_run.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FILE=Gemfile.lock
2+
if [ -f "$FILE" ]; then
3+
rm $FILE
4+
fi
5+
docker run --rm -v "$PWD:/srv/jekyll/" -p "8080:8080" \
6+
-it al-folio:latest bundler \
7+
exec jekyll serve --watch --port=8080 --host=0.0.0.0

bin/dockerhub_run.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FILE=Gemfile.lock
2+
if [ -f "$FILE" ]; then
3+
rm $FILE
4+
fi
5+
docker run --rm -v "$PWD:/srv/jekyll/" -p "8080:8080" \
6+
-it amirpourmand/al-folio bundler \
7+
exec jekyll serve --watch --port=8080 --host=0.0.0.0

0 commit comments

Comments
 (0)