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

Attempt with micronaut #42

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .creds
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
baz=fdr
foo=asddr
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ ij_formatter_tags_enabled = true
ij_smart_tabs = false
ij_wrap_on_typing = false

[*.{yml,yaml}]
indent_size = 2

[*.java]
ij_continuation_indent_size = 4
ij_visual_guides = 80, 120
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/graalvm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: GraalVM CE CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.m2/repository
key: ${{ runner.os }}-gradle-test-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle-test-
- name: Setup GraalVM CE
uses: DeLaGuardo/[email protected]
with:
graalvm-version: 22.3.0.java17
- name: Install Native Image
run: gu install native-image
- name: Docker login
uses: docker/login-action@v1
with:
registry: ${{ secrets.DOCKER_REGISTRY_URL }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build And Push Docker Image
env:
DOCKER_REPOSITORY_PATH: ${{ secrets.DOCKER_REPOSITORY_PATH }}
DOCKER_REGISTRY_URL: ${{ secrets.DOCKER_REGISTRY_URL }}
TESTCONTAINERS_RYUK_DISABLED: true
run: |
export DOCKER_IMAGE=`echo "${DOCKER_REGISTRY_URL}/${DOCKER_REPOSITORY_PATH}/systemofadownload" | sed -e 's#//#/#' -e 's#^/##'`
./gradlew check dockerPushNative --no-daemon
34 changes: 34 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Java CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.m2/repository
key: ${{ runner.os }}-gradle-test-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-test-
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Docker login
uses: docker/login-action@v1
with:
registry: ${{ secrets.DOCKER_REGISTRY_URL }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build And Push Docker Image
env:
DOCKER_REPOSITORY_PATH: ${{ secrets.DOCKER_REPOSITORY_PATH }}
DOCKER_REGISTRY_URL: ${{ secrets.DOCKER_REGISTRY_URL }}
TESTCONTAINERS_RYUK_DISABLED: true
run: |
export DOCKER_IMAGE=`echo "${DOCKER_REGISTRY_URL}/${DOCKER_REPOSITORY_PATH}/systemofadownload" | sed -e 's#//#/#' -e 's#^/##'`
./gradlew check dockerPush --no-daemon
2 changes: 1 addition & 1 deletion .java-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17
20.0.1
10 changes: 10 additions & 0 deletions .jpb/jpb-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DatabaseMigrationSettings" liquibaseVersion="4.5" />
<component name="JpaPluginProjectSettings">
<option name="entityNameTemplate" />
<option name="generateSerialVersionUID" value="true" />
<option name="useLazyOnToOneAssociations" value="true" />
<option name="scaffoldingLanguage" />
</component>
</project>
12 changes: 12 additions & 0 deletions .jpb/persistence-units.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PersistenceUnitSettings">
<persistence-units>
<persistence-unit name="Default">
<packages>
<package value="" />
</packages>
</persistence-unit>
</persistence-units>
</component>
</project>
3 changes: 2 additions & 1 deletion .jvmopts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
-Xss6M
-XX:ReservedCodeCacheSize=256M
-Dfile.encoding=UTF-8
--add-opens=java.base/java.lang=ALL-UNNAMED
--enable-preview
--add-opens=java.base/java.lang=ALL-UNNAMED
102 changes: 59 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,70 +7,86 @@ downloads website.

## Requirements

- Java 16
- Java 21 (GraalVM optional to build native images)
- Docker
- sbt 1.15
- terraform (if you want to deploy to a kubernetes cluster)

## Technologies in use
### Micronaut 4.1.3

### Framework
- [User Guide](https://docs.micronaut.io/4.1.3/guide/index.html)
- [API Reference](https://docs.micronaut.io/4.1.3/api/index.html)
- [Configuration Reference](https://docs.micronaut.io/4.1.3/guide/configurationreference.html)
- [Micronaut Guides](https://guides.micronaut.io/index.html)
---

SystemOfADownload (SOAD) is built on [LagomFramework], an opinionated
[Event Source] + [CQRS] architecture framework built on [Akka], and as such relies
on several functional programing paradigms. Lagom as a whole provides enough
to build out several services with semi-automatic service discovery routing
and using [Postgres] as the primary storage database for the Event Journal and
Query side persistence.
- [Shadow Gradle Plugin](https://plugins.gradle.org/plugin/com.github.johnrengelman.shadow)
- [Micronaut Gradle Plugin documentation](https://micronaut-projects.github.io/micronaut-gradle-plugin/latest/)
- [GraalVM Gradle Plugin documentation](https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html)
#### Feature test-resources documentation

To learn about the topics, please visit
[Lagom's documentation on concepts](https://www.lagomframework.com/documentation/1.6.x/java/CoreConcepts.html)
that goes at length about how the system works together.
- [Micronaut Test Resources documentation](https://micronaut-projects.github.io/micronaut-test-resources/latest/guide/)

### Containerization Out of the Box

SOAD is targeted at being deployed with either sbt in-development or deployed on a
Kubernetes cluster.
#### Feature r2dbc documentation

### Services
Each service is loosely intended on the desired workload/grouped boundaries of knowledge.
- [Micronaut R2DBC documentation](https://micronaut-projects.github.io/micronaut-r2dbc/latest/guide/)

In a sense, the data
The first three are what effectively being given as model views to exploring a paired
[Sonatype Nexus] repository instance for artifacts and presenting/serving them in a
more user friendlier way by providing git-like changelogs between artifacts.
- [https://r2dbc.io](https://r2dbc.io)

#### ArtifactService

The bread and butter of the shebang. Manages/creates/caches artifacts to knowledge by
[maven coordindates](https://maven.apache.org/pom.html#Maven_Coordinates). Typically,
an `Artifact` is not actually an artifact, but considered a `Component` with several
`Asset`s. Here we have exposed the ability to retrieve an artifact (if registered) and
its known assets along with download url's provided.
#### Feature github-workflow-graal-docker-registry documentation

#### CommitService
- [https://docs.github.com/en/free-pro-team@latest/actions](https://docs.github.com/en/free-pro-team@latest/actions)

This is a little more subtle, but effectively, since each artifact may or may not have a
`Git-Commit` listed in the jar manifest, this service strictly deals with managing registered
repositories, updating them, and pulling the list of commits diffing between two commits.

#### ChangelogService
#### Feature security-ldap documentation

Amalgamation of information between the `ArtifactService` and `CommitService`. This is where
we can store/manage changelogs per artifact regsitered by an entity.
- [Micronaut Security LDAP documentation](https://micronaut-projects.github.io/micronaut-security/latest/guide/index.html#ldap)

#### SonatypeWebhookService

This is the webhook functionality that performs a [Saga]-like series of jobs or units of
work. Because the nature of an artifact being uploaded to Sonatype and "the fact that anything
can and will go wrong",
#### Feature discovery-kubernetes documentation

- [Micronaut Kubernetes Service Discovery documentation](https://micronaut-projects.github.io/micronaut-kubernetes/latest/guide/#service-discovery)


#### Feature micronaut-aot documentation

- [Micronaut AOT documentation](https://micronaut-projects.github.io/micronaut-aot/latest/guide/)


#### Feature liquibase documentation

- [Micronaut Liquibase Database Migration documentation](https://micronaut-projects.github.io/micronaut-liquibase/latest/guide/index.html)

- [https://www.liquibase.org/](https://www.liquibase.org/)


#### Feature cache-caffeine documentation

- [Micronaut Caffeine Cache documentation](https://micronaut-projects.github.io/micronaut-cache/latest/guide/index.html)

- [https://github.com/ben-manes/caffeine](https://github.com/ben-manes/caffeine)


#### Feature serialization-jackson documentation

- [Micronaut Serialization Jackson Core documentation](https://micronaut-projects.github.io/micronaut-serialization/latest/guide/)


#### Feature data-r2dbc documentation

- [Micronaut Data R2DBC documentation](https://micronaut-projects.github.io/micronaut-data/latest/guide/#dbc)

- [https://r2dbc.io](https://r2dbc.io)


#### Feature jdbc-hikari documentation

- [Micronaut Hikari JDBC Connection Pool documentation](https://micronaut-projects.github.io/micronaut-sql/latest/guide/index.html#jdbc)


### AuthService

Provides the login end point and generates Json Web Tokens (JWTs) to enable interacting
with select services. It uses lagom-pac4j's [`SecuredService`] to provide authentication
and authorization to other endpoints. It is used to provide internal, LDAP and JWT based
authentication.

[LagomFramework]:https://lagomframework.com/
[Event Source]:https://docs.microsoft.com/en-us/azure/architecture/patterns/event-sourcing
Expand Down
17 changes: 17 additions & 0 deletions akka/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

version = "0.1"
group = "org.spongepowered.downloads"

plugins {
id("com.github.johnrengelman.shadow")
id("io.micronaut.library")
}

dependencies {
annotationProcessor("io.micronaut.serde:micronaut-serde-processor")
implementation("io.micronaut.serde:micronaut-serde-jackson")
api("io.micronaut:micronaut-inject")
api(platform(libs.akkaBom))
api(libs.bundles.actors)
implementation(libs.bundles.akkaManagement)
}
Loading
Loading