Parcourir la source

v0.1 of maven sync setup

custom-downloader
Lars Wilhelmsen il y a 3 ans
Parent
révision
417d4743bd
Aucune clé connue n'a été trouvée dans la base pour cette signature ID de la clé GPG: 2837CEDF73BEC588
14 fichiers modifiés avec 389 ajouts et 2 suppressions
  1. +1
    -2
      .gitignore
  2. +23
    -0
      README.md
  3. +113
    -0
      examples/spring-boot-1.xml
  4. +3
    -0
      repo/deploy.sh
  5. +14
    -0
      repo/docker-compose.yml
  6. +84
    -0
      repo/reposilite.cdn
  7. +84
    -0
      repo/reposilite.cdn.bak
  8. +3
    -0
      sync/.dockerignore
  9. +10
    -0
      sync/Dockerfile
  10. +5
    -0
      sync/build-docker-image.sh
  11. +2
    -0
      sync/cleanup.sh
  12. +5
    -0
      sync/resolve-deps-from-poms.sh
  13. +31
    -0
      sync/settings.xml
  14. +11
    -0
      sync/sync.sh

+ 1
- 2
.gitignore Voir le fichier

@@ -1,2 +1 @@
*.agdai
MAlonzo/**
data/

+ 23
- 0
README.md Voir le fichier

@@ -0,0 +1,23 @@
# Maven Sync Setup

## Repository

_Reposilite_-based Maven Repository Manager acting as a caching proxy.

```sh
mkdir data
cd repo
./deploy.sh
```
TODO: something is not working correctly when loading the initial configuration.
Take the content of the `reposilite.cdn` and paste it into the Configuration window
after logging in as `admin:secret` on http://localhost:9001 and press _Update configuration and reload_.

## Sync job

Script that can be triggered manually or scheduled.

cd sync
./sync.sh

Mirror tarballs.

+ 113
- 0
examples/spring-boot-1.xml Voir le fichier

@@ -0,0 +1,113 @@
<?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.6.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<kotlin.version>1.6.10</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

</project>

+ 3
- 0
repo/deploy.sh Voir le fichier

@@ -0,0 +1,3 @@
#!/bin/sh

docker-compose -d up

+ 14
- 0
repo/docker-compose.yml Voir le fichier

@@ -0,0 +1,14 @@
version: '3.9'

services:
repo:
image: dzikoysk/reposilite:3.0.0-alpha.23
environment:
REPOSILITE_OPTS: "--token admin:secret --local-config=/reposilite.cdn --local-config-mode=copy"
volumes:
- ./reposilite.cdn:/reposilite.cdn
- ../data:/app/data
ports:
- "9001:80"
restart: unless-stopped


+ 84
- 0
repo/reposilite.cdn Voir le fichier

@@ -0,0 +1,84 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# Reposilite :: Shared #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #

# Repository id used in Maven repository configuration
id: reposilite-repository
# Repository title
title: Maven Mirror
# Repository description
description: Maven Mirror
# Link to organization's website
organizationWebsite: https://reposilite.com
# Link to organization's logo
organizationLogo: https://avatars.githubusercontent.com/u/88636591
# The Internet Content Provider License (also known as Bei'An)
# Web services in China require ICP license, a permit issued by the Chinese government to permit China-based websites to operate in China.
# In order to fulfill the conditions, you should apply for ICP license from your service provider and fill in this parameter.
icpLicense: ""
# Enable default frontend with dashboard
frontend: true
# Enable Swagger (/swagger-docs) and Swagger UI (/swagger)
swagger: false
# Custom base path
basePath: /

# List of supported Maven repositories
repositories {
releases {
visibility: PUBLIC
redeployment: false
preserved: -1
storageProvider: fs --quota 100%
proxied: [
https://repo.maven.apache.org/maven2 --store --connectTimeout=3 --readTimeout=15
]
}
snapshots {
visibility: PUBLIC
redeployment: false
preserved: -1
storageProvider: fs --quota 100%
proxied: [
https://oss.sonatype.org/content/repositories/snapshots --store --connectTimeout=3 --readTimeout=15
]
}
}

# Statistics module configuration
statistics {
# How often Reposilite should divide recorded requests into separated groups.
# With higher precision you can get more detailed timestamps, but it'll increase database size.
# It's not that important for small repos with low traffic, but public instances should not use daily interval.
# Available modes: daily, weekly, monthly, yearly
resolvedRequestsInterval: monthly
}

# LDAP configuration
ldap {
# LDAP Authenticator is enabled
enabled: false
# LDAP server address
hostname: ldap.domain.com
# LDAP server port
port: 389
# Base DN with users
baseDn: dc=company,dc=com
# User used to perform searches in LDAP server (requires permissions to read all LDAP entries)
searchUserDn: cn=reposilite,ou=admins,dc=domain,dc=com
# Search user's password
searchUserPassword: reposilite-admin-secret
# Attribute in LDAP that represents unique username used to create access token
userAttribute: cn
# LDAP user filter
userFilter: (&(objectClass=person)(ou=Maven Users))
# Should the created through LDAP access token be TEMPORARY or PERSISTENT
userType: PERSISTENT
}

# Any kind of proxy services change real ip.
# The origin ip should be available in one of the headers.
# Nginx: X-Forwarded-For
# Cloudflare: CF-Connecting-IP
# Popular: X-Real-IP
forwardedIp: X-Forwarded-For

+ 84
- 0
repo/reposilite.cdn.bak Voir le fichier

@@ -0,0 +1,84 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# Reposilite :: Shared #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #

# Repository id used in Maven repository configuration
id: reposilite-repository
# Repository title
title: Maven Mirror
# Repository description
description: Maven Mirror
# Link to organization's website
organizationWebsite: https://reposilite.com
# Link to organization's logo
organizationLogo: https://avatars.githubusercontent.com/u/88636591
# The Internet Content Provider License (also known as Bei'An)
# Web services in China require ICP license, a permit issued by the Chinese government to permit China-based websites to operate in China.
# In order to fulfill the conditions, you should apply for ICP license from your service provider and fill in this parameter.
icpLicense: ""
# Enable default frontend with dashboard
frontend: true
# Enable Swagger (/swagger-docs) and Swagger UI (/swagger)
swagger: false
# Custom base path
basePath: /

# List of supported Maven repositories
repositories {
releases {
visibility: PUBLIC
redeployment: false
preserved: -1
storageProvider: fs --quota 100%
proxied: [
https://repo.maven.apache.org/maven2 --store --connectTimeout=3 --readTimeout=15
]
}
snapshots {
visibility: PUBLIC
redeployment: false
preserved: -1
storageProvider: fs --quota 100%
proxied: [
https://oss.sonatype.org/content/repositories/snapshots --store --connectTimeout=3 --readTimeout=15
]
}
}

# Statistics module configuration
statistics {
# How often Reposilite should divide recorded requests into separated groups.
# With higher precision you can get more detailed timestamps, but it'll increase database size.
# It's not that important for small repos with low traffic, but public instances should not use daily interval.
# Available modes: daily, weekly, monthly, yearly
resolvedRequestsInterval: monthly
}

# LDAP configuration
ldap {
# LDAP Authenticator is enabled
enabled: false
# LDAP server address
hostname: ldap.domain.com
# LDAP server port
port: 389
# Base DN with users
baseDn: dc=company,dc=com
# User used to perform searches in LDAP server (requires permissions to read all LDAP entries)
searchUserDn: cn=reposilite,ou=admins,dc=domain,dc=com
# Search user's password
searchUserPassword: reposilite-admin-secret
# Attribute in LDAP that represents unique username used to create access token
userAttribute: cn
# LDAP user filter
userFilter: (&(objectClass=person)(ou=Maven Users))
# Should the created through LDAP access token be TEMPORARY or PERSISTENT
userType: PERSISTENT
}

# Any kind of proxy services change real ip.
# The origin ip should be available in one of the headers.
# Nginx: X-Forwarded-For
# Cloudflare: CF-Connecting-IP
# Popular: X-Real-IP
forwardedIp: X-Forwarded-For

+ 3
- 0
sync/.dockerignore Voir le fichier

@@ -0,0 +1,3 @@
**
!settings.xml
!resolve-deps-from-poms.sh

+ 10
- 0
sync/Dockerfile Voir le fichier

@@ -0,0 +1,10 @@
FROM maven:alpine

RUN mkdir /poms && mkdir -p /root/.m2

ADD resolve-deps-from-poms.sh /resolve-deps-from-poms.sh
ADD settings.xml /root/.m2/settings.xml

VOLUME [ "/poms" ]

ENTRYPOINT [ "/resolve-deps-from-poms.sh" ]

+ 5
- 0
sync/build-docker-image.sh Voir le fichier

@@ -0,0 +1,5 @@
#!/bin/sh

COCLI=docker # or podman

docker build -t maven-sync-job .

+ 2
- 0
sync/cleanup.sh Voir le fichier

@@ -0,0 +1,2 @@
#!/bin/sh


+ 5
- 0
sync/resolve-deps-from-poms.sh Voir le fichier

@@ -0,0 +1,5 @@
#!/bin/sh

for pom in /poms/*; do
mvn -f $pom dependency:go-offline;
done

+ 31
- 0
sync/settings.xml Voir le fichier

@@ -0,0 +1,31 @@
<settings>
<profiles>
<profile>
<id>reposilite</id>
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>http://localhost:9001/releases</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots-repo</id>
<url>http://localhost:9001/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>reposilite</activeProfile>
</activeProfiles>
</settings>

+ 11
- 0
sync/sync.sh Voir le fichier

@@ -0,0 +1,11 @@
#!/bin/sh

COCLI=docker # or podman

$COCLI run --network=host -it --rm -v $(pwd)/../examples:/poms maven-sync-job
cd ../data/repositories/
tar zcvf maven-releases-packages.tar.gz releases/*
tar zcvf maven-snapshots-packages.tar.gz snapshots/*

echo "NEXT: mirror *.tar.gz and import into Artifactory."


Chargement…
Annuler
Enregistrer