Skip to content

Commit

Permalink
Introduce dev-services profile to showcase Docker services features.
Browse files Browse the repository at this point in the history
  • Loading branch information
odrotbohm committed Jul 13, 2023
1 parent 9360978 commit 6465b34
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
27 changes: 27 additions & 0 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
</dependency>

</dependencies>

<profiles>
Expand Down Expand Up @@ -244,6 +254,23 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
</dependencies>
</profile>

<profile>

<id>dev-services</id>

<build>
<defaultGoal>spring-boot:test-run</defaultGoal>
</build>

<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
</dependencies>

</profile>

<!-- General AOT support -->

<profile>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springsource.restbucks;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean;
import org.testcontainers.containers.PostgreSQLContainer;

/**
* @author Oliver Drotbohm
*/
@TestConfiguration
public class TestApplication {

@Bean
@ServiceConnection
PostgreSQLContainer<?> postgres() {
return new PostgreSQLContainer<>("postgres:latest");
}

public static void main(String[] args) {
SpringApplication.from(Restbucks::main)
.with(TestApplication.class)
.run(args);
}
}

0 comments on commit 6465b34

Please sign in to comment.