steve icon indicating copy to clipboard operation
steve copied to clipboard

Fix #1316

Open juherr opened this issue 2 years ago • 5 comments

juherr avatar Dec 03 '23 17:12 juherr

@ml170722d Please, could you confirm the fix?

juherr avatar Dec 03 '23 17:12 juherr

Running the command gives me the following output:

steve(bugfix/github-1316): docker build --build-arg DB_HOST=localhost --build-arg DB_PORT=3306 --build-arg DB_USERNAME=xxxx --build-arg DB_PASSWORD=xxxx --build-arg DB_DATABASE=xxxx  -f k8s/docker/Dockerfile -t steve .
[+] Building 2.2s (21/21) FINISHED                                                                                                                                           docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                   0.0s
 => => transferring dockerfile: 970B                                                                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                                                        0.0s
 => resolve image config for docker.io/docker/dockerfile:1                                                                                                                             1.2s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:ac85f380a63b13dfcefa89046420e1781752bab202122f8f50032edf31be0021                                                        0.0s
 => [internal] load metadata for docker.io/library/eclipse-temurin:11-jdk                                                                                                              0.8s
 => [internal] load build context                                                                                                                                                      0.0s
 => => transferring context: 46.72kB                                                                                                                                                   0.0s
 => CACHED [stage-1 1/3] FROM docker.io/library/eclipse-temurin:11-jdk@sha256:b64ecd1a2c7ad6f12df1b2473070123b8312772fb6ebc4e1437b1783f9a91837                                         0.0s
 => CACHED [build  2/13] WORKDIR /code                                                                                                                                                 0.0s
 => CACHED [build  3/13] ADD /src /code/src                                                                                                                                            0.0s
 => CACHED [build  4/13] ADD /website /code/website                                                                                                                                    0.0s
 => CACHED [build  5/13] ADD /pom.xml /code/pom.xml                                                                                                                                    0.0s
 => CACHED [build  6/13] ADD /mvnw /code/mvnw                                                                                                                                          0.0s
 => CACHED [build  7/13] ADD /.mvn /code/.mvn                                                                                                                                          0.0s
 => CACHED [build  8/13] RUN sed -i 's|${db.ip}|${env.DB_HOST}|g' pom.xml                                                                                                              0.0s
 => CACHED [build  9/13] RUN sed -i 's|${db.port}|${env.DB_PORT}|g' pom.xml                                                                                                            0.0s
 => CACHED [build 10/13] RUN sed -i 's|${db.user}|${env.DB_USERNAME}|g' pom.xml                                                                                                        0.0s
 => CACHED [build 11/13] RUN sed -i 's|${db.password}|${env.DB_PASSWORD}|g' pom.xml                                                                                                    0.0s
 => CACHED [build 12/13] RUN sed -i 's|${db.schema}|${env.DB_DATABASE}|g' pom.xml                                                                                                      0.0s
 => CACHED [build 13/13] RUN ./mvnw clean package -Pkubernetes -Djdk.tls.client.protocols="TLSv1,TLSv1.1,TLSv1.2"                                                                      0.0s
 => CACHED [stage-1 2/3] COPY --from=build /code/target/steve.jar steve.jar                                                                                                            0.0s
 => ERROR [stage-1 3/3] COPY --from=build /code/libs libs                                                                                                                              0.0s
------
 > [stage-1 3/3] COPY --from=build /code/libs libs:
------
Dockerfile:40
--------------------
  38 |
  39 |     COPY --from=build /code/target/steve.jar steve.jar
  40 | >>> COPY --from=build /code/libs libs
  41 |
  42 |     CMD java -jar steve.jar
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 7ff1e483-3d12-4839-9a19-02597ce6fb66::zlfi7iq27u9mvcu7nhnhy7y9i: "/code/libs": not found

If I comment out the second stage of the build and create the image from first stage, I get an successful build. Running the image in interactive mode and list the working directory I get the following:

steve(bugfix/github-1316): docker run --rm -it steve:latest bash
root@ab883ec12621:/code# ls -la
total 68
drwxr-xr-x 1 root root  4096 Dec  3 17:51 .
drwxr-xr-x 1 root root  4096 Dec  3 18:09 ..
drwxr-xr-x 3 root root  4096 Dec  3 17:43 .mvn
-rwxr-xr-x 1 root root 10283 Dec  3 17:43 mvnw
-rw-r--r-- 1 root root 31543 Dec  3 17:51 pom.xml
drwxr-xr-x 4 root root  4096 Dec  3 17:43 src
drwxr-xr-x 9 root root  4096 Dec  3 17:52 target
drwxr-xr-x 4 root root  4096 Dec  3 17:43 website 

root@ab883ec12621:/code# tree -L 2
.
├── mvnw
├── pom.xml
├── src
│   ├── main
│   └── test
├── target
│   ├── classes
│   ├── generated-sources
│   ├── generated-test-sources
│   ├── libs
│   ├── maven-archiver
│   ├── maven-status
│   ├── steve.jar
│   └── test-classes
└── website
    ├── logo
    └── screenshots

