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

Support deploying with docker compose without local docker-compose #462

Closed
wants to merge 14 commits into from
Closed

Support deploying with docker compose without local docker-compose #462

wants to merge 14 commits into from

Conversation

fiftin
Copy link
Contributor

@fiftin fiftin commented Jun 14, 2022

Related to this issue: #425.

I added support conteinerised docker-compose. To do this I refectored compose.go and extracted ComposeExecutor which can be:

  • ContainerizedDockerComposeExecutor - uses docker-compose from docker container.
  • LocalDockerComposeExecutor - uses local docker-compose.

compose.go Show resolved Hide resolved
args := append(cmds, options.Args...)

req := ContainerRequest{
Image: "docker/compose:1.29.2",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wdyt about using a configurable version of compose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, will do

Copy link
Contributor Author

@fiftin fiftin Jun 16, 2022

Choose a reason for hiding this comment

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

I replaced ref to function to interface ComposeExecutor with 2 implementations.

@codecov
Copy link

codecov bot commented Jun 15, 2022

Codecov Report

Merging #462 (5eb916a) into main (28706cb) will decrease coverage by 1.26%.
The diff coverage is 68.85%.

❗ Current head 5eb916a differs from pull request most recent head 3246837. Consider uploading reports for the commit 3246837 to get more accurate results

@@            Coverage Diff             @@
##             main     #462      +/-   ##
==========================================
- Coverage   65.55%   64.29%   -1.27%     
==========================================
  Files          19       20       +1     
  Lines        1199     1305     +106     
==========================================
+ Hits          786      839      +53     
- Misses        305      354      +49     
- Partials      108      112       +4     
Impacted Files Coverage Δ
compose_executors.go 68.62% <68.62%> (ø)
compose.go 61.39% <70.00%> (-15.39%) ⬇️
container.go 87.23% <0.00%> (ø)
docker.go 66.48% <0.00%> (+0.78%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 28706cb...3246837. Read the comment docs.

return NewDockerCompose(filePaths, identifier, LocalDockerComposeExecutor, nil, opts...)
}

func NewContainerizedDockerCompose(filePaths []string, identifier string, opts ...LocalDockerComposeOption) *LocalDockerCompose {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still return a LocalDockerCompose? It seems weird to me to use a containerised compose method that returns a LocalDC.

I'd be open to using a dedicated DockerisedDockerCompose type, although I think could come with changes in return types and generalisation...

Of course, not a blocker for this PR, but if you are interested in following-up with more refactors to make a stable API, I'm too

Copy link
Contributor Author

@fiftin fiftin Jun 16, 2022

Choose a reason for hiding this comment

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

I started with creating dedicated DockerisedDockerCompose type, but got too many unreasonable duplications. Using current LocalDockerCompose with different executors is a best solution for my opinion.

IMHO: interface DockerCompose should be removed and type LocalDockerCompose should renamed to DockerCompose, new interface ComposeExecutor should be used for extensions.

Alternatively:

  1. Rename type LocalDockerCompose to DockerComposeXYZ.

  2. Define type LocalDockerCompose as alias of DockerComposeXYZ for back compatibility and mark it as deprecated:

// Deprecated: Use DockerComposeXYZ instead.
type `LocalDockerCompose` `DockerComposeXYZ`

As you can see I used existing docker-compose tests for containerized docker-compose and it is works out-of-box :)

compose_test.go Outdated
func enumDockerComposes(filePaths []string, identifier string, executor func(compose *LocalDockerCompose), t *testing.T) {
composes := []*LocalDockerCompose{
NewLocalDockerCompose(filePaths, identifier, WithLogger(TestLogger(t))),
NewContainerizedDockerCompose(filePaths, identifier, WithLogger(TestLogger(t))),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we are using the new Dockerised compose here. Could you update the docs with examples on how to use it? There is a dedicated section for compose in the docs/features dir.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@fiftin
Copy link
Contributor Author

fiftin commented Jun 16, 2022

I replaced ref to function to interface DockerComposeExecutor with 2 implementations: containerised implementation has field ComposeVersion.

Also I applied all LocalDockerCompose tests for ContainerizedDockerCompose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants