I have the following Dockerfile:
FROM openjdk:17-jdk-alpine
WORKDIR /booking
COPY . .
RUN apk add --no-cache curl tar bash
ENV MAVEN_VERSION 3.6.3
ENV MAVEN_HOME /usr/lib/mvn
ENV PATH $MAVEN_HOME/bin:$PATH
RUN mkdir -p /usr/lib/mvn \
&& curl -fsSL http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz \
| tar -xzC /usr/lib/mvn --strip-components=1 \
&& ln -s /usr/lib/mvn/bin/mvn /usr/bin/mvn
RUN mvn clean install
EXPOSE 8080
CMD ["java", "-jar", "./target/booking-0.0.1-SNAPSHOT.jar"]
and this docker-compose.yml file:
version: "3.9"
services:
mongo:
image: mongo:latest
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: secret
MONGO_INITDB_DATABASE: booking
ports:
- "27018:27017"
api:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
depends_on:
mongo:
condition: service_completed_successfully
and the pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.8</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.be</groupId>
<artifactId>booking</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>booking</name>
<description>Project be booking</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
When I try to run docker-compose up with above settings I receive this error:
9.690 [ERROR] [ERROR] Some problems were encountered while processing the POMS:
9.705 [FATAL] Non-resolvable parent POM for com.be:booking:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot: spring-boot-starter-parent:pon:2.7.8 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.7.8/spring-boot-starter-parent-2.7.8.pom and 'parent.relativePath points at wrong local POM # line 5, column 10
9.722 #
9.725 [ERROR] The build could not read 1 project [Help 1]
9.727 [ERROR]
9.735 [ERROR] The project com.be: booking: 0.8.1-SNAPSHOT (/booking/pom.xml) has 1 error
9.735 [ERROR] Non-resolvable parent POM for com.be:booking:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.7.8 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.7.8/spring-boot-starter-parent-2.7.8.pom and parent.relativePath points at wrong local POM # Line 5, column 18: Unknown host repo.maven.apache.org: Try again → [Help 2]
9.753 [ERROR]
I don't know how to fix it yet.
I tried docker compose up serveral times because I thought my internet traffic has problem but still receive this error.
Related
I am trying to build an image for Kotlin/Spring Boot application. But when I run docker build I get the following error:
[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.7.20:compile (compile) on project download-common: Compilation failure
[ERROR] java.lang.IllegalStateException: Unable to find extension point configuration extensions/compiler.xml (cp:
[ERROR] null)
[ERROR] at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerApplicationExtensionPointsAndExtensionsFrom(KotlinCoreEnvironment.kt:612)
[ERROR] at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createApplicationEnvironment(KotlinCoreEnvironment.kt:587)
[ERROR] at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.getOrCreateApplicationEnvironment(KotlinCoreEnvironment.kt:518)
[ERROR] at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.getOrCreateApplicationEnvironmentForProduction(KotlinCoreEnvironment.kt:499)
[ERROR] at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:443)
[ERROR] at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:192)
[ERROR] at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:143)
[ERROR] at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53)
[ERROR] at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:99)
[ERROR] at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:47)
[ERROR] at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
[ERROR] at org.jetbrains.kotlin.maven.KotlinCompileMojoBase.execCompiler(KotlinCompileMojoBase.java:228)
[ERROR] at org.jetbrains.kotlin.maven.K2JVMCompileMojo.execCompiler(K2JVMCompileMojo.java:237)
[ERROR] at org.jetbrains.kotlin.maven.K2JVMCompileMojo.execCompiler(K2JVMCompileMojo.java:55)
[ERROR] at org.jetbrains.kotlin.maven.KotlinCompileMojoBase.execute(KotlinCompileMojoBase.java:209)
[ERROR] at org.jetbrains.kotlin.maven.K2JVMCompileMojo.execute(K2JVMCompileMojo.java:222)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:370)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:351)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:171)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:163)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:294)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:960)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[ERROR]
[ERROR]
[ERROR] -> [Help 1]
The code compiles just fine when I run the same mvn clean install -e on my local machine without docker. After a bit of Googling, I added the below entry to plugins. The requiresUnpack section.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<configuration>
<requiresUnpack>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-compiler</artifactId>
</dependency>
</requiresUnpack>
</configuration>
</plugin>
My Dockerfile is:
# AS <NAME> to name this stage as maven
FROM scratch
LABEL MAINTAINER="Sam"
#SETUP Ubuntu ENVIRONMENT
FROM ubuntu:latest as ubuntu
RUN export http_proxy=MY_PROXY_URL && export https_proxy=MY_PROXY_HTTPS_URL
#INSTALL JAVA
FROM eclipse-temurin:11-jdk-alpine AS jdk
#INSTALL MAVEN
FROM maven:3.8.6-eclipse-temurin-11-alpine AS maven
COPY settings.xml /usr/share/maven/conf/
RUN apk update && apk add git && apk add net-tools procps openssh-client openssh-server
RUN mkdir -p $HOME/images/lib/ && cd $HOME/images/lib/
RUN git clone MY_GIT_URL
WORKDIR /download_code
RUN git checkout feature/docker-branch
RUN mvn clean install -e
It is a SpringBoot Application with Kotlin. And if its of any use, I am on Windows 10.
But I still get the same error. Any pointers would be helpful.
I have a dockerfile which is like:
# openjdk:11-jre include 'wget' and 'curl', while openjdk:11-jre-slim does not
FROM openjdk:11-jre
ENV VERSION=2.28.1
ENV DIR=/home/wiremock
ENV JAR=wiremock-jre8-standalone-$VERSION.jar
ENV FULLPATH=$DIR/$JAR
# grab wiremock standalone jar
RUN mkdir -p $DIR
RUN useradd --no-log-init -r wiremock
RUN wget https://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-jre8-standalone/$VERSION/$JAR \
-O $FULLPATH
WORKDIR $DIR
# copy stub files to container
COPY --chown=wiremock:root src/main/resources/stubs/__files __files/
COPY --chown=wiremock:root src/main/resources/stubs/mappings mappings/
USER wiremock
EXPOSE 8080 8443
# healthcheck(wait 10s to start, then wait 10s interval and check, if wait more than 1s, is fail. Retry 3 times
# with same interval before marking as unhealthy)
HEALTHCHECK --start-period=10s --interval=10s --timeout=1s --retries=3 \
CMD curl http://localhost:8080/__admin && curl -k https://localhost:8443/__admin || exit 1
CMD java -jar $FULLPATH --https-port 8443 --verbose
Now, I cannot find a proper way to do it with maven-jib-plugin.
The dependency will be copied as a dependency, not downloaded with wget:
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8-standalone</artifactId>
<version>${wiremock.standalone.version}</version>
<scope>runtime</scope>
</dependency>
But I am not sure if all things can be done in jib, like creating user and so.
Now, I have this pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>foo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>app</artifactId>
<properties>
<docker.registry>xxx</docker.registry>
<docker.base.image>${docker.registry}/base/openjdk11:latest</docker.base.image>
<docker.image>app</docker.image>
<https.port>8443</https.port>
<work.dir>/home/wiremock</work.dir>
<jar>wiremock-jre8-standalone-${wiremock.standalone.version}.jar</jar>
<full.path>${work.dir}/${jar}</full.path>
</properties>
<dependencies>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8-standalone</artifactId>
<version>${wiremock.standalone.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/libs</outputDirectory>
<includeArtifactIds>wiremock-jre8-standalone</includeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<from>
<image>${docker.base.image}</image>
</from>
<to>
<image>${docker.image}</image>
<tags>
<tag>latest</tag>
</tags>
</to>
<extraDirectories>
<paths>
<path>
<from>libs/</from>
<into>${work.dir}</into>
</path>
<path>
<from>src/main/resources/stubs/__files</from>
<into>${work.dir}/__files</into>
</path>
<path>
<from>src/main/resources/stubs/mappings</from>
<into>${work.dir}/mappings</into>
</path>
</paths>
<permissions>
<permission>
<file>${work.dir}/**/*.*</file>
<mode>744</mode>
</permission>
</permissions>
</extraDirectories>
<container>
<user>wiremock:root</user>
<appRoot>${work.dir}</appRoot>
<workingDirectory>${work.dir}</workingDirectory>
<ports>
<port>8080</port>
<port>${https.port}</port>
</ports>
<args> <!-- dockerfile CMD part-->
<arg>-jar</arg>
<arg>${full.path}</arg>
<arg>--https-port</arg>
<arg>${https.port}</arg>
<arg>--verbose</arg>
</args>
<mainClass>com.github.tomakehurst.wiremock.standalone.WireMockServerRunner</mainClass>
</container>
<!-- <containerizingMode>packaged</containerizingMode> -->
</configuration>
</plugin>
</plugins>
</build>
</project>
When I run mvn jib:dockerBuild, the image is built successfully(good news!), I see in log the dependency jar is copied to libs, and then copied into container.
But then when I run it, I see error:
docker: Error response from daemon: unable to find user wiremock: no matching entries in passwd file.
So jib did not create the user for me.
Also, I think HEALTHCHECK is not done, neither.
I can skip new user creation and healthcheck, as they are not recommended and not supported now(https://github.com/GoogleContainerTools/jib/issues/676, https://github.com/GoogleContainerTools/jib/issues/1029), but when I want to run the jar like I do in dockerfile, I see another error:
$ docker run -p 8080:8080 -p 8443:8443 app
Exception in thread "main" joptsimple.UnrecognizedOptionException: j is not a recognized option
at joptsimple.OptionException.unrecognizedOption(OptionException.java:108)
at joptsimple.OptionParser.validateOptionCharacters(OptionParser.java:633)
at joptsimple.OptionParser.handleShortOptionCluster(OptionParser.java:528)
at joptsimple.OptionParser.handleShortOptionToken(OptionParser.java:523)
at joptsimple.OptionParserState$2.handleArgument(OptionParserState.java:59)
at joptsimple.OptionParser.parse(OptionParser.java:396)
at com.github.tomakehurst.wiremock.standalone.CommandLineOptions.<init>(CommandLineOptions.java:179)
at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.run(WireMockServerRunner.java:52)
at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.main(WireMockServerRunner.java:134)
I see the image is built like this:
[INFO] Container entrypoint set to [java, -cp, #/home/wiremock/jib-classpath-file, com.github.tomakehurst.wiremock.standalone.WireMockServerRunner]
[INFO] Container program arguments set to [-jar, /home/wiremock/wiremock-jre8-standalone-2.28.1.jar, --https-port, 8443, --verbose]
How can I properly translate this dockerfile into a jib configuration in XML?
Well, at last I found it:
I should set <container><entrypoint>, and not <args>. <mainClass> is not needed.
<container>
...
<entrypoint>java,-jar,${full.path},--https-port,${https.port},--verbose</entrypoint>
</container>
<!-- <containerizingMode>packaged</containerizingMode>-->
Then the entrypoint is like:
[INFO] Container entrypoint set to [java, -jar, /home/wiremock/wiremock-jre8-standalone-2.28.1.jar, --https-port, 8443, --verbose]
And the wiremock jar is running correctly.
I have been using Dockerfile for my project with a sample code like given below.
RUN groupadd syslog && apt-get update && apt-get -q install -y curl logrotate iproute2
I would like to convert this to pom.xml so that other micro-services can inherit it.
I surely cannot add this under build tag as I cannot and don't want this to get executed at the build time, I rather want this to set up logrotate in the container when the container starts up.
I tried adding few run commands, but that did not work. I am trying to understand which XML tag needs to be used for making sure my container RUNs the command on start up?
Your guidance will be highly appreciated.
Try runs:
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<runs>
<run>groupadd syslog</run>
<run>apt-get update</run>
<run>apt-get -q install -y curl logrotate iproute2</run>
</runs>
</configuration>
</plugin>
Scenario: I have a Spring Boot Cloud Config working properly locally. i want to run it inside of my Docker Container. I have tried several approaches and I am still getting the error pasted in this thread.
I can see it is somehow related to Git but I can't think something I am doing wrong. I have created a VOLUME and pointed it to my local git repository outside of Docker.
Since I don't know what exactly has been complained I am very confused what try also. I guess this error is raised by Spring Boot because it is trying to reach the git repository outside of Docker container.
In case it is relevant, I am using CentOs.
dockerfile:
FROM openjdk:8-jre-alpine
MAINTAINER jimis
COPY files/config-server-0.0.1-SNAPSHOT.jar /opt/spring-cloud/lib/
ENV SPRING_APPLICATION_JSON='{"spring": {"cloud": {"config": {"server":{"git": {"uri": "/var/lib/spring-cloud/config-repo","clone-on-start": true}}}}}}'
ENTRYPOINT ["/usr/bin/java"]
CMD ["-jar", "/opt/spring-cloud/lib/config-server-0.0.1-SNAPSHOT.jar"]
VOLUME /home/jimis/_d/GITs/spring_cloud_config_server
EXPOSE 8888
pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.mybank</groupId>
<artifactId>config-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>config-server</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
application.properties:
server.port=8888
spring.cloud.config.server.git.uri=/home/jimis/_d/GITs/spring_cloud_config_server
spring.cloud.config.server.git.clone-on-start=true
management.security.enabled=true
spring.autoconfigure.exclude=org.springframawork.boot.autoconfigure.SecurityAutoConfiguration
*** edited
all logs:
[jimis#my-centos spring_cloud_config_server]$ ls
config-client-development.properties config-client-production.properties
[jimis#my-centos spring_cloud_config_server]$ ]git status
bash: ]git: command not found
[jimis#my-centos spring_cloud_config_server]$ git init
Reinitialized existing Git repository in /home/jimis/_d/GITs/spring_cloud_config_server/.git/
[jimis#my-centos spring_cloud_config_server]$ git add .
[jimis#my-centos spring_cloud_config_server]$ git commit -m 'a'
[master (root-commit) 17b27ee] a
2 files changed, 2 insertions(+)
create mode 100644 config-client-development.properties
create mode 100644 config-client-production.properties
[jimis#my-centos spring_cloud_config_server]$ docker build --file=Dockerfile.jce --tag=config-server:latest --rm=true .unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/jimis/_d/GITs/spring_cloud_config_server/Dockerfile.jce: no such file or directory
[jimis#my-centos spring_cloud_config_server]$ cd /_d
bash: cd: /_d: No such file or directory
[jimis#my-centos spring_cloud_config_server]$ cd /home/jimis/_d
[jimis#my-centos _d]$ ls
docker_containers DOckerfile GITs postman-collections tools wiki_personal WSs
[jimis#my-centos _d]$ cd docker_containers/
[jimis#my-centos docker_containers]$ ls
docker-compose.yml dockerfile temp index.html?tab=images test
[jimis#my-centos docker_containers]$ cd test/
[jimis#my-centos test]$ ls
Dockerfile Dockerfile.j Dockerfile.jce files
[jimis#my-centos test]$ docker build --file=Dockerfile.jce --tag=config-server:latest --rm=true .
Sending build context to Docker daemon 30.3MB
Step 1/8 : FROM openjdk:8-jre-alpine
---> ce8477c7d086
Step 2/8 : MAINTAINER jimis
---> Using cache
---> 9374f15ccee8
Step 3/8 : COPY files/config-server-0.0.1-SNAPSHOT.jar /opt/spring-cloud/lib/
---> Using cache
---> f51755b312a3
Step 4/8 : ENV SPRING_APPLICATION_JSON='{"spring": {"cloud": {"config": {"server":{"git": {"uri": "/var/lib/spring-cloud/config-repo","clone-on-start": true}}}}}}'
---> Using cache
---> e74d751a834e
Step 5/8 : ENTRYPOINT ["/usr/bin/java"]
---> Using cache
---> 9cc07b037942
Step 6/8 : CMD ["-jar", "/opt/spring-cloud/lib/config-server-0.0.1-SNAPSHOT.jar"]
---> Using cache
---> 6296a8af03c6
Step 7/8 : VOLUME /home/jimis/_d/GITs/spring_cloud_config_server
---> Running in a0e8feb850df
Removing intermediate container a0e8feb850df
---> f965c6e77ebb
Step 8/8 : EXPOSE 8888
---> Running in d96dd08fb766
Removing intermediate container d96dd08fb766
---> a43058934ad5
Successfully built a43058934ad5
Successfully tagged config-server:latest
[jimis#my-centos test]$ /home/jimis/_d/GITs/s^C
[jimis#my-centos test]$ docker volume create --name=vol-repo
vol-repo
[jimis#my-centos test]$ docker run --name=config-server --publish=8888:8888 --volume=vol-repo:/home/jimis/_d/GITs/spring_cloud_config_server config-server:latest
docker: Error response from daemon: Conflict. The container name "/config-server" is already in use by container "4621a6a3b2e6a9c49fba805549b94bbf4cb4373f941f27ab1d2d3a82fe13854b". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
[jimis#my-centos test]$ docker container prune
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
4621a6a3b2e6a9c49fba805549b94bbf4cb4373f941f27ab1d2d3a82fe13854b
f96bf8a70ff5f6398ebe8729718c1946a12db2fae8390f1f54bfca42b67e4da2
Total reclaimed space: 0B
[jimis#my-centos test]$ docker run --name=config-server --publish=8888:8888 --volume=vol-repo:/home/jimis/_d/GITs/spring_cloud_config_server config-server:latest
2019-04-12 17:47:48.805 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$aa804fc0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.3.RELEASE)
2019-04-12 17:47:49.097 INFO 1 --- [ main] c.m.c.ConfigServerApplication : No active profile set, falling back to default profiles: default
2019-04-12 17:47:50.511 INFO 1 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=11be5ef3-61b1-3539-a246-b6326ba4f12c
2019-04-12 17:47:50.562 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$aa804fc0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-04-12 17:47:51.008 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8888 (http)
2019-04-12 17:47:51.070 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-04-12 17:47:51.071 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.16]
2019-04-12 17:47:51.094 INFO 1 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2019-04-12 17:47:51.367 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-04-12 17:47:51.368 INFO 1 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2242 ms
2019-04-12 17:47:52.428 WARN 1 --- [ main] .c.s.e.MultipleJGitEnvironmentRepository : Error occured cloning to base directory.
org.eclipse.jgit.api.errors.InvalidRemoteException: Invalid remote: origin
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:251) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar!/:5.1.3.201810200350-r]
at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:306) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar!/:5.1.3.201810200350-r]
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:200) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar!/:5.1.3.201810200350-r]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.cloneToBasedir(JGitEnvironmentRepository.java:589) [spring-cloud-config-server-2.1.1.RELEASE.jar!/:2.1.1.RELEASE]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.initClonedRepository(JGitEnvironmentRepository.java:340) [spring-cloud-config-server-2.1.1.RELEASE.jar!/:2.1.1.RELEASE]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.afterPropertiesSet(JGitEnvironmentRepository.java:256) [spring-cloud-config-server-2.1.1.RELEASE.jar!/:2.1.1.RELEASE]
at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.afterPropertiesSet(MultipleJGitEnvironmentRepository.java:66) [spring-cloud-config-server-2.1.1.RELEASE.jar!/:2.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1821) [spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1758) [spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) [spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) [spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) [spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) [spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) [spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1463) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1427) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1318) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1205) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1167) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:668) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1395) [spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) [spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) [spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) [spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE]
When running 'npm install' in a Jenkins Docker container I get these errors:
[INFO] --- exec-maven-plugin:1.6.0:exec (npm install) # geosolutions ---
npm WARN tar ENOENT: no such file or directory, open '/var/jenkins_home/workspace/aproject2/node_modules/.staging/schema-utils-bdceae78/package.json'
npm WARN tar ENOENT: no such file or directory, open '/var/jenkins_home/workspace/aproject2/node_modules/.staging/schema-utils-bdceae78/README.md'
...(and many lines like) ...
npm WARN tar ENOENT: no such file or directory, futime
npm WARN tar ENOENT: no such file or directory, futime
npm WARN tar ENOENT: no such file or directory, futime
npm WARN tar ENOENT: no such file or directory, futime
No 'node_modules' are generated. Only a few in node_modules/.staging.
When going into the Jenkins Docker container, I can fix this by manually performing:
rm -rf node_modules
rm -f package-lock.json
npm install
The next time I have to skip the 'npm install' step, so directly start with the 'ng build'. Then everything works OK. Of couse - this is not a decent workaround. Therefore this is NOT a duplicate question.
How can I do a good 'npm install'?
In my Jenkins container I have a Node/Npm installation. Npm is 6.5 and node is either 8, 9, 10 or 11. All with the newest npm 6.5.
My Jenkins image contains this code for adding npm/nodejs to it:
RUN apt-get install -y curl \
&& curl -sL https://deb.nodesource.com/setup_9.x | bash - \
&& apt-get install -y nodejs \
&& curl -L https://www.npmjs.com/install.sh | sh
Update: Today I had the same issue at the office. Two different Jenkinsjobs start the very same Maven task with 'npm install'. One is OK, the other not. One Jenkinsjob is started via a multibranch, the other as a regular pipeline. Hmm, very strange.
I think this has to do with the operating environment, so the $PATH, environment variables, etc.
After talking to a number of experts and reading a lot of forum posts, the following is the proposed 'workaround'. Many people use the workaround. I hope you have a better solution than this one. At least, this workaround works.
Following the workaround, building Angular in Maven can go like this: first clear the workspace, especially removing the node_modules folder and the package-lock.json file. Then start the npm install and the build action.
If you are in a hurry after creating your first build, just add a property 'maven.exec.skip', and start Maven with the -P maven.exec.skip=true. Then the cleaning and npm install step are skipped ;-)
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>npm clear workspace</id>
<goals>
<goal>exec</goal>
</goals>
<phase>initialize</phase>
<configuration>
<skip>${maven.exec.skip}</skip>
<executable>rm</executable>
<arguments>
<argument>-rf</argument>
<argument>node_modules</argument>
<argument>package-lock.json</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>exec</goal>
</goals>
<phase>initialize</phase>
<configuration>
<skip>${maven.exec.skip}</skip>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>build Angular production code</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>build</argument>
<!--<argument>--prod</argument>-->
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Facing the Same Issue steps to resolve your issue.
npm WARN tar ENOENT: no such file or directory
steps used to solve:-
I) in Jenkins job go to your directory and do
rm -rf package-lock.json
npm -i