-
Notifications
You must be signed in to change notification settings - Fork 42
Simplify Makefile / Dockerfile interactions using docker-compose.yml #785
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
4 commits
Select commit
Hold shift + click to select a range
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,66 +1,48 @@ | ||
| # 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 | ||
| DOCKER_DIR=docker | ||
|
|
||
| # Targets | ||
| .PHONY: all dockerbuild_test dockerrun_test dockerbuild_docs dockerrun_docs docs docker_test clean help | ||
| .PHONY: all test docs docker_test clean help | ||
|
|
||
| all: help | ||
|
|
||
| mdlint_fix: | ||
| @echo "Running markdownlint..." | ||
| markdownlint --config .markdownlint.yml --fix . | ||
|
|
||
| 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) | ||
| test: | ||
| @echo "Running tests locally..." | ||
| pytest -v src/test | ||
|
|
||
| dockerbuild_docs: | ||
| @echo "Building the docs Docker image..." | ||
| $(DOCKER_BUILD) --target $(DOCS_DOCKER_TARGET) --tag $(DOCS_IMAGE) . | ||
| docker_test: | ||
| @echo "Running tests in Docker..." | ||
| pushd $(DOCKER_DIR) && docker-compose run --rm test | ||
|
|
||
| dockerrun_docs: | ||
| @echo "Running the docs Docker image..." | ||
| $(DOCKER_RUN) --publish $(MKDOCS_PORT):8000 $(PROJECT_VOLUME) $(DOCS_IMAGE) | ||
| docs: | ||
| @echo "Building and running docs in Docker..." | ||
| pushd $(DOCKER_DIR) && docker-compose up docs | ||
|
|
||
| up: | ||
| @echo "Starting Docker services..." | ||
| pushd $(DOCKER_DIR) && docker-compose up -d | ||
|
|
||
| docs: dockerbuild_docs dockerrun_docs | ||
| docker_test: dockerbuild_test dockerrun_test | ||
| down: | ||
| @echo "Stopping Docker services..." | ||
| pushd $(DOCKER_DIR) && docker-compose down | ||
|
|
||
| clean: | ||
| @echo "Cleaning up..." | ||
| $(DOCKER) rmi $(TEST_IMAGE) $(DOCS_IMAGE) || true | ||
| @echo "Cleaning up Docker resources..." | ||
| pushd $(DOCKER_DIR) && docker-compose down --rmi local || true | ||
|
|
||
| help: | ||
| @echo "Usage: make [target]" | ||
| @echo "" | ||
| @echo "Targets:" | ||
| @echo " all - Display this help message" | ||
| @echo " mdlint_fix - Run markdownlint with --fix" | ||
| @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" | ||
|
|
||
|
|
||
|
|
||
| @echo " test - Run the tests in a local shell" | ||
| @echo " docs - Build and run the docs Docker service" | ||
| @echo " docker_test - Run the tests in a Docker container" | ||
| @echo " clean - Remove Docker containers and 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
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
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,36 @@ | ||
| services: | ||
| base: | ||
| build: | ||
| context: .. | ||
| dockerfile: docker/Dockerfile | ||
| target: base | ||
| image: base:latest | ||
|
|
||
| dependencies: | ||
| build: | ||
| context: .. | ||
| dockerfile: docker/Dockerfile | ||
| target: dependencies | ||
| image: dependencies:latest | ||
| depends_on: | ||
| - base | ||
|
|
||
| test: | ||
| build: | ||
| context: .. | ||
| dockerfile: docker/Dockerfile | ||
| target: test | ||
| image: test:latest | ||
| depends_on: | ||
| - dependencies | ||
|
|
||
| docs: | ||
| build: | ||
| context: .. | ||
| dockerfile: docker/Dockerfile | ||
| target: docs | ||
| image: docs:latest | ||
| depends_on: | ||
| - dependencies | ||
| ports: | ||
| - "8000:8000" |
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.