build: update public artifacts
This commit is contained in:
@@ -54,11 +54,12 @@ jobs:
|
||||
# ensure executable
|
||||
- run: chmod +x ./gradlew
|
||||
# run gradle test and build
|
||||
- run: |
|
||||
./gradlew check
|
||||
./gradlew bootJar
|
||||
env:
|
||||
MAVEN_TOKEN: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
# disabled since gradle doesn't require maven token anymore
|
||||
# - run: |
|
||||
# ./gradlew check
|
||||
# ./gradlew bootJar
|
||||
# env:
|
||||
# MAVEN_TOKEN: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
# setup docker
|
||||
- name: set up docker cli
|
||||
run: |
|
||||
@@ -82,6 +83,7 @@ jobs:
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
# file: ci.Dockerfile
|
||||
file: Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
|
||||
+7
-1
@@ -1,5 +1,11 @@
|
||||
FROM gradle:jdk21 AS build
|
||||
|
||||
WORKDIR /code
|
||||
COPY . /code
|
||||
RUN gradle bootJar --no-daemon
|
||||
|
||||
FROM azul/zulu-openjdk:21-latest
|
||||
EXPOSE 8099
|
||||
WORKDIR /app
|
||||
COPY build/libs/*.jar /app/app.jar
|
||||
COPY --from=build /code/build/libs/*.jar /app/app.jar
|
||||
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
|
||||
+18
-17
@@ -33,23 +33,24 @@ repositories {
|
||||
maven {
|
||||
name = "cleverthis-forgejo-maven"
|
||||
url = uri("https://git.cleverthis.com/api/packages/clevermicro/maven")
|
||||
if (System.getenv("MAVEN_TOKEN").isNullOrBlank()) {
|
||||
credentials(HttpHeaderCredentials::class) {
|
||||
name = "Authorization"
|
||||
val token =
|
||||
findProperty("cleverThisForgejoToken") as String? ?: error("Token not found")
|
||||
value = "token $token"
|
||||
}
|
||||
} else {
|
||||
credentials(HttpHeaderCredentials::class) {
|
||||
name = "Authorization"
|
||||
val token = System.getenv("MAVEN_TOKEN")
|
||||
value = "token $token"
|
||||
}
|
||||
}
|
||||
authentication {
|
||||
create("header", HttpHeaderAuthentication::class)
|
||||
}
|
||||
// disable auth since artifacts are publicly available
|
||||
// if (System.getenv("MAVEN_TOKEN").isNullOrBlank()) {
|
||||
// credentials(HttpHeaderCredentials::class) {
|
||||
// name = "Authorization"
|
||||
// val token =
|
||||
// findProperty("cleverThisForgejoToken") as String? ?: error("Token not found")
|
||||
// value = "token $token"
|
||||
// }
|
||||
// } else {
|
||||
// credentials(HttpHeaderCredentials::class) {
|
||||
// name = "Authorization"
|
||||
// val token = System.getenv("MAVEN_TOKEN")
|
||||
// value = "token $token"
|
||||
// }
|
||||
// }
|
||||
// authentication {
|
||||
// create("header", HttpHeaderAuthentication::class)
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
FROM azul/zulu-openjdk:21-latest
|
||||
EXPOSE 8099
|
||||
WORKDIR /app
|
||||
COPY build/libs/*.jar /app/app.jar
|
||||
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.cleverthis.authservice.config;
|
||||
|
||||
import com.cleverthis.clevermicro.client.amqp.CleverMicroAmqpClient;
|
||||
import com.cleverthis.clevermicro.client.amqp.CleverMicroAmqpConfig;
|
||||
import com.rabbitmq.client.ConnectionFactory;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
||||
/**
|
||||
* Provide {@link CleverMicroAmqpClient} as a bean.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(CleverMicroClientConfigProperties.class)
|
||||
@Slf4j
|
||||
public class CleverMicroClientConfig {
|
||||
|
||||
private final CleverMicroClientConfigProperties properties;
|
||||
|
||||
public CleverMicroClientConfig(
|
||||
final CleverMicroClientConfigProperties configProperties
|
||||
) {
|
||||
this.properties = configProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Post construct.
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// correct availability
|
||||
if (this.properties.getInitialAvailability() <= 0) {
|
||||
this.properties.setInitialAvailability(Runtime.getRuntime().availableProcessors() * 2);
|
||||
}
|
||||
log.info("CleverMicroClientConfig initial availability: {}",
|
||||
this.properties.getInitialAvailability());
|
||||
log.info("CleverMicroClient will use swarm info: serviceId={}, taskId={}",
|
||||
this.properties.getSwarmServiceId(), this.properties.getSwarmTaskId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a RabbitMQ {@link ConnectionFactory}.
|
||||
*/
|
||||
@Bean
|
||||
@Lazy
|
||||
public ConnectionFactory connectionFactory() {
|
||||
final var factory = new ConnectionFactory();
|
||||
factory.setHost(this.properties.getRabbitmqHost());
|
||||
factory.setPort(this.properties.getRabbitmqPort());
|
||||
factory.setUsername(this.properties.getRabbitmqUsername());
|
||||
factory.setPassword(this.properties.getRabbitmqPassword());
|
||||
factory.setVirtualHost(this.properties.getRabbitmqVhost());
|
||||
factory.setAutomaticRecoveryEnabled(true);
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link CleverMicroAmqpClient} bean.
|
||||
*/
|
||||
@Bean
|
||||
@Lazy
|
||||
@ConditionalOnMissingBean
|
||||
public CleverMicroAmqpClient cleverMicroAmqpClient(
|
||||
final ConnectionFactory connectionFactory,
|
||||
final ApplicationContext applicationContext
|
||||
) throws IOException, TimeoutException {
|
||||
final var client = new CleverMicroAmqpClient(
|
||||
connectionFactory.newConnection(), CleverMicroAmqpConfig.builder()
|
||||
.serviceName(applicationContext.getApplicationName())
|
||||
.swarmServiceId(this.properties.getSwarmServiceId())
|
||||
.swarmTaskId(this.properties.getSwarmTaskId())
|
||||
.reportAvailabilityUsageCooldown(Duration.ofMillis(250))
|
||||
.reportAvailabilityRecoveryCooldown(Duration.ofSeconds(1))
|
||||
.reportAvailabilityRegularCooldown(Duration.ofSeconds(5))
|
||||
.build()
|
||||
);
|
||||
client.getHandlerManager().getAvailability()
|
||||
.release(this.properties.getInitialAvailability());
|
||||
return client;
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.cleverthis.authservice.config;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Config properties for {@link CleverMicroClientConfig}.
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "clevermicro.client")
|
||||
@Builder
|
||||
@Getter
|
||||
@Setter
|
||||
public class CleverMicroClientConfigProperties {
|
||||
/**
|
||||
* Host of the rabbitmq server.
|
||||
*/
|
||||
@Builder.Default
|
||||
private String rabbitmqHost = "localhost";
|
||||
|
||||
/**
|
||||
* The port of the rabbitmq server.
|
||||
*/
|
||||
@Builder.Default
|
||||
private int rabbitmqPort = 5672;
|
||||
|
||||
/**
|
||||
* RabbitMQ username.
|
||||
*/
|
||||
@Builder.Default
|
||||
private String rabbitmqUsername = "guest";
|
||||
|
||||
/**
|
||||
* RabbitMQ password.
|
||||
*/
|
||||
@Builder.Default
|
||||
private String rabbitmqPassword = "guest";
|
||||
|
||||
/**
|
||||
* Vhost of the rabbitmq server.
|
||||
*/
|
||||
@Builder.Default
|
||||
private String rabbitmqVhost = "/";
|
||||
|
||||
/**
|
||||
* Initial availability.
|
||||
* <p>
|
||||
* Default: CPU cores * 2, since the workload for auth-service is mainly IO-intensive.
|
||||
* </p>
|
||||
* <p>Set to -1 to use the default value.</p>
|
||||
* */
|
||||
@Builder.Default
|
||||
private int initialAvailability = Runtime.getRuntime().availableProcessors() * 2;
|
||||
|
||||
/**
|
||||
* Docker swarm service id.
|
||||
*/
|
||||
private String swarmServiceId;
|
||||
|
||||
/**
|
||||
* Docker swarm task id.
|
||||
*/
|
||||
private String swarmTaskId;
|
||||
}
|
||||
@@ -34,6 +34,21 @@ auth-service:
|
||||
# Default Keycloak Client ID if no prefix matches (optional)
|
||||
# defaultKeycloakClientId: "general-api-client"
|
||||
|
||||
# CleverMicro client
|
||||
clevermicro:
|
||||
client:
|
||||
# rabbitmq
|
||||
rabbitmq-host: ${RABBITMQ_HOST:localhost}
|
||||
rabbitmq-port: ${RABBITMQ_PORT:5672}
|
||||
rabbitmq-username: ${RABBITMQ_USER:springuser}
|
||||
rabbitmq-password: ${RABBITMQ_PASSWORD:TheCleverWho}
|
||||
rabbitmq-vhost: ${RABBITMQ_VHOST:/}
|
||||
# swarm env
|
||||
swarm-service-id: ${SWARM_SERVICE_ID:auth-service-id}
|
||||
swarm-task-id=: ${SWARM_TASK_ID:dummy-task-id}
|
||||
# backpressure
|
||||
initial-availability: ${MAX_AVAILABILITY:-1}
|
||||
|
||||
logging:
|
||||
level:
|
||||
# Set log levels as needed.
|
||||
|
||||
Reference in New Issue
Block a user