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
Feature/92 Provide Makefile #94
Conversation
This will prepare a testing image ready to be dispatched (with specific requirements applied)
Devised to customize our base image with testing requirements. We splitted this in two images because testing increases +120MB layers size
So far just with dummy `manage.py test` execution
Implemented targets: ``` $ make help usage: make [target] options: start Start all or c=<name> containers in FOREGROUND serve Start all or c=<name> containers in BACKGROUND test Execute tests stop Stop all or c=<name> containers restart Restart all or c=<name> containers status Show status of containers ps Alias of status clean Clean all containers (keeping volumes) purge Purge all containers and volumes build (re)Build all images or c=<name> containers other: help Show this help. mk-upgrade Check for updates of mk-lib mk-version Show current version of mk-lib ```
serve: ## Start all or c=<name> containers in BACKGROUND | ||
@$(DOCKER_COMPOSE) -f $(DOCKER_COMPOSE_FILE) up $(c) -d | ||
|
||
test: ## Execute tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to have another option to execute an specific test or all tests from one folder as you can do it in pytest. What do you think?
I've seen that you used the django command to run the tests, but it will trigger the pytests? Can you add a parameter to add the specific test path or folder path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, this is just an starting point :)
Tomorrow I'll explore options to inject strings or define specific string modifiers (filters).
Regarding the executed tests, it's not hardcoded, it's configurable on the invoked task so can be ammended without effort.
Currently there are no tests, pytest has not been configured and maybe it's better to deal with this in another PR
@@ -0,0 +1,95 @@ | |||
# Docker compose makefile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know about this package, I'll check it later, but it adds a lot of files I don't know what is the added value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It speeds up targets generation, provides auto help and more enhancements.
Btw, this is not mandatory :)
The proposed solution makes sense @jbagot? Or you want to explore another solution? I would liked to reach more feedback about the abstract solution (not about the detaila about the tests params) :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine, thanks @XaviTorello
TL;DR
With this setup, we just create an specific layer with testing requirements also applied ready to work tagged locally in
anem-per-feina:tests
. Also it provides amake
with most common development actions integratedFix #92 Create Makefile
Description
It provides a
Makefile
devised to simplify development actions:The idea is that now our composition will build two local images:
anem-per-feina:local
: with current Dockerfile definition (justrequirements.txt
file)anem-per-feina:tests
: extendinglocal
with testing requirements (processingrequirements-test.txt
)This is handled with a new service named
test
:build
orup
)entrypoint
, so it just dies when composition startsmake test
test
serviceentrypoint
to invoke our test task and dies (will be deleted once ends with--rm
)Considerations
One option was to also process
requirements-test.txt
inside the base image, but this increases +53% image size:Remember that this base Dockerfile will be the one used for everything (CI, CD, ...)
Another option was to integrate the
requirements-test.txt
processing inside theapp
entrypoint, or inside an specific task to be invoked, but it's very slow and complicates the development experience.We could also duplicate the docker-file with an specific testing definition, but maybe can introduce some non needed complexity. This way can be studied in short if we need it :)
Used https://github.com/krom/docker-compose-makefile to simplify Makefile definition (just 40kB)
Code formating
Done