I have a problem here! I cannot deploy spring boot application to AWS Elastic Beanstalk with eb cli using docker-compose.yml
Here my code!
Here my simple API
@RestController
@ConfigurationProperties(prefix = "test")
public class TestApi {
private String activeProfile;
@GetMapping
public Map<String, String> isWorking() {
return Map.of(
"WORKING", "true"
);
}
@GetMapping("active/profile")
public Map<String, String> showActiveProfile() {
return Map.of(
"SPRING_PROFILES_ACTIVE", activeProfile
);
}
public String getActiveProfile() {
return activeProfile;
}
public void setActiveProfile(String activeProfile) {
this.activeProfile = activeProfile;
}
}
And here my Dockerfile
FROM amazoncorretto:17
ARG JAR_FILE=target/docker-app-0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]
EXPOSE 5000
And docker-compose.yml
version: '3'
services:
spring-boot-prod-docker-app:
image: beksultancs/docker-app:2.0
# build:
# context: ./
# dockerfile: Dockerfile
ports:
- '80:5000'
environment:
- "SPRING_PROFILES_ACTIVE=prod"
I've 2 spring boot active profile
- DEFAULT inside default active profile
test.active_profile=DEFAULT
here only one line of code
- PROD inside application-prod.yml
test.active_profile=PRODUCTION server.port=5000
only two line
and when I tried deploy an application
with eb cli
$ eb init $ eb create
and here RESULT
2022-05-07 07:14:29 INFO Environment update is starting.
2022-05-07 07:14:33 INFO Deploying new version to instance(s).
2022-05-07 07:14:40 ERROR Instance deployment failed to build the Docker image. The deployment failed.
2022-05-07 07:14:40 ERROR Instance deployment failed. For details, see 'eb-engine.log'.
2022-05-07 07:14:43 ERROR [Instance: i-02fcf8292017f9e2e] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error..
2022-05-07 07:14:43 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2022-05-07 07:14:43 ERROR Unsuccessful command execution on instance id(s) 'i-02fcf8292017f9e2e'. Aborting the operation.
2022-05-07 07:14:44 ERROR Failed to deploy application.
Instance deployment failed to build the Docker image
cannot solve this problem? how I can deploy my application?
If you know another way to deploy spring boot application please leave a link to learn it or you can leave steps what to do?
thanks in advance!