Compare commits

..

No commits in common. "6a21ca2b48e6e2f7eb751504c6a28e89ef69dd93" and "6d82744e7fbf434e02fb484d85d6404e4824e824" have entirely different histories.

6 changed files with 45 additions and 188 deletions

View file

@ -1,33 +0,0 @@
name: build and publish docker image / deploy
on:
push:
branches: ["dev"]
pull_request:
branches: ["dev"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: https://github.com/actions/checkout@v4
with:
repository: 'learningpulse/server'
ref: 'dev'
token: '${{ secrets.token }}'
- name: 'Set up java 22'
uses: https://github.com/actions/setup-java@v3
with:
java-version: "22"
distribution: "temurin"
- name: "Setup maven"
uses: https://github.com/stCarolas/setup-maven@v5
- name: Build with Maven
run: mvn -Dtoken=${{ secrets.token }} clean compile jib:build -e

2
.gitignore vendored
View file

@ -1,2 +0,0 @@
result/*
result

View file

@ -2,17 +2,18 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1716509168, "lastModified": 1716293225,
"narHash": "sha256-4zSIhSRRIoEBwjbPm3YiGtbd8HDWzFxJjw5DYSDy1n8=", "narHash": "sha256-pU9ViBVE3XYb70xZx+jK6SEVphvt7xMTbm6yDIF4xPs=",
"owner": "NixOS", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "bfb7a882678e518398ce9a31a881538679f6f092", "rev": "3eaeaeb6b1e08a016380c279f8846e0bd8808916",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "owner": "nixos",
"ref": "nixos-unstable", "ref": "nixos-unstable",
"type": "indirect" "repo": "nixpkgs",
"type": "github"
} }
}, },
"root": { "root": {

121
flake.nix
View file

@ -1,95 +1,48 @@
{ {
description = "CI, devshell and package definition for learningpulse"; description = "Learning Pulse";
inputs = { inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
}; };
outputs = { self, nixpkgs, ... }:
outputs =
{ self
, nixpkgs
, maven
, makeWrapper
}:
let let
# TODO add more systems javaVersion = 22;
system = "x86_64-linux"; overlays = [
pkgs = import nixpkgs { inherit system; }; (final: prev: rec {
jdk = prev."jdk${toString javaVersion}";
buildPackages = with pkgs; [ gradle = prev.gradle.override { java = jdk; };
jdk22 maven = prev.maven.override { inherit jdk; };
makeWrapper })
]; ];
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit overlays system; };
});
in in
rec { {
packages.${system} =
{
learningpulse-gateway = pkgs.maven.buildMavenPackage rec {
pname = "gateway";
version = "0.0.1";
src = ./.;
# todo get automatically
mvnHash = "sha256-YCK1Qujgx73cZdEx2mRip+y+66px5TxL247fBIMyoy4=";
nativeBuildInputs = buildPackages;
installPhase = ''
mkdir -p $out/bin $out/share/${pname}
install -Dm644 ${pname}/target/${pname}-${version}.jar $out/share/${pname}
makeWrapper ${pkgs.jre8}/bin/java $out/bin/${pname} \
--add-flags "-jar $out/share/${pname}/${pname}-${version}.jar"
'';
};
learningpulse-eureka = pkgs.maven.buildMavenPackage rec {
pname = "eureka";
version = "0.0.1";
src = ./.;
# todo get automatically
mvnHash = "sha256-YCK1Qujgx73cZdEx2mRip+y+66px5TxL247fBIMyoy4=";
nativeBuildInputs = buildPackages;
installPhase = ''
mkdir -p $out/bin $out/share/${pname}
install -Dm644 ${pname}/target/${pname}-${version}.jar $out/share/${pname}
makeWrapper ${pkgs.jre8}/bin/java $out/bin/${pname} \
--add-flags "-jar $out/share/${pname}/${pname}-${version}.jar"
'';
};
learningpulse-dummy = pkgs.maven.buildMavenPackage rec {
pname = "dummy";
version = "0.0.1";
src = ./.;
# todo get automatically
mvnHash = "sha256-YCK1Qujgx73cZdEx2mRip+y+66px5TxL247fBIMyoy4=";
nativeBuildInputs = buildPackages;
installPhase = ''
mkdir -p $out/bin $out/share/${pname}
install -Dm644 ${pname}/target/${pname}-${version}.jar $out/share/${pname}
makeWrapper ${pkgs.jre8}/bin/java $out/bin/${pname} \
--add-flags "-jar $out/share/${pname}/${pname}-${version}.jar"
'';
};
};
hydraJobs = { hydraJobs = {
inherit (self) gateway = maven.buildMavenPackage rec {
packages; pname = "learningpulse-gateway";
version = "1.2.1";
#
# hello i wrote something here to test pulling
};
}; };
devShells."${system}".default = pkgs.mkShell { devShells = forEachSupportedSystem ({ pkgs }: {
buildInputs = with pkgs; [ default = pkgs.mkShell {
maven packages = with pkgs; [
jdk22 jdk
jre8 maven
# top run actions locally ];
act };
]; });
};
}; };
} }

41
pom.xml
View file

@ -61,51 +61,12 @@
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin> </plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<from>
<image>eclipse-temurin:22-jre</image>
<!-- <auth>
<username>${dockerusername}</username>
<password>${dockerpassword}</password>
</auth> -->
<platforms>
<platform>
<architecture>amd64</architecture>
<os>linux</os>
</platform>
<platform>
<architecture>arm64</architecture>
<os>linux</os>
</platform>
</platforms>
</from>
<to>
<image>git.4o1x5.dev/learningpulse/server/${project.artifactId}:${project.version}</image>
<auth>
<username>hydrabot</username>
<password>${token}</password>
</auth>
</to>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>dockerBuild</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>

View file

@ -1,23 +0,0 @@
# LearningPulse server
## CI/CD
To check up on builds head to [the hydra server](https://hydra.4o1x5.dev/project/learningpulse)
### Enter developer shell
```bash
nix develop
```
### Build services
```bash
nix build .#learningpulse-dummy
```
### Run service
```bash
nix develop && cd dummy && mvn run spring-boot:run
```