Build gradle:
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:2022.0.2"
}
}
docker run:
❯ docker run --name bib_authorization-service \ ─╯
-p 9000:9000 \
-d dameergamlet/bib-authorization-service:1.0-SNAPSHOT \
--restart=no
deployment:
jib {
from {
image = jibBaseDockerImage
}
to {
image = "${dockerHubUsername}/bib-${project.name}:${project.version}"
tags = [version, project.version] as List<String>
auth {
username = dockerHubUsername
password = dockerHubPassword
}
}
container {
format = jibImageFormat
getCreationTime().set(Instant.now().toString())
}
}
Resutl:
,--. ,--. ,--.
,--,--.,--.,--.,-' '-.| ,---. ,-----. ,---. ,---. ,--.--.,--. ,--.`--' ,---. ,---.
' ,-. || || |'-. .-'| .-. |'-----'( .-'| .-. :| .--' \ `' / ,--.| .--'| .-. :
\ '-' |' '' ' | | | | | | .-' `) --.| | \ / | |\ `--.\ --.
`--`--' `----' `--' `--' `--' `----' `----'`--' `--' `--' `---' `----'
Powered by Spring Boot 3.0.6
---------------------------------------------------------------------------------------------------------------------------------------------------
2023-08-28T15:28:10.269Z INFO 1 --- [ main] s.t.a.AuthorizationServiceApplication : Starting AuthorizationServiceApplication using Java 17.0.7 with PID 1 (/app/classes started by root in /)
2023-08-28T15:28:10.272Z INFO 1 --- [ main] s.t.a.AuthorizationServiceApplication : The following 1 profile is active: "default"
2023-08-28T15:28:10.316Z INFO 1 --- [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://127.0.0.1:8888
2023-08-28T15:28:10.316Z INFO 1 --- [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Exception on Url - http://127.0.0.1:8888:org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://127.0.0.1:8888/authorization-service/dev": Connection refused. Will be trying the next url if available
2023-08-28T15:28:10.316Z WARN 1 --- [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Could not locate PropertySource ([ConfigServerConfigDataResource@439a8f59 uris = array<String>['http://127.0.0.1:8888'], optional = true, profiles = list['default']]): I/O error on GET request for "http://127.0.0.1:8888/authorization-service/dev": Connection refused
2023-08-28T15:28:11.552Z INFO 1 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=9ba36e0a-f296-31f3-a926-c93f722e5b63
2023-08-28T15:28:11.864Z INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9000 (http)
2023-08-28T15:28:11.872Z INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
...
But locally everything works without problems:
,--. ,--. ,--.
,--,--.,--.,--.,-' '-.| ,---. ,-----. ,---. ,---. ,--.--.,--. ,--.`--' ,---. ,---.
' ,-. || || |'-. .-'| .-. |'-----'( .-'| .-. :| .--' \ `' / ,--.| .--'| .-. :
\ '-' |' '' ' | | | | | | .-' `) --.| | \ / | |\ `--.\ --.
`--`--' `----' `--' `--' `--' `----' `----'`--' `--' `--' `---' `----'
Powered by Spring Boot 3.0.6
---------------------------------------------------------------------------------------------------------------------------------------------------
2023-08-28T19:32:47.991+04:00 INFO 403957 --- [ main] s.t.a.AuthorizationServiceApplication : Starting AuthorizationServiceApplication using Java 17.0.8 with PID 403957 (/home/damir/Documents/THESIS/PROJECT/bibraryteka-backend/authorization-service/build/classes/java/main started by damir in /home/damir/Documents/THESIS/PROJECT/bibraryteka-backend)
2023-08-28T19:32:47.993+04:00 INFO 403957 --- [ main] s.t.a.AuthorizationServiceApplication : The following 1 profile is active: "default"
2023-08-28T19:32:48.038+04:00 INFO 403957 --- [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://127.0.0.1:8888
2023-08-28T19:32:48.038+04:00 INFO 403957 --- [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Located environment: name=authorization-service, profiles=[dev], label=null, version=9de19230902b655973e7555482bf0f852bebe9f1, state=null
2023-08-28T19:32:49.013+04:00 INFO 403957 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=769bf767-a828-32b8-8874-7e2c17f03dcf
2023-08-28T19:32:49.276+04:00 INFO 403957 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9000 (http)
2023-08-28T19:32:49.282+04:00 INFO 403957 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-08-28T19:32:49.282+04:00 INFO 403957 --- [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.8]
...
I can't link spring cloud and docker.
If someone was able to solve this problem - write. I can say for sure that there were no problems in another project with the same configuration.
Comment From: DameerGamlet
config-application:
server:
port: 8888
spring:
application:
name: config-server
cloud:
config:
server:
git:
default-label: develop
uri: https://github.com/URL
Comment From: blackr1234
This should be a Docker usage issue, not related to Spring at all.
See Docker's documentation: Networking with standalone containers.