I am guessing you want to copy the code/target/libs directory. When I change the copy location, the build is successful, but then there is a new problem:

steve(bugfix/github-1316) ✗: docker run --rm steve:latest
[INFO ] 2023-12-03 18:15:15,484 de.rwth.idsg.steve.utils.PropertiesFileLoader (main) - Hint: The Java system property 'main.properties' can be set to point to an external properties file, which will be prioritized over the bundled one
Exception in thread "main" java.lang.ExceptionInInitializerError
        at de.rwth.idsg.steve.Application.<init>(Application.java:40)
        at de.rwth.idsg.steve.Application.main(Application.java:63)
Caused by: java.lang.NumberFormatException: For input string: "$DB_PORT"
        at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.base/java.lang.Integer.parseInt(Integer.java:638)
        at java.base/java.lang.Integer.parseInt(Integer.java:770)
        at de.rwth.idsg.steve.utils.PropertiesFileLoader.getInt(PropertiesFileLoader.java:83)
        at de.rwth.idsg.steve.SteveConfiguration.<init>(SteveConfiguration.java:85)
        at de.rwth.idsg.steve.SteveConfiguration.<clinit>(SteveConfiguration.java:35)
        ... 2 more 

ml170722d avatar Dec 03 '23 18:12 ml170722d

Thanks for the feedback! 👍

In the latest issue, $DB_PORT is not replaced by the env value as expected and use the string value.

juherr avatar Dec 03 '23 18:12 juherr

@ml170722d Could check the fix and tell me if the command bellow solve the second issue?

docker run --rm --env DB_HOST=localhost --env DB_PORT=3306 --env DB_USERNAME=xxxx --env DB_PASSWORD=xxxx --env DB_DATABASE=xxxx steve:latest

juherr avatar Dec 05 '23 11:12 juherr

steve(bugfix/github-1316): docker run --rm --env DB_HOST=localhost --env DB_PORT=3306 --env DB_USERNAME=xxxx --env DB_PASSWORD=xxxx --env DB_DATABASE=xxxx steve:latest
[INFO ] 2024-01-07 20:04:29,401 de.rwth.idsg.steve.utils.PropertiesFileLoader (main) - Hint: The Java system property 'main.properties' can be set to point to an external properties file, which will be prioritized over the bundled one
[INFO ] 2024-01-07 20:04:29,489 de.rwth.idsg.steve.Application (main) - Loaded the properties. Starting with the 'PROD' profile
[INFO ] 2024-01-07 20:04:29,502 de.rwth.idsg.steve.Application (main) - Date/time zone of the application is set to UTC. Current date/time: 2024-01-07T20:04:29.495Z
Log file: Not available
Starting.[INFO ] 2024-01-07 20:04:29,675 org.eclipse.jetty.server.Server (main) - jetty-10.0.14; built: 2023-02-22T23:12:32.272Z; git: 976721d0f3e903a243584d47870ad2f2c1bf9e55; jvm 11.0.21+9
[INFO ] 2024-01-07 20:04:29,862 org.eclipse.jetty.server.handler.ContextHandler.steve (main) - No Spring WebApplicationInitializer types detected on classpath
[INFO ] 2024-01-07 20:04:29,897 org.eclipse.jetty.server.session.DefaultSessionIdManager (main) - Session workerName=node0
[INFO ] 2024-01-07 20:04:29,907 org.eclipse.jetty.server.handler.ContextHandler.steve (main) - Initializing Spring root WebApplicationContext
[INFO ] 2024-01-07 20:04:29,908 org.springframework.web.context.ContextLoader (main) - Root WebApplicationContext: initialization started
.[INFO ] 2024-01-07 20:04:30,651 com.zaxxer.hikari.HikariDataSource (main) - HikariPool-1 - Starting...
..[WARN ] 2024-01-07 20:04:31,836 org.springframework.web.context.support.AnnotationConfigWebApplicationContext (main) - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ocppConfiguration': Unsatisfied dependency expressed through field 'ocpp12Server'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'centralSystemService12_SoapServer': Unsatisfied dependency expressed through field 'service'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'centralSystemService16_Service': Unsatisfied dependency expressed through field 'ocppServerRepository'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ocppServerRepositoryImpl': Unsatisfied dependency expressed through field 'ctx'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dslContext' defined in de.rwth.idsg.steve.config.BeanConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.jooq.DSLContext]: Factory method 'dslContext' threw exception; nested exception is com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
 FAILED!
Please refer to the log file for details

I would say this is now ok and working. It failed probably because I am not running any dbs locally. The main thing is that Docker image can be build with no problems.

ml170722d avatar Jan 07 '24 20:01 ml170722d

superseded by https://github.com/steve-community/steve/pull/1611

goekay avatar Sep 17 '25 08:09 goekay