-
Notifications
You must be signed in to change notification settings - Fork 42
Dockerize the mkdocs dev server #695
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
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4745c9c
refine Dockerfile to modularize targets
ahouseholder 7d8e892
add Makefile to simplify container build & run process
ahouseholder b497f76
update readme to explain makefile use
ahouseholder 94d01ad
Merge branch 'main' into 582-dockerize-the-mkdocs-dev-server
ahouseholder b12ee66
Merge branch 'main' of https://github.com/CERTCC/SSVC into 582-docker…
ahouseholder 2fa4ff7
`markdownlint --fix .`
ahouseholder 3d2b1a2
Merge branch '582-dockerize-the-mkdocs-dev-server' of https://github.…
ahouseholder cd119a4
address common error where `ssvc` module is not found due to PYTHONPATH
ahouseholder c205248
add `venv` note
ahouseholder 4ff9b99
explain that ports in docker containers are local to the container
ahouseholder 469a82a
add basic `make` explainer
ahouseholder 898fe45
`markdownlint --fix .`
ahouseholder 8e1eb8b
use long options
ahouseholder a5ef55a
Merge branch 'main' into 582-dockerize-the-mkdocs-dev-server
ahouseholder 7ad3f0e
Merge branch 'main' into 582-dockerize-the-mkdocs-dev-server
ahouseholder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,23 @@ | ||
| FROM python:3.12-slim-bookworm | ||
|
|
||
| FROM python:3.12-slim-bookworm AS base | ||
| RUN pip install --upgrade pip | ||
| WORKDIR /app | ||
|
|
||
| FROM base AS dependencies | ||
|
|
||
| # install requirements | ||
| COPY requirements.txt . | ||
| RUN pip install -r requirements.txt | ||
|
|
||
| # Copy the files we need | ||
| COPY src/ . | ||
| COPY data ./data | ||
| COPY . /app | ||
| # Set the environment variable | ||
| ENV PYTHONPATH=/app/src | ||
|
|
||
|
|
||
| FROM dependencies AS test | ||
| # install pytest | ||
| RUN pip install pytest | ||
|
|
||
| # run the unit tests \ | ||
| ENTRYPOINT ["pytest"] | ||
| CMD ["test"] | ||
| CMD ["pytest","src/test"] | ||
|
|
||
| FROM dependencies AS docs | ||
| CMD ["mkdocs", "serve", "--dev-addr", "0.0.0.0:8000"] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # Project-specific vars | ||
| PFX=ssvc | ||
| DOCKER=docker | ||
| DOCKER_BUILD=$(DOCKER) build | ||
| DOCKER_RUN=$(DOCKER) run --tty --rm | ||
| PROJECT_VOLUME=--volume $(shell pwd):/app | ||
| MKDOCS_PORT=8765 | ||
|
|
||
| # docker names | ||
| TEST_DOCKER_TARGET=test | ||
| TEST_IMAGE = $(PFX)_test | ||
| DOCS_DOCKER_TARGET=docs | ||
| DOCS_IMAGE = $(PFX)_docs | ||
|
|
||
| # Targets | ||
| .PHONY: all dockerbuild_test dockerrun_test dockerbuild_docs dockerrun_docs docs docker_test clean help | ||
|
|
||
| all: help | ||
|
|
||
| dockerbuild_test: | ||
| @echo "Building the test Docker image..." | ||
| $(DOCKER_BUILD) --target $(TEST_DOCKER_TARGET) --tag $(TEST_IMAGE) . | ||
|
|
||
| dockerrun_test: | ||
| @echo "Running the test Docker image..." | ||
| $(DOCKER_RUN) $(PROJECT_VOLUME) $(TEST_IMAGE) | ||
|
|
||
| dockerbuild_docs: | ||
| @echo "Building the docs Docker image..." | ||
| $(DOCKER_BUILD) --target $(DOCS_DOCKER_TARGET) --tag $(DOCS_IMAGE) . | ||
|
|
||
| dockerrun_docs: | ||
| @echo "Running the docs Docker image..." | ||
| $(DOCKER_RUN) --publish $(MKDOCS_PORT):8000 $(PROJECT_VOLUME) $(DOCS_IMAGE) | ||
|
|
||
|
|
||
| docs: dockerbuild_docs dockerrun_docs | ||
| docker_test: dockerbuild_test dockerrun_test | ||
|
|
||
| clean: | ||
| @echo "Cleaning up..." | ||
| $(DOCKER) rmi $(TEST_IMAGE) $(DOCS_IMAGE) || true | ||
|
|
||
| help: | ||
| @echo "Usage: make [target]" | ||
| @echo "" | ||
| @echo "Targets:" | ||
| @echo " all - Display this help message" | ||
| @echo " docs - Build and run the docs Docker image" | ||
| @echo " docker_test - Build and run the test Docker image" | ||
| @echo "" | ||
| @echo " dockerbuild_test - Build the test Docker image" | ||
| @echo " dockerrun_test - Run the test Docker image" | ||
| @echo " dockerbuild_docs - Build the docs Docker image" | ||
| @echo " dockerrun_docs - Run the docs Docker image" | ||
| @echo "" | ||
| @echo " clean - Remove the Docker images" | ||
| @echo " help - Display this help message" | ||
|
|
||
|
|
||
|
|
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
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.
Uh oh!
There was an error while loading. Please reload this page.