diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..c5e8aa32 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +_site/ +.sass-cache/ +.jekyll-metadata +.git/ +.idea/ +*.iml +.DS_Store +vendor/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..3f0a3843 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM ruby:3.2-slim + +# Install build dependencies required by native gem extensions (e.g., nokogiri) +# and libcurl for htmlproofer link checking +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + build-essential \ + git \ + libcurl4-openssl-dev \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /site + +# Install gems first (layer caching - only re-runs when Gemfile changes) +COPY Gemfile Gemfile.lock ./ +RUN bundle install + +# Copy the rest of the site +COPY . . + +EXPOSE 4000 diff --git a/README.md b/README.md index e26d2eca..fbd3704c 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,40 @@ For Bundler, depending on your system, you may need to also install the Ruby development headers (e.g. `ruby-dev`). On Ubuntu/Debian, for example, this would be accomplished by doing `sudo apt-get install ruby-dev`. + +### Docker Setup (Recommended) + +If you have [Docker](https://www.docker.com/) installed, you can skip +the Ruby/Bundler prerequisites entirely: + +1. Clone the repository: + ```bash + git clone https://github.com/Submitty/submitty.github.io.git + cd submitty.github.io + ``` +2. Start the development server: + ```bash + docker compose up + ``` + The first run takes a few minutes to install dependencies. Subsequent + runs start in seconds. + +3. Visit [http://localhost:4000](http://localhost:4000) to view the site. + Changes to files will automatically trigger a rebuild and refresh your + browser. + +4. To stop the server, press `Ctrl+C` or run: + ```bash + docker compose down + ``` + To run the link checker with Docker: + ```bash + docker compose exec docs bundle exec jekyll build + docker compose exec docs bundle exec htmlproofer ./_site --assume-extension --empty-alt-ignore --disable_external + ``` +If you prefer to set up Ruby natively, see the manual instructions below. + + ### Setup 1. Clone the respository on your local machine, e.g., diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..02461c13 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +services: + docs: + build: . + ports: + - "127.0.0.1:35729:35729" # livereload port, bypasses nginx + expose: + - "4000" + volumes: + - .:/site + - bundle_cache:/usr/local/bundle + environment: + - JEKYLL_ENV=development + command: bundle exec jekyll serve --host 0.0.0.0 --livereload --force_polling + nginx: + image: nginx:alpine + ports: + - "127.0.0.1:4000:80" + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + depends_on: + - docs +volumes: + bundle_cache: diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..2140a0be --- /dev/null +++ b/nginx.conf @@ -0,0 +1,24 @@ +events {} +http { + server { + listen 80; + server_name localhost; + + sub_filter '0.0.0.0:4000' 'localhost:4000'; + sub_filter '0.0.0.0:35729' 'localhost:35729'; + sub_filter_once off; + sub_filter_types text/html application/json; + + location / { + proxy_pass http://docs:4000; + proxy_set_header Host $host; + } + + location /livereload { + proxy_pass http://docs:35729; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + } +}