Docker Image Refresh - #2270
Open
tsengia wants to merge 32 commits into
Open
Conversation
Co-authored-by: Simon Legner <Simon.Legner@gmail.com>
Co-authored-by: Simon Legner <Simon.Legner@gmail.com>
…eat/docker-dev
Author
|
Also, aside from this PR, I would be interested in becoming a maintainer for this repo. |
…p server if docs origin and app host are the same
…eat/docker-dev
There was a problem hiding this comment.
Pull request overview
This PR refreshes DevDocs’ containerization story by consolidating Docker build logic into a single multi-stage Dockerfile, adding a VS Code devcontainer setup, and introducing runtime configuration knobs intended to make Docker deployments smaller and more configurable (docs/assets moved to volumes, origin/SSL settings configurable).
Changes:
- Replaced multiple Dockerfiles with a single multi-stage
Dockerfile(dev + runtime targets) and updated ignore rules to keep docs/assets out of build context. - Added Docker deployment documentation and a
.devcontainer/devcontainer.jsonfor containerized development. - Introduced new host/origin configuration plumbing (meta-based config + server-side env vars) and adjusted request handling for same-host doc serving.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
views/index.erb |
Adds meta tags intended to provide runtime-configurable docs host/origin to client JS. |
README.md |
Documents Docker-based deployment flow and new environment variables. |
lib/app.rb |
Adds env var toggles for SSL/HSTS, new docs host/origin settings, and a same-host docs send_file fallback. |
Dockerfile-alpine |
Removes the old Alpine Dockerfile in favor of the unified Dockerfile. |
Dockerfile |
Introduces multi-stage (base/dev/runtime) build and runtime volumes for docs/assets. |
assets/javascripts/models/doc.js |
Changes doc asset URL construction to use protocol-relative origins. |
assets/javascripts/app/config.js.erb |
Switches config source to DOM meta tags for docs origin and production host. |
.vscode/settings.json |
Adds workspace spellchecker configuration. |
.gitignore |
Ignores local .env and .bash_history. |
.gitattributes |
Enables text auto-normalization. |
.dockerignore |
Excludes docs/assets/log/tmp/test from Docker build context to keep images smaller. |
.devcontainer/devcontainer.json |
Adds VS Code devcontainer configuration targeting the dev stage image. |
Suppressed comments (2)
lib/app.rb:135
- Same issue as the dev/test block:
settings.docsandsettings.newsare set to lambdas, but the rest of the app treats them as concrete values (hash/array). This will raise errors in production routes and RSS generation.
configure :production do
set :docs, -> { parse_docs }
set :news, -> { parse_news }
end
assets/javascripts/app/config.js.erb:11
- Same issue as
docs_origin:#production-host-metais not defined inviews/other.erb, so this can throw at runtime on doc pages (and any non-index route that rendersother.erb).
production_host: document.getElementById("production-host-meta").content,
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
127
to
130
| configure :development, :test do | ||
| set :docs, -> { parse_docs } | ||
| set :news, -> { parse_news } | ||
| end |
Comment on lines
+431
to
+434
| elsif !request.path.end_with?(".html") && user_has_docs?(doc) && supports_js_redirection? | ||
| redirect_via_js(request.path) | ||
| elsif settings.docs_host == settings.docs_origin && File.exist?(File.join(settings.public_folder, "docs", request.path.gsub("..",""))) | ||
| send_file File.join(settings.public_folder, "docs", request.path.gsub("..","")), status: status |
| app.config = { | ||
| db_filename: 'db.json', | ||
| default_docs: <%= App.default_docs.to_json %>, | ||
| docs_origin: document.getElementById("docs-origin-meta").content, |
Comment on lines
+24
to
+25
| <meta id="production-host-meta" content="<%= App.docs_host %>" > | ||
| <meta id="docs-origin-meta" content="//<%= App.docs_origin %>" > |
Comment on lines
+46
to
+50
| return `//${app.config.docs_origin}${this.fullPath(path)}?${this.mtime}`; | ||
| } | ||
|
|
||
| dbUrl() { | ||
| return `${app.config.docs_origin}/${this.slug}/${app.config.db_filename}?${this.mtime}`; | ||
| return `//${app.config.docs_origin}/${this.slug}/${app.config.db_filename}?${this.mtime}`; |
Comment on lines
+32
to
+39
| RUN bundle config unset without && \ | ||
| bundle install && \ | ||
| apk add --update bash curl && \ | ||
| curl -LO https://download.docker.com/linux/static/stable/x86_64/docker-26.1.4.tgz && \ | ||
| tar -xzf docker-26.1.4.tgz && \ | ||
| mv docker/docker /usr/bin && \ | ||
| rm -rf docker docker-26.1.4.tgz && \ | ||
| rm -rf ~/.gem /root/.bundle/cache /usr/local/bundle/cache |
Comment on lines
+50
to
+52
| RUN apk del gzip build-base git zlib-dev && \ | ||
| chown -R $USERNAME:$USERNAME /devdocs && \ | ||
| rm -rf /tmp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR combines the multiple
Dockerfile's in the repo into a single, multi-stageDockerfilethat can be used to build both development and production Docker images.I've also added a
devcontainer.jsonfile that can be used with VS Code to provider a containerized development environment. This PR was originally based off of this PR: #1337Instead of the Docker image including all the documentation by default, now users are able to select which documentation sections they want to include in their local deployment of DevDocs.
This makes it easier/faster to publish new official Docker images of DevDocs because the image size is much smaller.
All downloaded documentation and compiled assets are stored in Docker volumes instead of being baked into the image.
This also means that new Docker images only need uploaded when code changes, and not when documentation updates.
Finally, this PR adds environment variables that can be used to configure the SSL and origin settings of DevDocs when deployed via Docker container. This helps if deploying DevDocs behind a reverse proxy/load balancer, and when running on Windows via WSL2.
This PR should close:
Once this PR is merged, I would think a new Docker image should be released again, which would close #895 and this PR.