|
1 | | -# Labspace starter |
| 1 | +# Labspace - Introduction to Testcontainers - Java |
2 | 2 |
|
3 | | -This repository is intended to server as a template to help bootstrap a new Labspace. |
| 3 | +Containers can be used for more than simply running your application. With Testcontainers, you can use containers to easily start the services needed by your application. |
4 | 4 |
|
5 | | -## Instructions |
| 5 | +In this Labspace, you'll learn how to use Testcontainers in a Spring-based application. |
6 | 6 |
|
7 | | -1. Create a new repository using this repo as the template ([docs here](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template)). |
| 7 | +## Learning objectives |
8 | 8 |
|
9 | | - **NOTE:** After creating the repo, a GHA workflow will run to do some additional bootstrapping. The bootstrapping workflow file will be removed during bootstrapping. |
| 9 | +By the end of this Labspace, you will have learned the following: |
10 | 10 |
|
11 | | -2. Clone your newly created repo to your local machine |
| 11 | +- Write end-to-end API tests using real services instead of mocks |
| 12 | +- How to autowire Spring config to use containerized databases |
| 13 | +- How to use GenericContainer to provide additional services and wire them with `@DynamicPropertySource` |
12 | 14 |
|
13 | | -3. Start the local development mode: |
| 15 | +## Launch the Labspace |
14 | 16 |
|
15 | | - ```bash |
16 | | - # On Mac/Linux |
17 | | - CONTENT_PATH=$PWD docker compose -f oci://dockersamples/labspace-content-dev -f .labspace/compose.override.yaml up |
| 17 | +To launch the Labspace, run the following command: |
18 | 18 |
|
19 | | - # On Windows with PowerShell |
20 | | - $Env:CONTENT_PATH = (Get-Location).Path; docker compose -f oci://dockersamples/labspace-content-dev -f .labspace/compose.override.yaml up |
21 | | - ``` |
| 19 | +```bash |
| 20 | +docker compose -f oci://dockersamples/labspace-testcontainers-java up -d |
| 21 | +``` |
22 | 22 |
|
23 | | -4. Update the `labspace.yaml` with your Labspace's title and description |
| 23 | +And then open your browser to http://localhost:3030. |
24 | 24 |
|
25 | | -5. Write your Labspace! Being in dev mode, your changes should be visible in the interface without a restart. Feel free to edit either on your host machine or in the Labspace itself! |
| 25 | +### Using the Docker Desktop extension |
26 | 26 |
|
27 | | - Add any supporting application files or resources directly into the Labspace. This repo will be cloned into the Labspace at startup. |
| 27 | +If you have the Labspace extension installed (`docker extension install dockersamples/labspace-extension` if not), you can also [click this link](https://open.docker.com/dashboard/extension-tab?extensionId=dockersamples/labspace-extension&location=dockersamples/labspace-testcontainers-javaimages&title=Introduction%20to%20Testcontainers%20-%20Java) to launch the Labspace. |
28 | 28 |
|
29 | | - Be sure to check out the [docs](https://github.com/dockersamples/labspace-infra/tree/main/docs) for additional information and guidelines. |
30 | 29 |
|
| 30 | +## Contributing |
31 | 31 |
|
| 32 | +If you find something wrong or something that needs to be updated, feel free to submit a PR. If you want to make a larger change, feel free to fork the repo into your own repository. |
32 | 33 |
|
33 | | -### Setting up the deployment pipeline |
| 34 | +**Important note:** If you fork it, you will need to update the GHA workflow to point to your own Hub repo. |
34 | 35 |
|
35 | | -The template repo contains a workflow file to make it easy to publish your Labspace. |
| 36 | +1. Clone this repo |
36 | 37 |
|
37 | | -1. Add GitHub Action Secrets in your new repo for the following: |
| 38 | +2. Start the Labspace in content development mode: |
38 | 39 |
|
39 | | - - `DOCKERHUB_USERNAME` - the username to authenticate to Docker Hub with |
40 | | - - `DOCKERHUB_TOKEN` - a personal or organization access token to use for authentication |
| 40 | + ```bash |
| 41 | + # On Mac/Linux |
| 42 | + CONTENT_PATH=$PWD docker compose up --watch |
41 | 43 |
|
42 | | -2. In the `.github/workflows/publish-labspace.yaml.temp` file, update the `DOCKERHUB_REPO` with the name of the Docker Hub repo you want to publish to. |
| 44 | + # On Windows with PowerShell |
| 45 | + $Env:CONTENT_PATH = (Get-Location).Path; docker compose up --watch |
| 46 | + ``` |
43 | 47 |
|
44 | | -3. Rename the workflow file to remove the `.temp` extension. |
| 48 | +3. Open the Labspace at http://localhost:3030. |
45 | 49 |
|
46 | | - ```bash |
47 | | - mv .github/workflows/publish-labspace.yaml.temp .github/workflows/publish-labspace.yaml |
48 | | - ``` |
| 50 | +4. Make the necessary changes and validate they appear as you expect in the Labspace |
| 51 | + |
| 52 | + Be sure to check out the [docs](https://github.com/dockersamples/labspace-infra/tree/main/docs) for additional information and guidelines. |
0 commit comments