Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile to run this maven cache? #9

Open
jamshid opened this issue Feb 5, 2020 · 1 comment
Open

Dockerfile to run this maven cache? #9

jamshid opened this issue Feb 5, 2020 · 1 comment

Comments

@jamshid
Copy link

jamshid commented Feb 5, 2020

Found this project in a search, will give it a try, thanks! I'm having no end of problems using artifactory as a maven cache. Building maven projects in docker really needs a caching maven proxy since it's hard to share a ~/.m2/repository with docker builds.

I could try to make a Dockerfile to build and run this project. But sorry I'm not sure what the settings.xml should look like for this? Below is artifactory's, is this all that is needed?

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <servers>
    <server>
      <username>${security.getCurrentUsername()}</username>
      <password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
      <id>central</id>
    </server>
    <server>
      <username>${security.getCurrentUsername()}</username>
      <password>${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}</password>
      <id>snapshots</id>
    </server>
  </servers>
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>http://artifactory1:8081/artifactory/libs-release</url>
        </repository>
        <repository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>http://artifactory1:8081/artifactory/libs-snapshot</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>http://artifactory1:8081/artifactory/libs-release</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>http://artifactory1:8081/artifactory/libs-snapshot</url>
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>
@mbafford
Copy link

mbafford commented Feb 19, 2020

@jamshid
I just got this working (mostly) for a Maven build using this docker image:

docker run -p 5956:5956 --name tiny-maven-proxy slamdev/tiny-maven-proxy

Then running my mvn build steps using:

mvn -gs /opt/build/mvn-mirror-settings.xml <command>

With a /opt/build/mvn-mirror-settings.xml of:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <mirrors>
        <mirror>
            <id>tiny-maven-mirror</id>
            <name>tiny-maven-mirror</name>
            <url>http://192.168.99.101:5956/</url>
            <mirrorOf>maven2,central</mirrorOf>
        </mirror>
    </mirrors>
</settings>

Two problems in my tests:

  1. there is an issue with the maven build process hanging after a request is made through the proxy for an artifact the proxy can't find. I'm still tracking down why that's happening.
  2. This is faster than downloading the artifacts directly, for sure, but it's still a lot slower than directly building from ~/.m2/repository/.

UPDATE The hanging seems to be related to this issue: #10 - I have no issues when I only use the single repository https://repo.maven.apache.org/maven2/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants