diff --git a/.github/workflows/deploy-image.yml b/.github/workflows/deploy-image.yml new file mode 100644 index 000000000000..93321b3eabaf --- /dev/null +++ b/.github/workflows/deploy-image.yml @@ -0,0 +1,32 @@ +name: Docker Image CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: amirpourmand/al-folio diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000000..79aaead7f91c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM jekyll/jekyll +Label MAINTAINER Amir Pourmand +#install imagemagick tool for convert command +RUN apk add --no-cache --virtual .build-deps \ + libxml2-dev \ + shadow \ + autoconf \ + g++ \ + make \ + && apk add --no-cache imagemagick-dev imagemagick +WORKDIR /srv/jekyll +ADD Gemfile /srv/jekyll/ +RUN bundle install diff --git a/README.md b/README.md index 148440a5f0e9..cecda63112ab 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,48 @@ Why Jekyll? Read [Andrej Karpathy's blog post](https://karpathy.github.io/2014/0 ### Installation -#### Local setup +#### Local setup using Docker (Recommended on Windows) + +You need to do these step to get `al-folio` up and running in your local machine: + +- Install [docker](https://docs.docker.com/get-docker/) +- Clone your repository + +```bash + git clone git@github.com:/.git + cd +``` + +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. + +```bash + bin/dockerhub_run.sh +``` + +> 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. + +
(click to expand) Build your own docker image (more advanced): + +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): + + +\```bash + bin/docker_build_image.sh +\``` + +Run the website! + +\```bash + bin/docker_run.sh +\``` + +> To change port number, you can edit `docker_run.sh` file. + +> 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. + +
+ +#### Local Setup (Standard) 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:/` and do the following: diff --git a/bin/docker_build_image.sh b/bin/docker_build_image.sh new file mode 100755 index 000000000000..fe208afbf7ae --- /dev/null +++ b/bin/docker_build_image.sh @@ -0,0 +1,5 @@ + FILE=Gemfile.lock +if [ -f "$FILE" ]; then + rm $FILE +fi + docker build -t "al-folio:latest" . \ No newline at end of file diff --git a/bin/docker_run.sh b/bin/docker_run.sh new file mode 100755 index 000000000000..a59a44ba2383 --- /dev/null +++ b/bin/docker_run.sh @@ -0,0 +1,7 @@ +FILE=Gemfile.lock +if [ -f "$FILE" ]; then + rm $FILE +fi +docker run --rm -v "$PWD:/srv/jekyll/" -p "8080:8080" \ + -it al-folio:latest bundler \ + exec jekyll serve --watch --port=8080 --host=0.0.0.0 \ No newline at end of file diff --git a/bin/dockerhub_run.sh b/bin/dockerhub_run.sh new file mode 100755 index 000000000000..7054e9914f2e --- /dev/null +++ b/bin/dockerhub_run.sh @@ -0,0 +1,7 @@ +FILE=Gemfile.lock +if [ -f "$FILE" ]; then + rm $FILE +fi +docker run --rm -v "$PWD:/srv/jekyll/" -p "8080:8080" \ + -it amirpourmand/al-folio bundler \ + exec jekyll serve --watch --port=8080 --host=0.0.0.0