diff --git a/.gitignore b/.gitignore index 58ab67f..8fce603 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -*.agdai -MAlonzo/** +data/ diff --git a/README.md b/README.md index e69de29..24b496b 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/examples/spring-boot-1.xml b/examples/spring-boot-1.xml new file mode 100644 index 0000000..b1b3d17 --- /dev/null +++ b/examples/spring-boot-1.xml @@ -0,0 +1,113 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.6.5 + + + com.example + demo + 0.0.1-SNAPSHOT + demo + Demo project for Spring Boot + + 11 + 1.6.10 + + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-amqp + + + org.springframework.boot + spring-boot-starter-hateoas + + + org.springframework.boot + spring-boot-starter-oauth2-resource-server + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-web + + + com.fasterxml.jackson.module + jackson-module-kotlin + + + org.jetbrains.kotlin + kotlin-reflect + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + + + org.thymeleaf.extras + thymeleaf-extras-springsecurity5 + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.amqp + spring-rabbit-test + test + + + org.springframework.security + spring-security-test + test + + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + org.springframework.boot + spring-boot-maven-plugin + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + -Xjsr305=strict + + + spring + + + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + + + + + diff --git a/repo/deploy.sh b/repo/deploy.sh new file mode 100755 index 0000000..789415b --- /dev/null +++ b/repo/deploy.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +docker-compose -d up diff --git a/repo/docker-compose.yml b/repo/docker-compose.yml new file mode 100644 index 0000000..e906b0a --- /dev/null +++ b/repo/docker-compose.yml @@ -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 + diff --git a/repo/reposilite.cdn b/repo/reposilite.cdn new file mode 100644 index 0000000..244f2de --- /dev/null +++ b/repo/reposilite.cdn @@ -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 diff --git a/repo/reposilite.cdn.bak b/repo/reposilite.cdn.bak new file mode 100644 index 0000000..244f2de --- /dev/null +++ b/repo/reposilite.cdn.bak @@ -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 diff --git a/sync/.dockerignore b/sync/.dockerignore new file mode 100644 index 0000000..7c87d60 --- /dev/null +++ b/sync/.dockerignore @@ -0,0 +1,3 @@ +** +!settings.xml +!resolve-deps-from-poms.sh diff --git a/sync/Dockerfile b/sync/Dockerfile new file mode 100644 index 0000000..ea74413 --- /dev/null +++ b/sync/Dockerfile @@ -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" ] diff --git a/sync/build-docker-image.sh b/sync/build-docker-image.sh new file mode 100755 index 0000000..738fd29 --- /dev/null +++ b/sync/build-docker-image.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +COCLI=docker # or podman + +docker build -t maven-sync-job . diff --git a/sync/cleanup.sh b/sync/cleanup.sh new file mode 100755 index 0000000..13f4793 --- /dev/null +++ b/sync/cleanup.sh @@ -0,0 +1,2 @@ +#!/bin/sh + diff --git a/sync/resolve-deps-from-poms.sh b/sync/resolve-deps-from-poms.sh new file mode 100755 index 0000000..eddc3fd --- /dev/null +++ b/sync/resolve-deps-from-poms.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +for pom in /poms/*; do + mvn -f $pom dependency:go-offline; +done diff --git a/sync/settings.xml b/sync/settings.xml new file mode 100644 index 0000000..e581a47 --- /dev/null +++ b/sync/settings.xml @@ -0,0 +1,31 @@ + + + + reposilite + + + central + Central Repository + http://localhost:9001/releases + default + + false + + + + snapshots-repo + http://localhost:9001/snapshots + + false + + + true + + + + + + + reposilite + + \ No newline at end of file diff --git a/sync/sync.sh b/sync/sync.sh new file mode 100755 index 0000000..3f04c85 --- /dev/null +++ b/sync/sync.sh @@ -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." +