Skip to content
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

Implement cache from #4310

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compose/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@

ALLOWED_KEYS = DOCKER_CONFIG_KEYS + [
'build',
'cachefrom',
'container_name',
'dockerfile',
'log_driver',
Expand Down
5 changes: 3 additions & 2 deletions compose/config/config_schema_v2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@
{
"type": "object",
"properties": {
"args": {"$ref": "#/definitions/list_or_dict"},
"cachefrom": {"$ref": "#/definitions/list_of_strings"},
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I allowed to add it to the 2.0 schema?

"context": {"type": "string"},
"dockerfile": {"type": "string"},
"args": {"$ref": "#/definitions/list_or_dict"}
"dockerfile": {"type": "string"}
},
"additionalProperties": false
}
Expand Down
5 changes: 3 additions & 2 deletions compose/config/config_schema_v2.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@
{
"type": "object",
"properties": {
"args": {"$ref": "#/definitions/list_or_dict"},
"cachefrom": {"$ref": "#/definitions/list_of_strings"},
"context": {"type": "string"},
"dockerfile": {"type": "string"},
"args": {"$ref": "#/definitions/list_or_dict"}
"dockerfile": {"type": "string"}
},
"additionalProperties": false
}
Expand Down
5 changes: 3 additions & 2 deletions compose/config/config_schema_v3.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@
{
"type": "object",
"properties": {
"args": {"$ref": "#/definitions/list_or_dict"},
"cachefrom": {"$ref": "#/definitions/list_of_strings"},
"context": {"type": "string"},
"dockerfile": {"type": "string"},
"args": {"$ref": "#/definitions/list_or_dict"}
"dockerfile": {"type": "string"}
},
"additionalProperties": false
}
Expand Down
1 change: 1 addition & 0 deletions compose/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ def build(self, no_cache=False, pull=False, force_rm=False):
nocache=no_cache,
dockerfile=build_opts.get('dockerfile', None),
buildargs=build_opts.get('args', None),
cachefrom=build_opts.get('cachefrom', None),
)

try:
Expand Down
14 changes: 14 additions & 0 deletions tests/integration/service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,20 @@ def test_build_with_build_args(self):
service.build()
assert service.image()

@v2_only()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct?

def test_build_with_cachefrom(self):
base_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, base_dir)

with open(os.path.join(base_dir, 'Dockerfile'), 'w') as f:
f.write("FROM busybox\n")

service = self.create_service('cachefrom',
build={'context': base_dir,
'cachefrom': ['build1']})
service.build()
assert service.image()

def test_start_container_stays_unprivileged(self):
service = self.create_service('web')
container = create_and_start_container(service).inspect()
Expand Down