diff --git a/Dockerfile b/Dockerfile index b409c4407d64..1517b5c53d0b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,6 +40,11 @@ RUN bundle update \ FROM scratch AS vendor COPY --from=vendored /out / +# Serve the files using jekyll to enable file watching +# and livereload for a faster inner loop +FROM gem AS dev +CMD ["./dev-start.sh"] + # Build the static HTML for the current docs. # After building with jekyll, fix up some links FROM gem AS generate diff --git a/_config.yml b/_config.yml index 5239a2e03389..36f70def7e4d 100644 --- a/_config.yml +++ b/_config.yml @@ -123,6 +123,7 @@ defaults: # Fetch upstream resources (reference documentation) used by _plugins/fetch_remote.rb # - repo is the GitHub repository to fetch from # - ref the Git reference +# - completion_marker is a file path that, if it exists, will prevent a redownload from occurring # - paths is a list to the resources within the remote repository # - dest is the destination path within the working tree # - src is a list of glob source paths within the remote repository @@ -130,6 +131,7 @@ fetch-remote: - repo: "https://github.com/docker/cli" default_branch: "master" ref: "20.10" + completion_marker: "engine/deprecated.md" paths: - dest: "engine/extend" src: @@ -148,6 +150,7 @@ fetch-remote: - repo: "https://github.com/docker/docker" default_branch: "master" ref: "20.10" + completion_marker: "engine/api/version-history.md" paths: - dest: "engine/api" src: @@ -156,6 +159,7 @@ fetch-remote: - repo: "https://github.com/docker/compose-cli" default_branch: "main" ref: "main" + completion_marker: "cloud/ecs-compose-features.md" paths: - dest: "cloud" src: @@ -166,6 +170,7 @@ fetch-remote: - repo: "https://github.com/docker/buildx" default_branch: "master" ref: "master" + completion_marker: "build/bake/index.md" paths: - dest: "build/bake" src: @@ -174,6 +179,7 @@ fetch-remote: - repo: "https://github.com/distribution/distribution" default_branch: "main" ref: "release/2.7" + completion_marker: "registry/spec/index.md" paths: - dest: "registry/spec" src: @@ -186,6 +192,7 @@ fetch-remote: - repo: "https://github.com/moby/buildkit" default_branch: "master" ref: "master" + completion_marker: "engine/reference/builder.md" paths: - dest: "engine/reference/builder.md" src: diff --git a/_plugins/fetch_remote.rb b/_plugins/fetch_remote.rb index 8513fc509980..12556b457f5d 100644 --- a/_plugins/fetch_remote.rb +++ b/_plugins/fetch_remote.rb @@ -49,6 +49,15 @@ def pre_read(site) puts "Starting plugin fetch_remote.rb..." site.config['fetch-remote'].each do |entry| puts " Repo #{entry['repo']} (#{entry['ref']})" + + if(File.exist?(entry['completion_marker'])) + fmp = FrontMatterParser::Parser.parse_file(entry['completion_marker']) + if fmp.content != "" + puts " Skipping fetch as #{entry['completion_marker']} exists" + next + end + end + Dir.mktmpdir do |tmpdir| tmpfile = FetchRemote.download("#{entry['repo']}/archive/#{entry['ref']}.zip", tmpdir) Dir.mktmpdir do |ztmpdir| @@ -121,7 +130,6 @@ def pre_read(site) end end end - end_time = Time.now puts "done in #{(end_time - beginning_time)} seconds" end diff --git a/_plugins/fix_urls.rb b/_plugins/fix_urls.rb index 1d96f38ebc65..8df274e5142a 100644 --- a/_plugins/fix_urls.rb +++ b/_plugins/fix_urls.rb @@ -9,10 +9,14 @@ def post_read(site) Jekyll.logger.info " Fixing up URLs in swagger files" Dir.glob(%w[./docker-hub/api/*.yaml ./engine/api/*.yaml]) do |file_name| - Jekyll.logger.info " #{file_name}" text = File.read(file_name) replace = text.gsub("https://docs.docker.com", "") - File.open(file_name, "w") { |file| file.puts replace } + if text == replace + Jekyll.logger.info " #{file_name} (skipped - no change)" + else + Jekyll.logger.info " #{file_name}" + File.open(file_name, "w") { |file| file.puts replace } + end end end_time = Time.now diff --git a/_plugins/update_api_toc.rb b/_plugins/update_api_toc.rb index b8e6170a3cee..e2ffe5cfb2cf 100644 --- a/_plugins/update_api_toc.rb +++ b/_plugins/update_api_toc.rb @@ -13,8 +13,10 @@ def pre_read(site) engine_ver = site.config['latest_engine_api_version'] toc_file = File.read("_data/toc.yaml") replace = toc_file.gsub!("{{ site.latest_engine_api_version }}", engine_ver) - Jekyll.logger.info " Replacing '{{ site.latest_engine_api_version }}' with #{engine_ver} in _data/toc.yaml" - File.open("_data/toc.yaml", "w") { |file| file.puts replace } + if toc_file != replace + Jekyll.logger.info " Replacing '{{ site.latest_engine_api_version }}' with #{engine_ver} in _data/toc.yaml" + File.open("_data/toc.yaml", "w") { |file| file.puts replace } + end end end_time = Time.now diff --git a/dev-start.sh b/dev-start.sh new file mode 100755 index 000000000000..a2263805818d --- /dev/null +++ b/dev-start.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ "$JEKYLL_ENV" == "production" ]; then + echo "Starting in production mode" + exec bundle exec jekyll serve --host=0.0.0.0 -l --config _config.yml,_config_production.yml +else + exec bundle exec jekyll serve --host=0.0.0.0 -l +fi diff --git a/docker-compose.yml b/docker-compose.yml index 7d5ab9d730b5..8d66b1a9f7c9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,10 @@ services: args: - JEKYLL_ENV context: . + target: dev image: docs/docstage ports: - - "4000:4000" + - 4000:4000 + - 35729:35729 + volumes: + - ./:/src