Skip to content

Add Docker image for our docs site #594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 18, 2024

Conversation

nrichers
Copy link
Collaborator

@nrichers nrichers commented Dec 17, 2024

Internal Notes for Reviewers

For self-hosted installations, we agreed to create a Docker image that can be shipped with the rest of the product. This PR adds:

  • Dockerfile — Uses the rendered site output in site/_site and turns it into a Docker image that can be served on port 4444
  • make docker-build— Fetches the source files, renders the docs site, and builds the image
  • make docker-serve— Serves the docs site locally for testing on port 4444
  • README.md — Explains the above

I also updated the mostly unused docs-site action to use our production profile. We don't use this action as part of our workflow generally, so it should be fine to repurpose for the Docker image.

Proof it works

Relevant bits from make docker-image: [EDIT — INFO IS FROM BEFORE SPLITTING THE MAKE ACTION]

Building the Docker image ...
[+] Building 2.9s (7/7) FINISHED                                                                                                                                           
 => [internal] load build definition from Dockerfile                                                                                                                  0.0s
 => => transferring dockerfile: 37B                                                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                                                     0.0s
 => => transferring context: 2B                                                                                                                                       0.0s
 => [internal] load metadata for docker.io/library/nginx:alpine                                                                                                       1.0s
 => [internal] load build context                                                                                                                                     0.5s
 => => transferring context: 62.39MB                                                                                                                                  0.5s
 => CACHED [1/2] FROM docker.io/library/nginx:alpine@sha256:41523187cf7d7a2f2677a80609d9caa14388bf5c1fbca9c410ba3de602aaaab4                                          0.0s
 => [2/2] COPY site/_site /usr/share/nginx/html                                                                                                                       0.9s
 => exporting to image                                                                                                                                                0.4s
 => => exporting layers                                                                                                                                               0.4s
 => => writing image sha256:c4f5c2232248f2ad3fd53b528f36f3a34ebaddbbeadd04147b996ae4a6815a57                                                                          0.0s
 => => naming to docker.io/library/validmind-docs                                                                                                                     0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them

Starting the Docker container on http://localhost:4444/ ...
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2024/12/17 19:09:02 [notice] 1#1: using the "epoll" event method
2024/12/17 19:09:02 [notice] 1#1: nginx/1.27.3
2024/12/17 19:09:02 [notice] 1#1: built by gcc 13.2.1 20240309 (Alpine 13.2.1_git20240309) 
2024/12/17 19:09:02 [notice] 1#1: OS: Linux 5.15.49-linuxkit
2024/12/17 19:09:02 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/12/17 19:09:02 [notice] 1#1: start worker processes
2024/12/17 19:09:02 [notice] 1#1: start worker process 30
2024/12/17 19:09:02 [notice] 1#1: start worker process 31
2024/12/17 19:09:02 [notice] 1#1: start worker process 32
2024/12/17 19:09:02 [notice] 1#1: start worker process 33
2024/12/17 19:09:02 [notice] 1#1: start worker process 34
172.17.0.1 - - [17/Dec/2024:19:22:21 +0000] "GET / HTTP/1.1" 200 61628 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" "-"
172.17.0.1 - - [17/Dec/2024:19:22:21 +0000] "GET /site_libs/quarto-contrib/fontawesome6-0.1.0/all.css HTTP/1.1" 200 137826 "http://localhost:4444/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" "-"
...

What Docker shows:

image

And finally, accessing the site locally:

image

We use port 4444 since this is a Quarto site and this is what I already use locally.

External Release Notes

@nrichers nrichers added infrastructure Docs infra changes internal Not to be externalized in the release notes labels Dec 17, 2024
@nrichers nrichers requested a review from nibalizer December 17, 2024 19:45
Copy link
Contributor

PR Summary

This pull request introduces Docker support for building and serving the static HTML site. The changes include:

  • A new Dockerfile is added to create a Docker image using the official Nginx image. The static site content is copied to the Nginx HTML directory, and port 4444 is exposed for accessing the site.
  • The README.md file is updated with instructions on how to build and serve the site using Docker. It includes prerequisites, build commands, and access instructions.
  • The Makefile is updated to include a new docker-image target. This target builds the Docker image and runs the container, serving the site on port 4444. The docs-site target is also modified to use a production profile for rendering the static HTML site.

These changes enable users to deploy the static site in a consistent environment using Docker, facilitating both local testing and production deployment.

Test Suggestions

  • Verify that the Docker image builds successfully using the provided Dockerfile.
  • Test that the Docker container runs and serves the static site on port 4444.
  • Ensure that the static site content is correctly copied to the Nginx HTML directory.
  • Check that the site is accessible at http://localhost:4444 after running the Docker container.
  • Test the make docker-image command to ensure it builds and runs the Docker container as expected.

@nrichers nrichers changed the title Add Docker images for our docs site Add Docker image for our docs site Dec 17, 2024
Copy link
Contributor

A PR preview is available: Preview URL

1 similar comment
Copy link
Contributor

A PR preview is available: Preview URL

Copy link
Contributor

A PR preview is available: Preview URL

@nrichers nrichers merged commit d2219d9 into main Dec 18, 2024
3 checks passed
nrichers added a commit that referenced this pull request Dec 18, 2024
* Add Dockerfile, make docker-image action, and update readme

* Remove stray text

* Minor comment update

* Split make action into docker-build and docker-serve

Co-authored-by: Nik Richers <nik@validmind.ai>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Docs infra changes internal Not to be externalized in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants