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

feat(core): Image build (Dockerfile support) #585

Merged
merged 3 commits into from
May 31, 2024

Conversation

Tranquility2
Copy link
Contributor

@Tranquility2 Tranquility2 commented May 27, 2024

As part of the effort described, detailed and presented on #559
(Providing the implementation for #83 - Docker file support and more)
This is the first PR (out of 4) that should provide all the groundwork to support image build.

This would allow users to use custom images:

  with DockerImage(path=".") as image:
            with DockerContainer(str(image)) as container:
                # Test something with/on custom image

Next in line is:
feat(core): Added SrvContainer
And later on:
feat(core): Added FastAPI module
feat(core): Added AWS Lambda module
(all of the above can be overviewed on #559)

Added DockerImage to core

Make sure all build related stuff are removed after

Fix Image related issues

Improve image removal code

Add test from docker client kwargs image

Added core test from image flow

Improve docstring for Image

Update core Readme to include image and full example

Fix usage of image name

Update test from image string

Replace image name with tag

Update image remove handling

Fix image usage doctest

Image build based on id

Image clean is now optional

Fixed doctest

Update log about image removal

Improve image related test flow

Refactor image related test flow
@juangon
Copy link

juangon commented May 29, 2024

Would be great having this 👍

@alexanderankin alexanderankin merged commit 54c88cf into testcontainers:main May 31, 2024
7 checks passed
alexanderankin added a commit that referenced this pull request Jun 18, 2024
As part of the effort described, detailed and presented on #559 
This is the seconds PR (out of 4) that should provide all the groundwork
to support containers running a server.


This would allow users to use custom images:
```python
with DockerImage(path=".", tag="test:latest") as image:
    with ServerContainer(port=9000, image=image) as srv:
        # Test something with/on the server using port 9000
```

Next in line are:
`feat(core): Added FastAPI module`
`feat(core): Added AWS Lambda module`

---
Based on the work done on #585
Expended from issue #83

---------

Co-authored-by: David Ankin <[email protected]>
alexanderankin pushed a commit that referenced this pull request Jun 20, 2024
🤖 I have created a release *beep* *boop*
---


##
[4.6.0](testcontainers-v4.5.1...testcontainers-v4.6.0)
(2024-06-18)


### Features

* **core:** Added ServerContainer
([#595](#595))
([0768490](0768490))
* **core:** Image build (Dockerfile support)
([#585](#585))
([54c88cf](54c88cf))


### Bug Fixes

* Add Cockroach DB Module to Testcontainers
([#608](#608))
([4aff679](4aff679))
* Container for Milvus database
([#606](#606))
([ec76df2](ec76df2))
* move TESTCONTAINERS_HOST_OVERRIDE to config.py
([#603](#603))
([2a5a190](2a5a190)),
closes
[#602](#602)
* **mqtt:** Add mqtt.MosquittoContainer
([#568](#568))
([#599](#599))
([59cb6fc](59cb6fc))


### Documentation

* **main:** Private registry
([#598](#598))
([9045c0a](9045c0a))
* Update private registry instructions
([#604](#604))
([f5a019b](f5a019b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
alexanderankin pushed a commit that referenced this pull request Jun 28, 2024
As part of the effort described, detailed and presented on
#559
This is the third PR (out of 4) that should provide all the groundwork
to support containers running a server.

As discussed on #595 this PR aims to refactor the `ServerContainer`
under a new dedicated module called "generic".

![image](https://github.com/testcontainers/testcontainers-python/assets/7189138/b7a3395b-ce3c-40ef-8baa-dfa3eff1b056)

The idea is that this module could include multiple generic
implementations such as ```server.py``` with the proper documentation
and examples to allow users simpler usage and QOL.
This PR adds the original FastAPI implementation as a simple doc
example, I think this aligns better following #595
        
Next in line is ```feat(core): Added AWS Lambda module```

Based on the work done on
#585 and
#595
Expended from issue
#83

---
Please note an extra commit is included to simulate the relations when
importing between and with other modules.
alexanderankin pushed a commit that referenced this pull request Jul 31, 2024
As part of the effort described, detailed and presented on
#559
This is the 4th (and final in this track) PR that should provide support
for AWS Lambda containers.

This module will add the ability to test and run Amazon Lambdas (using
the built-in runtime interface emulator)
For example:

```python
from testcontainers.aws import AWSLambdaContainer
from testcontainers.core.waiting_utils import wait_for_logs
from testcontainers.core.image import DockerImage

with DockerImage(path="./modules/aws/tests/lambda_sample", tag="test-lambda:latest") as image:
    with AWSLambdaContainer(image=image, port=8080) as func:
        response = func.send_request(data={'payload': 'some data'})
        assert response.status_code == 200
        assert "Hello from AWS Lambda using Python" in response.json()
        delay = wait_for_logs(func, "START RequestId:")
```

This can (and probably will) be used with the provided
[LocalStackContainer](https://testcontainers-python.readthedocs.io/en/latest/modules/localstack/README.html)
to help simulate more advance AWS cases.

---

Based on the work done on:
- #585 
- #595 
- #612

Expended from issue
#83
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.

3 participants