feat: init k8s and customer service (#15)
Release package / release (push) Failing after 2m10s
Release package / release (push) Failing after 2m10s
Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Reviewed-on: #15
This commit was merged in pull request #15.
This commit is contained in:
@@ -1,18 +1,44 @@
|
|||||||
FROM alpine:3.22
|
FROM ubuntu:26.04
|
||||||
|
|
||||||
RUN apk update && apk add --no-cache \
|
# Tránh các câu hỏi tương tác trong quá trình cài đặt
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y ca-certificates && apt-get clean
|
||||||
|
|
||||||
|
RUN sed -i 's|http://archive.ubuntu.com|https://apt.demonkernel.io.vn|g' /etc/apt/sources.list.d/ubuntu.sources && \
|
||||||
|
sed -i 's|http://security.ubuntu.com|https://apt.demonkernel.io.vn|g' /etc/apt/sources.list.d/ubuntu.sources
|
||||||
|
|
||||||
|
# 1. Cài đặt các công cụ cơ bản
|
||||||
|
RUN apt-get update --fix-missing && apt-get install --no-install-recommends --no-install-suggests -y \
|
||||||
curl \
|
curl \
|
||||||
bash \
|
bash \
|
||||||
openjdk21-jdk \
|
build-essential \
|
||||||
maven \
|
docker-buildx \
|
||||||
git \
|
git \
|
||||||
ca-certificates \
|
docker.io \
|
||||||
pnpm
|
maven \
|
||||||
|
libz-dev
|
||||||
|
|
||||||
# git trust all directories
|
# 5. Cấu hình Git
|
||||||
RUN git config --global --add safe.directory '*'
|
RUN git config --global --add safe.directory '*'
|
||||||
|
|
||||||
# Install quarkus
|
# 2. Cài đặt Node.js & PNPM (thay thế cho apk pnpm)
|
||||||
|
RUN curl -fsSL https://get.pnpm.io/install.sh | bash -
|
||||||
|
|
||||||
|
# 3. Cài đặt Kubectl
|
||||||
|
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \
|
||||||
|
&& install -m 0755 kubectl /usr/local/bin/kubectl
|
||||||
|
|
||||||
|
# 4. Cài đặt Mandrel 25
|
||||||
|
# Lưu ý: Dùng bản linux-amd64 (glibc) tiêu chuẩn cho Ubuntu
|
||||||
|
ENV JAVA_HOME=/usr/lib/jvm/mandrel
|
||||||
|
ENV GRAALVM_HOME=/usr/lib/jvm/mandrel
|
||||||
|
ENV PATH="${JAVA_HOME}/bin:${PATH}"
|
||||||
|
|
||||||
|
RUN mkdir -p ${JAVA_HOME} && \
|
||||||
|
curl -L https://github.com/graalvm/mandrel/releases/download/mandrel-25.0.2.0-Final/mandrel-java25-linux-amd64-25.0.2.0-Final.tar.gz | tar -xz -C ${JAVA_HOME} --strip-components=1
|
||||||
|
|
||||||
|
# 6. Cài đặt JBang & Quarkus CLI
|
||||||
ENV JBANG_DIR="/root/.jbang"
|
ENV JBANG_DIR="/root/.jbang"
|
||||||
ENV PATH="${JBANG_DIR}/bin:${PATH}"
|
ENV PATH="${JBANG_DIR}/bin:${PATH}"
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
{
|
{
|
||||||
"dockerComposeFile": "docker-compose.main.yaml",
|
"dockerComposeFile": "docker-compose.main.yaml",
|
||||||
"mounts": [
|
"mounts": [
|
||||||
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
|
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind",
|
||||||
|
"source=${localEnv:USERPROFILE}/.kube,target=/root/.kube,type=bind"
|
||||||
],
|
],
|
||||||
"remoteUser": "root",
|
"remoteUser": "root",
|
||||||
"service": "devcontainer",
|
"service": "devcontainer",
|
||||||
@@ -24,5 +25,5 @@
|
|||||||
"TESTCONTAINERS_RYUK_DISABLED": "true",
|
"TESTCONTAINERS_RYUK_DISABLED": "true",
|
||||||
"QUARKUS_DEBUG_HOST": "0.0.0.0"
|
"QUARKUS_DEBUG_HOST": "0.0.0.0"
|
||||||
},
|
},
|
||||||
"forwardPorts": [5005]
|
"forwardPorts": [5005, 8080]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ on:
|
|||||||
- main
|
- main
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -25,8 +25,13 @@ jobs:
|
|||||||
- name: Set up JDK
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@v5
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: "temurin"
|
distribution: "graalvm"
|
||||||
java-version: "21"
|
java-version: "25"
|
||||||
|
cache: "maven"
|
||||||
|
|
||||||
|
- uses: gerlero/apt-install@v1
|
||||||
|
with:
|
||||||
|
packages: build-essential zlib1g-dev docker.io
|
||||||
|
|
||||||
- name: Cache Maven packages
|
- name: Cache Maven packages
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
@@ -37,7 +42,9 @@ jobs:
|
|||||||
${{ runner.os }}-maven-
|
${{ runner.os }}-maven-
|
||||||
|
|
||||||
- name: Build and Test all modules
|
- name: Build and Test all modules
|
||||||
run: ./mvnw -B install -Dquarkus.container-image.build=false -Dquarkus.container-image.push=false
|
run: |
|
||||||
|
./mvnw -B install \
|
||||||
|
-Dquarkus.container-image.push=false \
|
||||||
|
|
||||||
- name: Publish Test Report
|
- name: Publish Test Report
|
||||||
uses: scacap/action-surefire-report@v1
|
uses: scacap/action-surefire-report@v1
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
wrapperVersion=3.3.4
|
wrapperVersion=3.3.4
|
||||||
distributionType=only-script
|
distributionType=only-script
|
||||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip
|
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip
|
||||||
distributionSha256Sum=305773a68d6ddfd413df58c82b3f8050e89778e777f3a745c8e5b8cbea4018ef
|
distributionSha256Sum=
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@
|
|||||||
[
|
[
|
||||||
"@semantic-release/exec",
|
"@semantic-release/exec",
|
||||||
{
|
{
|
||||||
"prepareCmd": "./mvnw versions:set -DnewVersion=${nextRelease.version} && sed -i \"s|\\(image: git.demonkernel.io.vn/foodsurf/[^:]*\\):.*|\\1:${nextRelease.version}|g\" k8s.yaml",
|
"prepareCmd": "./mvnw versions:set -DnewVersion=${nextRelease.version} && sed -i \"/-service:/ s|:[^:]*$|:${nextRelease.version}|\" k8s.yaml",
|
||||||
"publishCmd": "if [ \"${branch.name}\" = \"main\" ]; then ./mvnw package -Dquarkus.container-image.tag=${nextRelease.version} -DskipTests; fi"
|
"publishCmd": "if [ \"${branch.name}\" = \"main\" ]; then ./mvnw package -Dquarkus.container-image.tag=${nextRelease.version} -DskipTests; fi"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<compiler-plugin.version>3.15.0</compiler-plugin.version>
|
<compiler-plugin.version>3.15.0</compiler-plugin.version>
|
||||||
<maven.compiler.release>21</maven.compiler.release>
|
<maven.compiler.release>25</maven.compiler.release>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding
|
<project.reporting.outputEncoding
|
||||||
>UTF-8</project.reporting.outputEncoding>
|
>UTF-8</project.reporting.outputEncoding>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.drinkool.models;
|
|||||||
|
|
||||||
import com.drinkool.entities.BaseEntity;
|
import com.drinkool.entities.BaseEntity;
|
||||||
import com.drinkool.utils.PhoneValidator;
|
import com.drinkool.utils.PhoneValidator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.password4j.Password;
|
import com.password4j.Password;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import jakarta.transaction.*;
|
import jakarta.transaction.*;
|
||||||
@@ -20,6 +21,7 @@ public abstract class UserModel extends BaseEntity {
|
|||||||
public String phone;
|
public String phone;
|
||||||
|
|
||||||
@Column(nullable = false, length = 1024)
|
@Column(nullable = false, length = 1024)
|
||||||
|
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||||
public String hashedPassword;
|
public String hashedPassword;
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.drinkool.services;
|
package com.drinkool.services;
|
||||||
|
|
||||||
|
import com.drinkool.Jwt;
|
||||||
|
import com.drinkool.Role;
|
||||||
import com.drinkool.Url;
|
import com.drinkool.Url;
|
||||||
import com.drinkool.dtos.*;
|
import com.drinkool.dtos.*;
|
||||||
import com.drinkool.entities.CustomerEntity;
|
import com.drinkool.entities.CustomerEntity;
|
||||||
@@ -22,7 +24,10 @@ public class AuthenticationService {
|
|||||||
|
|
||||||
newCustomer.signup(input.name, input.phone, input.password);
|
newCustomer.signup(input.name, input.phone, input.password);
|
||||||
|
|
||||||
return Response.status(Response.Status.CREATED).build();
|
return Response.status(Response.Status.CREATED)
|
||||||
|
.header(Jwt.userId, newCustomer.id.toString())
|
||||||
|
.header(Jwt.role, Role.Customer)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@@ -33,7 +38,10 @@ public class AuthenticationService {
|
|||||||
|
|
||||||
newCustomer.signup(input.phone);
|
newCustomer.signup(input.phone);
|
||||||
|
|
||||||
return Response.status(Response.Status.CREATED).build();
|
return Response.status(Response.Status.CREATED)
|
||||||
|
.header(Jwt.userId, newCustomer.id.toString())
|
||||||
|
.header(Jwt.role, Role.Customer)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@@ -44,29 +52,54 @@ public class AuthenticationService {
|
|||||||
input.phone
|
input.phone
|
||||||
).firstResult();
|
).firstResult();
|
||||||
|
|
||||||
if (customer == null) throw new BadRequestException("InvalidPhoneNumber");
|
if (customer == null) return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("InvalidPhoneNumber")
|
||||||
|
.build();
|
||||||
|
|
||||||
if (!customer.login(input.password)) throw new BadRequestException(
|
if (!customer.login(input.password)) return Response.status(
|
||||||
"InvalidPassword"
|
Response.Status.BAD_REQUEST
|
||||||
);
|
)
|
||||||
|
.entity("InvalidPassword")
|
||||||
|
.build();
|
||||||
|
|
||||||
return Response.accepted().build();
|
return Response.accepted()
|
||||||
|
.header(Jwt.userId, customer.id.toString())
|
||||||
|
.header(Jwt.role, Role.Customer)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path(Url.QuickLogin)
|
@Path(Url.QuickLogin)
|
||||||
public Response quickLogin(QuickLogin input) {
|
public Response quickLogin(QuickLogin input) {
|
||||||
if (otpService.verifyOtp(input.phone, input.otp)) {
|
if (!otpService.verifyOtp(input.phone, input.otp)) {
|
||||||
return Response.accepted().build();
|
|
||||||
}
|
|
||||||
return Response.status(Response.Status.UNAUTHORIZED)
|
return Response.status(Response.Status.UNAUTHORIZED)
|
||||||
.entity("InvalidOTP")
|
.entity("InvalidOTP")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CustomerEntity customer = CustomerEntity.find(
|
||||||
|
"phone",
|
||||||
|
input.phone
|
||||||
|
).firstResult();
|
||||||
|
|
||||||
|
return Response.accepted()
|
||||||
|
.header(Jwt.userId, customer.id.toString())
|
||||||
|
.header(Jwt.role, Role.Customer)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path(Url.SmsOtp)
|
@Path(Url.SmsOtp)
|
||||||
public Response smsOtp(SmsOtp input) {
|
public Response smsOtp(SmsOtp input) {
|
||||||
|
CustomerEntity customer = CustomerEntity.find(
|
||||||
|
"phone",
|
||||||
|
input.phone
|
||||||
|
).firstResult();
|
||||||
|
|
||||||
|
if (customer == null) return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("InvalidPhoneNumber")
|
||||||
|
.build();
|
||||||
|
|
||||||
String otp = otpService.generateAndSaveOtp(input.phone);
|
String otp = otpService.generateAndSaveOtp(input.phone);
|
||||||
|
|
||||||
// Ở đây bạn sẽ gọi Kafka để gửi SMS thực tế
|
// Ở đây bạn sẽ gọi Kafka để gửi SMS thực tế
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.drinkool.services;
|
||||||
|
|
||||||
|
import com.drinkool.Jwt;
|
||||||
|
import com.drinkool.Url;
|
||||||
|
import com.drinkool.models.UserModel;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import jakarta.ws.rs.*;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Path("")
|
||||||
|
public class UserService {
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path(Url.Me)
|
||||||
|
@Transactional
|
||||||
|
public Response me(@HeaderParam(Jwt.userId) UUID id) {
|
||||||
|
if (id == null) return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity("InvalidUserId")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return Response.ok(UserModel.find("id", id).firstResult()).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ quarkus.container-image.name=account-service
|
|||||||
quarkus.container-image.push=true
|
quarkus.container-image.push=true
|
||||||
quarkus.container-image.build=true
|
quarkus.container-image.build=true
|
||||||
quarkus.container-image.builder=docker
|
quarkus.container-image.builder=docker
|
||||||
|
quarkus.container-image.additional-tags=latest
|
||||||
|
|
||||||
# Redis
|
# Redis
|
||||||
quarkus.redis.hosts=redis://localhost:6379
|
quarkus.redis.hosts=redis://localhost:6379
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.drinkool.services;
|
package com.drinkool.services;
|
||||||
|
|
||||||
import static io.restassured.RestAssured.given;
|
import static io.restassured.RestAssured.*;
|
||||||
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
import com.drinkool.Jwt;
|
||||||
|
import com.drinkool.Role;
|
||||||
import com.drinkool.Url;
|
import com.drinkool.Url;
|
||||||
import com.drinkool.dtos.*;
|
import com.drinkool.dtos.*;
|
||||||
import com.drinkool.entities.CustomerEntity;
|
import com.drinkool.entities.CustomerEntity;
|
||||||
@@ -14,9 +17,9 @@ import org.junit.jupiter.api.Test;
|
|||||||
@QuarkusTest
|
@QuarkusTest
|
||||||
public class AuthenticationServiceTest {
|
public class AuthenticationServiceTest {
|
||||||
|
|
||||||
private Random random = new Random();
|
public static Random random = new Random();
|
||||||
|
|
||||||
private String generateRandomPhone() {
|
public static String generateRandomPhone() {
|
||||||
return "+8477" + String.format("%07d", random.nextInt(10000000));
|
return "+8477" + String.format("%07d", random.nextInt(10000000));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,6 +55,8 @@ public class AuthenticationServiceTest {
|
|||||||
.when()
|
.when()
|
||||||
.post(Url.QuickSignup)
|
.post(Url.QuickSignup)
|
||||||
.then()
|
.then()
|
||||||
|
.header(Jwt.userId, notNullValue())
|
||||||
|
.header(Jwt.role, is(Role.Customer))
|
||||||
.statusCode(201);
|
.statusCode(201);
|
||||||
|
|
||||||
assertEquals(1, CustomerEntity.find("phone", phone).count());
|
assertEquals(1, CustomerEntity.find("phone", phone).count());
|
||||||
@@ -121,6 +126,18 @@ public class AuthenticationServiceTest {
|
|||||||
SmsOtp input = new SmsOtp();
|
SmsOtp input = new SmsOtp();
|
||||||
input.phone = phone;
|
input.phone = phone;
|
||||||
|
|
||||||
|
Signup signup = new Signup();
|
||||||
|
signup.phone = phone;
|
||||||
|
signup.name = "sms user";
|
||||||
|
signup.password = "password123";
|
||||||
|
|
||||||
|
given()
|
||||||
|
.contentType(ContentType.JSON)
|
||||||
|
.body(signup)
|
||||||
|
.when()
|
||||||
|
.post(Url.Signup)
|
||||||
|
.then();
|
||||||
|
|
||||||
given()
|
given()
|
||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
.body(input)
|
.body(input)
|
||||||
@@ -128,9 +145,6 @@ public class AuthenticationServiceTest {
|
|||||||
.post(Url.SmsOtp)
|
.post(Url.SmsOtp)
|
||||||
.then()
|
.then()
|
||||||
.statusCode(202);
|
.statusCode(202);
|
||||||
|
|
||||||
// Lưu ý: Vì không dùng Mock, code sẽ chạy qua OtpService thật.
|
|
||||||
// Nếu OtpService lưu vào DB, bạn có thể bổ sung Assert tại đây để check OtpEntity.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.drinkool.services;
|
||||||
|
|
||||||
|
import static io.restassured.RestAssured.*;
|
||||||
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
|
|
||||||
|
import com.drinkool.Jwt;
|
||||||
|
import com.drinkool.Url;
|
||||||
|
import com.drinkool.dtos.QuickSignup;
|
||||||
|
|
||||||
|
import io.quarkus.test.junit.QuarkusTest;
|
||||||
|
import io.restassured.http.ContentType;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@QuarkusTest
|
||||||
|
public class UserServiceTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMeEndpointWithHeader() {
|
||||||
|
String phone = AuthenticationServiceTest.generateRandomPhone();
|
||||||
|
QuickSignup input = new QuickSignup();
|
||||||
|
input.phone = phone;
|
||||||
|
|
||||||
|
String testUserId = given()
|
||||||
|
.contentType(ContentType.JSON)
|
||||||
|
.body(input)
|
||||||
|
.when()
|
||||||
|
.post(Url.QuickSignup)
|
||||||
|
.then()
|
||||||
|
.extract()
|
||||||
|
.header(Jwt.userId);
|
||||||
|
|
||||||
|
given()
|
||||||
|
.header(Jwt.userId, testUserId)
|
||||||
|
.contentType(ContentType.JSON)
|
||||||
|
.when()
|
||||||
|
.post(Url.Me)
|
||||||
|
.then()
|
||||||
|
.statusCode(200)
|
||||||
|
.body("id", is(testUserId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMeEndpointWithoutHeader() {
|
||||||
|
given()
|
||||||
|
.when()
|
||||||
|
.post(Url.Me)
|
||||||
|
.then()
|
||||||
|
.statusCode(400);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<compiler-plugin.version>3.15.0</compiler-plugin.version>
|
<compiler-plugin.version>3.15.0</compiler-plugin.version>
|
||||||
<maven.compiler.release>21</maven.compiler.release>
|
<maven.compiler.release>25</maven.compiler.release>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding
|
<project.reporting.outputEncoding
|
||||||
>UTF-8</project.reporting.outputEncoding>
|
>UTF-8</project.reporting.outputEncoding>
|
||||||
|
|||||||
+8
-25
@@ -17,14 +17,15 @@
|
|||||||
<packaging>quarkus</packaging>
|
<packaging>quarkus</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
<quarkus.package.jar.enabled>false</quarkus.package.jar.enabled>
|
||||||
|
<skipITs>false</skipITs>
|
||||||
|
<quarkus.native.enabled>true</quarkus.native.enabled>
|
||||||
<compiler-plugin.version>3.15.0</compiler-plugin.version>
|
<compiler-plugin.version>3.15.0</compiler-plugin.version>
|
||||||
<maven.compiler.release>21</maven.compiler.release>
|
<maven.compiler.release>25</maven.compiler.release>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
>UTF-8</project.reporting.outputEncoding>
|
|
||||||
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
|
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
|
||||||
<quarkus.platform.group-id
|
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
|
||||||
>io.quarkus.platform</quarkus.platform.group-id>
|
|
||||||
<quarkus.platform.version>3.32.4</quarkus.platform.version>
|
<quarkus.platform.version>3.32.4</quarkus.platform.version>
|
||||||
<skipITs>true</skipITs>
|
<skipITs>true</skipITs>
|
||||||
<surefire-plugin.version>3.5.4</surefire-plugin.version>
|
<surefire-plugin.version>3.5.4</surefire-plugin.version>
|
||||||
@@ -101,8 +102,7 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<argLine>@{argLine}</argLine>
|
<argLine>@{argLine}</argLine>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<java.util.logging.manager
|
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||||
>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
|
||||||
<maven.home>${maven.home}</maven.home>
|
<maven.home>${maven.home}</maven.home>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -123,28 +123,11 @@
|
|||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<native.image.path>
|
<native.image.path>
|
||||||
${project.build.directory}/${project.build.finalName}-runner</native.image.path>
|
${project.build.directory}/${project.build.finalName}-runner</native.image.path>
|
||||||
<java.util.logging.manager
|
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||||
>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
|
||||||
<maven.home>${maven.home}</maven.home>
|
<maven.home>${maven.home}</maven.home>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>native</id>
|
|
||||||
<activation>
|
|
||||||
<property>
|
|
||||||
<name>native</name>
|
|
||||||
</property>
|
|
||||||
</activation>
|
|
||||||
<properties>
|
|
||||||
<quarkus.package.jar.enabled>false</quarkus.package.jar.enabled>
|
|
||||||
<skipITs>false</skipITs>
|
|
||||||
<quarkus.native.enabled>true</quarkus.native.enabled>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
</project>
|
</project>
|
||||||
@@ -5,3 +5,7 @@ quarkus.container-image.name=gateway-service
|
|||||||
quarkus.container-image.push=true
|
quarkus.container-image.push=true
|
||||||
quarkus.container-image.build=true
|
quarkus.container-image.build=true
|
||||||
quarkus.container-image.builder=docker
|
quarkus.container-image.builder=docker
|
||||||
|
quarkus.container-image.additional-tags=latest
|
||||||
|
|
||||||
|
# Build
|
||||||
|
quarkus.native.container-build=false
|
||||||
|
|||||||
@@ -2,25 +2,56 @@
|
|||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: account-service
|
name: account-deploy
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: account-service
|
app: account
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: account-service
|
app: account
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: account-service
|
- name: account-pod
|
||||||
image: git.demonkernel.io.vn/foodsurf/account-service:latest
|
image: git.demonkernel.io.vn/foodsurf/account-service:latest
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
env:
|
env:
|
||||||
- name: QUARKUS_REDIS_HOST
|
- name: QUARKUS_REDIS_HOST
|
||||||
value: "redis-service"
|
value: "redis-service"
|
||||||
|
- name: QUARKUS_DATASOURCE_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: postgres-credentials
|
||||||
|
key: password
|
||||||
|
- name: QUARKUS_DATASOURCE_USERNAME
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: postgres-credentials
|
||||||
|
key: username
|
||||||
|
- name: QUARKUS_DATASOURCE_JDBC_URL
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: postgres-credentials
|
||||||
|
key: url
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpu: "500m"
|
||||||
|
memory: "512Mi"
|
||||||
|
requests:
|
||||||
|
cpu: "100m"
|
||||||
|
memory: "256Mi"
|
||||||
|
volumeMounts:
|
||||||
|
- name: keys-volume
|
||||||
|
mountPath: "/etc/keys"
|
||||||
|
readOnly: true
|
||||||
|
volumes:
|
||||||
|
- name: keys-volume
|
||||||
|
secret:
|
||||||
|
secretName: jwt-keys
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
@@ -28,7 +59,7 @@ metadata:
|
|||||||
name: account-service
|
name: account-service
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
app: account-service
|
app: account
|
||||||
ports:
|
ports:
|
||||||
- port: 80
|
- port: 80
|
||||||
targetPort: 8080
|
targetPort: 8080
|
||||||
@@ -49,13 +80,29 @@ spec:
|
|||||||
app: gateway
|
app: gateway
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: gateway
|
- name: gateway-pod
|
||||||
image: git.demonkernel.io.vn/foodsurf/gateway-service:latest
|
image: git.demonkernel.io.vn/foodsurf/gateway-service:latest
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
env:
|
env:
|
||||||
- name: QUARKUS_REST_CLIENT_ACCOUNT_URL
|
- name: QUARKUS_REST_CLIENT_ACCOUNT_URL
|
||||||
value: "http://account-service"
|
value: "http://account-service"
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpu: "500m"
|
||||||
|
memory: "512Mi"
|
||||||
|
requests:
|
||||||
|
cpu: "100m"
|
||||||
|
memory: "256Mi"
|
||||||
|
volumeMounts:
|
||||||
|
- name: keys-volume
|
||||||
|
mountPath: "/etc/keys"
|
||||||
|
readOnly: true
|
||||||
|
volumes:
|
||||||
|
- name: keys-volume
|
||||||
|
secret:
|
||||||
|
secretName: jwt-keys
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
@@ -68,7 +115,7 @@ spec:
|
|||||||
ports:
|
ports:
|
||||||
- port: 80
|
- port: 80
|
||||||
targetPort: 8080
|
targetPort: 8080
|
||||||
nodePort: 39080
|
nodePort: 32080
|
||||||
---
|
---
|
||||||
# 3. REDIS
|
# 3. REDIS
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
@@ -85,7 +132,7 @@ spec:
|
|||||||
app: redis
|
app: redis
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: redis
|
- name: redis-pod
|
||||||
image: redis:alpine
|
image: redis:alpine
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 6379
|
- containerPort: 6379
|
||||||
|
|||||||
+2
-2
@@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
<artifactId>lib</artifactId>
|
<artifactId>lib</artifactId>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>21</maven.compiler.source>
|
<maven.compiler.source>25</maven.compiler.source>
|
||||||
<maven.compiler.target>21</maven.compiler.target>
|
<maven.compiler.target>25</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.drinkool;
|
||||||
|
|
||||||
|
public class Jwt {
|
||||||
|
public static final String headerId = "X-Internal-";
|
||||||
|
public static final String userId = headerId + "UserId";
|
||||||
|
public static final String role = headerId + "Role";
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.drinkool;
|
||||||
|
|
||||||
|
public class Role {
|
||||||
|
public static final String Customer = "customer";
|
||||||
|
}
|
||||||
@@ -7,4 +7,5 @@ public class Url {
|
|||||||
public static final String Login = "/login";
|
public static final String Login = "/login";
|
||||||
public static final String QuickLogin = "/quick_login";
|
public static final String QuickLogin = "/quick_login";
|
||||||
public static final String SmsOtp = "/sms_otp";
|
public static final String SmsOtp = "/sms_otp";
|
||||||
|
public static final String Me = "/me";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<version>1.1.0-dev.1</version>
|
<version>1.1.0-dev.1</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>21</maven.compiler.source>
|
<maven.compiler.source>25</maven.compiler.source>
|
||||||
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
|
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
|
||||||
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
|
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
|
||||||
<quarkus.platform.version>3.32.3</quarkus.platform.version>
|
<quarkus.platform.version>3.32.3</quarkus.platform.version>
|
||||||
|
|||||||
Reference in New Issue
Block a user