From a98f619cf9d56dafdff86f8c9a2a607c67fa3029 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 12 Apr 2023 21:02:31 +0100 Subject: [PATCH] Add dockerfile for local dev --- .dockerignore | 5 +++++ .github/workflows/validate.yml | 11 +++++++++++ Dockerfile | 15 +++++++++++++++ README.md | 4 ++++ Rakefile | 2 +- _config.yml | 2 ++ docker-compose.yml | 10 ++++++++++ 7 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..9f93ae48 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +/gems +_site +.sass-cache +.jekyll-metadata +.bundle diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 19d35b3b..81d32fe6 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -27,3 +27,14 @@ jobs: - name: Build & Validate run: rake validate + + docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Build container + run: docker-compose build + + - name: Build site in container + run: docker-compose run docs rake build diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..d7c4f580 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM ruby:2.7 + +ENV GLOBAL_GEMS=true + +WORKDIR /usr/src/website + +RUN git config --global --add safe.directory /usr/src/website && git config --global --add safe.directory /usr/src/website/_sass/brand + +RUN gem install bundler rake + +COPY . ./ + +RUN rake dependencies + +CMD ["rake", "dev"] diff --git a/README.md b/README.md index 6107af27..24c325d4 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ The Student Robotics public website. ## Getting Started +For ease of setup, a Docker container is provided. Simply install Docker and `docker-compose`, and run `docker-compose up`. + +### Manual + 0. [Clone this repo][clone-repo] 1. [Install Ruby 2.7][install-ruby] diff --git a/Rakefile b/Rakefile index 07577d6b..af1a844c 100644 --- a/Rakefile +++ b/Rakefile @@ -32,7 +32,7 @@ end task :submodules => ['_sass/brand/.git'] task :dev => [:dependencies, :submodules] do - sh('bundle exec jekyll serve --drafts --config _config.yml,_dev.yml') + sh('bundle exec jekyll serve --host 0.0.0.0 --drafts --config _config.yml,_dev.yml') end task :build => [:dependencies, :submodules] do diff --git a/_config.yml b/_config.yml index 1f14b0db..c0c4da83 100644 --- a/_config.yml +++ b/_config.yml @@ -115,6 +115,8 @@ exclude: - .github/ - .vscode/ - vendor/ + - docker-compose.yml + - Dockerfile paginate: 3 paginate_path: "/blog/:num/" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..4e2a4e6c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: "2.3" + +services: + website: + build: + context: . + volumes: + - ".:/usr/src/website" + ports: + - "4000:4000"