Compare commits

..

11 Commits

Author SHA1 Message Date
42157c4abc optimize setup
Some checks failed
deploy to hetzner / deploy (push) Failing after 4m54s
Signed-off-by: Peter Siegmund <developer@mars3142.org>
2025-08-23 00:13:03 +02:00
7e53d48d41 Revert "fixing opentelemetry uri"
Some checks failed
deploy to hetzner / deploy (push) Failing after 4m55s
This reverts commit 7c4c9001d0.
2024-11-01 22:54:31 +01:00
7c4c9001d0 fixing opentelemetry uri
Signed-off-by: Peter Siegmund <developer@mars3142.org>
2024-11-01 22:51:18 +01:00
f170687cb8 new cool stuff
Signed-off-by: Peter Siegmund <developer@mars3142.org>
2024-11-01 22:51:03 +01:00
4f3b03cec5 add OpenTelemetry
Signed-off-by: Peter Siegmund <developer@mars3142.org>
2024-11-01 22:50:04 +01:00
dependabot[bot]
edfacb05a1 Bump org.springframework.boot:spring-boot-starter-parent
Bumps [org.springframework.boot:spring-boot-starter-parent](https://github.com/spring-projects/spring-boot) from 3.3.4 to 3.3.5.
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](https://github.com/spring-projects/spring-boot/compare/v3.3.4...v3.3.5)

---
updated-dependencies:
- dependency-name: org.springframework.boot:spring-boot-starter-parent
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-31 23:39:46 +01:00
dependabot[bot]
65fb1a3311 Bump org.springframework.modulith:spring-modulith-bom
Bumps [org.springframework.modulith:spring-modulith-bom](https://github.com/spring-projects/spring-modulith) from 1.2.4 to 1.2.5.
- [Release notes](https://github.com/spring-projects/spring-modulith/releases)
- [Commits](https://github.com/spring-projects/spring-modulith/compare/1.2.4...1.2.5)

---
updated-dependencies:
- dependency-name: org.springframework.modulith:spring-modulith-bom
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-31 23:39:40 +01:00
dependabot[bot]
55eb9b5c12 Bump vaadin.version from 24.5.0.rc1 to 24.6.0.alpha1
Bumps `vaadin.version` from 24.5.0.rc1 to 24.6.0.alpha1.

Updates `com.vaadin:vaadin-bom` from 24.5.0.rc1 to 24.6.0.alpha1

Updates `com.vaadin:vaadin-maven-plugin` from 24.5.0.rc1 to 24.6.0.alpha1

---
updated-dependencies:
- dependency-name: com.vaadin:vaadin-bom
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: com.vaadin:vaadin-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-21 14:29:59 +02:00
ed71fce96f optimize configs for CI build
Signed-off-by: Peter Siegmund <developer@mars3142.org>
2024-10-20 23:59:07 +02:00
f1554f1131 testing request with parameters
Signed-off-by: Peter Siegmund <developer@mars3142.org>
2024-10-20 20:28:38 +02:00
dependabot[bot]
ea47e63660 Bump vaadin.version from 24.5.0.beta3 to 24.5.0.rc1
Bumps `vaadin.version` from 24.5.0.beta3 to 24.5.0.rc1.

Updates `com.vaadin:vaadin-bom` from 24.5.0.beta3 to 24.5.0.rc1

Updates `com.vaadin:vaadin-maven-plugin` from 24.5.0.beta3 to 24.5.0.rc1

---
updated-dependencies:
- dependency-name: com.vaadin:vaadin-bom
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.vaadin:vaadin-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-20 20:17:24 +02:00
12 changed files with 92 additions and 94 deletions

View File

@@ -11,11 +11,13 @@ USER app
# Copy all needed project files to a folder
COPY --chown=app ./.mvn/ .mvn
COPY --chown=app ./mvnw ./pom.xml ./app.json ./
COPY --chown=app ./mvnw ./pom.xml ./
COPY --chown=app ./src ./src
RUN curl -OL https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
# Build the production package
RUN ./mvnw --batch-mode clean verify -Pproduction -DskipTests
RUN ./mvnw --batch-mode clean verify -Pproduction -DskipTests
# Running stage: the part that is used for running the application
FROM eclipse-temurin:21-jre-noble
@@ -24,7 +26,8 @@ RUN useradd -m app
USER app
COPY --chown=app --from=build /usr/src/app/target/*.jar /usr/app/website.jar
COPY --chown=app --from=build /usr/src/app/opentelemetry-javaagent.jar /usr/app/opentelemetry-javaagent.jar
HEALTHCHECK CMD curl --fail http://localhost:5000/actuator/health/liveness || exit 1
HEALTHCHECK CMD curl --fail http://localhost:8080/actuator/health || exit 1
CMD ["java", "-jar", "/usr/app/website.jar"]

20
Makefile Normal file
View File

@@ -0,0 +1,20 @@
REMOTE_HOST = mars3142@172.16.20.1
PROJECT_NAME = firmware-hq
SERVICE_NAME = website
RASPI_PATH = /mnt/data/${PROJECT_NAME}
install: build deploy import cleanup
build:
docker buildx build --platform linux/arm64 --no-cache -t ${PROJECT_NAME}/${SERVICE_NAME}:latest -o type=docker,dest=./${SERVICE_NAME}-arm64.tar .
deploy:
scp ./${SERVICE_NAME}-arm64.tar ${REMOTE_HOST}:${RASPI_PATH}/
import:
ssh ${REMOTE_HOST} "sudo docker load -i ${RASPI_PATH}/${SERVICE_NAME}-arm64.tar && rm ${RASPI_PATH}/${SERVICE_NAME}-arm64.tar"
cleanup:
rm -f ${SERVICE_NAME}-arm64.tar
.PHONY: build deploy import cleanup

View File

@@ -1,14 +0,0 @@
{
"healthchecks": {
"web": [
{
"type": "readiness",
"name": "web check",
"description": "Checking if the app responds to the /actuator/health/readiness endpoint",
"path": "/actuator/health/readiness",
"port": 5000,
"attempts": 3
}
]
}
}

View File

@@ -12,16 +12,16 @@
<properties>
<java.version>21</java.version>
<vaadin.version>24.5.0.beta3</vaadin.version>
<vaadin.version>24.6.0.alpha1</vaadin.version>
<spring-cloud.version>2023.0.3</spring-cloud.version>
<spring-cloud-gcp.version>5.4.1</spring-cloud-gcp.version>
<spring-modulith.version>1.2.4</spring-modulith.version>
<spring-modulith.version>1.2.5</spring-modulith.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.4</version>
<version>3.3.5</version>
</parent>
<repositories>

View File

@@ -0,0 +1,9 @@
package dev.mars3142.fhq.client;
import org.springframework.web.service.annotation.GetExchange;
public interface AuthClient {
@GetExchange("/v1/auth")
String getAuth();
}

View File

@@ -1,9 +1,16 @@
package dev.mars3142.fhq.client;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.service.annotation.GetExchange;
public interface TimeZoneClient {
@GetExchange("/v1/timezone")
String getTimeZone();
@GetExchange("/v1/timezone/{area}")
String getTimeZone(@PathVariable String area);
@GetExchange("/v1/timezone/{area}/{location}")
String getTimeZone(@PathVariable String area, @PathVariable String location);
}

View File

@@ -1,6 +1,9 @@
package dev.mars3142.fhq.config;
import dev.mars3142.fhq.client.AuthClient;
import dev.mars3142.fhq.client.TimeZoneClient;
import dev.mars3142.fhq.config.interceptor.AuthInterceptor;
import lombok.val;
import org.springframework.boot.web.client.ClientHttpRequestFactories;
import org.springframework.boot.web.client.ClientHttpRequestFactorySettings;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
@@ -17,22 +20,34 @@ public class RestClientConfig {
@LoadBalanced
@Bean
RestClient.Builder restClientBuilder() {
return RestClient.builder();
return RestClient.builder()
.requestInterceptor(new AuthInterceptor());
}
@Bean
public TimeZoneClient timeZoneClient(RestClient.Builder restClientBuilder) {
RestClient restClient = restClientBuilder
public AuthClient authClient(RestClient.Builder builder) {
val restClient = builder
.baseUrl("http://auth-service")
.requestFactory(getClientRequestFactory())
.build();
val restClientAdapter = RestClientAdapter.create(restClient);
val httpServiceProxyFactory = HttpServiceProxyFactory.builderFor(restClientAdapter).build();
return httpServiceProxyFactory.createClient(AuthClient.class);
}
@Bean
public TimeZoneClient timeZoneClient(RestClient.Builder builder) {
val restClient = builder
.baseUrl("http://timezone-service")
.requestFactory(getClientRequestFactory())
.build();
var restClientAdapter = RestClientAdapter.create(restClient);
var httpServiceProxyFactory = HttpServiceProxyFactory.builderFor(restClientAdapter).build();
val restClientAdapter = RestClientAdapter.create(restClient);
val httpServiceProxyFactory = HttpServiceProxyFactory.builderFor(restClientAdapter).build();
return httpServiceProxyFactory.createClient(TimeZoneClient.class);
}
private ClientHttpRequestFactory getClientRequestFactory() {
ClientHttpRequestFactorySettings clientHttpRequestFactorySettings = ClientHttpRequestFactorySettings.DEFAULTS;
val clientHttpRequestFactorySettings = ClientHttpRequestFactorySettings.DEFAULTS;
return ClientHttpRequestFactories.get(clientHttpRequestFactorySettings);
}
}

View File

@@ -0,0 +1,19 @@
package dev.mars3142.fhq.config.interceptor;
import java.io.IOException;
import lombok.val;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
public class AuthInterceptor implements ClientHttpRequestInterceptor {
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException {
val headers = request.getHeaders();
headers.add("X-FHQ-USER-ID", "Vaadin");
return execution.execute(request, body);
}
}

View File

@@ -15,7 +15,7 @@ import lombok.val;
public class LandingPageView extends Composite<VerticalLayout> {
public LandingPageView(TimeZoneClient client) {
val timeZone = client.getTimeZone();
val timeZone = client.getTimeZone("Europe", "Berlin");
val verticalLayout = new VerticalLayout();
verticalLayout.setSizeFull();
verticalLayout.add(new Text(timeZone));

View File

@@ -1,15 +0,0 @@
server:
port: ${PORT:8090}
vaadin:
# To improve the performance during development.
# For more information https://vaadin.com/docs/latest/integrations/spring/configuration#special-configuration-parameters
allowed-packages : com.vaadin,org.vaadin,dev.hilla,dev.mars3142
backend:
uri: http://localhost:8091/v1
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka

View File

@@ -1,52 +0,0 @@
logging:
level:
org:atmosphere: warn
spring:
application:
name: website
mustache:
check-template-location: false
jpa:
defer-datasource-initialization: true
backend:
uri: https://api.firmware-hq.dev/v1
eureka:
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://eureka-service.web:8761/eureka
instance:
instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
info:
application:
name: ${spring.application.name}
version: '@project.version@'
spring-cloud-version: '@spring-cloud.version@'
spring-boot-version: '@project.parent.version@'
management:
endpoint:
health:
probes:
enabled: true
server:
port: ${PORT:8080}
shutdown: graceful
error:
include-message: on_param
include-stacktrace: on_param
sentry:
dsn: https://354321d371291036cffcdb5b1a72fd6e@o394865.ingest.us.sentry.io/4507718826262528
environment: edge-service
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
# We recommend adjusting this value in production.
tracesSampleRate: 1.0

View File

@@ -0,0 +1,6 @@
eureka:
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: ${EUREKA}