Merge branch 'development' into 'devops-staging'

Development

See merge request empatnusabangsa/ppob/ppob-backend!91
This commit is contained in:
ilham dwi pratama 2022-01-06 16:22:25 +00:00
commit d9f964de90
10 changed files with 124 additions and 28 deletions

View File

@ -48,7 +48,7 @@ build-production:
services: services:
- docker:dind - docker:dind
script: script:
- docker login $REGISTRY_URL -u $NWP_REGISTRY_USER -p $NWP_REGISTRY_PASS - docker login $REGISTRY_URL -u $BKA_REGISTRY_USER -p $BKA_REGISTRY_PASS
- docker build -t $REGISTRY_IMAGE:$VERSION_PRODUCTION . - docker build -t $REGISTRY_IMAGE:$VERSION_PRODUCTION .
- docker push $REGISTRY_IMAGE:$VERSION_PRODUCTION - docker push $REGISTRY_IMAGE:$VERSION_PRODUCTION
- docker rmi $REGISTRY_IMAGE:$VERSION_PRODUCTION - docker rmi $REGISTRY_IMAGE:$VERSION_PRODUCTION
@ -59,9 +59,9 @@ deploy-production:
only: only:
- devops-production - devops-production
script: script:
- kubectl config set-cluster k8s --server="${NWP_CLUSTER_HOST}" - kubectl config set-cluster k8s --server="${BKA_CLUSTER_HOST}"
- kubectl config set clusters.k8s.certificate-authority-data ${NWP_CLUSTER_CA} - kubectl config set clusters.k8s.certificate-authority-data ${BKA_CLUSTER_CA}
- kubectl config set-credentials gitlab --token="${NWP_CLUSTER_TOKEN}" - kubectl config set-credentials gitlab --token="${BKA_CLUSTER_TOKEN}"
- kubectl config set-context default --cluster=k8s --user=gitlab - kubectl config set-context default --cluster=k8s --user=gitlab
- kubectl config use-context default - kubectl config use-context default
- sed -i "s/<VERSION>/${VERSION_PRODUCTION}/g" k8s/production/deployment.yaml - sed -i "s/<VERSION>/${VERSION_PRODUCTION}/g" k8s/production/deployment.yaml

View File

@ -0,0 +1,33 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ppob-backend
namespace: empatnusabangsa-production
spec:
selector:
matchLabels:
app: ppob-backend
replicas: 1
template:
metadata:
labels:
app: ppob-backend
spec:
containers:
- name: ppob-backend
image: registry-harbor.app.bangun-kreatif.com/empatnusabangsa/ppob-backend:<VERSION>
ports:
- containerPort: 5000
envFrom:
- secretRef:
name: ppob-backend-env
volumeMounts:
- name: storage
mountPath: /home/node/files
volumes:
- name: storage
persistentVolumeClaim:
claimName: ppob-backend-pvc
imagePullSecrets:
- name: regcred

View File

@ -0,0 +1,24 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ppob-backend
namespace: empatnusabangsa-production
annotations:
kubernetes.io/ingress.class: "traefik"
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
rules:
- host: "ppob-backend.k3s.bangun-kreatif.com"
http:
paths:
- pathType: Prefix
path: /
backend:
service:
name: ppob-backend
port:
number: 5000
tls:
- hosts:
- "ppob-backend.k3s.bangun-kreatif.com"
secretName: ppob-backend-k3s-bangun-kreatif-com-tls

View File

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: empatnusabangsa-production

13
k8s/production/pvc.yaml Normal file
View File

@ -0,0 +1,13 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: ppob-backend-pvc
namespace : empatnusabangsa-production
annotations:
volume.beta.kubernetes.io/storage-class: "managed-nfs-storage"
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi

View File

@ -0,0 +1,16 @@
apiVersion: v1
kind: Secret
metadata:
name: ppob-backend-env
namespace: empatnusabangsa-production
type: Opaque
stringData:
PORT:
SECRET:
DATABASE_HOST:
DATABASE_NAME:
DATABASE_USERNAME:
DATABASE_PASSWORD:
DATABASE_PORT:
DATABASE_CLIENT:

View File

@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: ppob-backend
namespace: empatnusabangsa-production
labels:
run: ppob-backend
spec:
ports:
- port: 5000
protocol: TCP
selector:
app: ppob-backend

View File

@ -10,4 +10,4 @@ spec:
- ReadWriteMany - ReadWriteMany
resources: resources:
requests: requests:
storage: 10Gi storage: 512m

View File

@ -84,28 +84,22 @@ export class ProductService {
where: { where: {
product: productData.id, product: productData.id,
partner: partnerData.id, partner: partnerData.id,
endDate: IsNull(),
}, },
}); });
} else { } else {
dataHistoryPrice = await this.productHistoryPrice.findOne({ dataHistoryPrice = await this.productHistoryPrice.findOne({
product: productData, product: productData,
partner: IsNull(), partner: IsNull(),
endDate: IsNull(),
}); });
} }
if (!dataHistoryPrice) { if (dataHistoryPrice) {
await this.productHistoryPrice.insert({ await this.productHistoryPrice.update(dataHistoryPrice.id, {
product: productData, endDate: new Date(),
mark_up_price: it[4],
price: it[3],
type: productType.NORMAL,
startDate: new Date(),
partner: it[6] != '-' ? partnerData : null,
}); });
} else { }
dataHistoryPrice.endDate = new Date();
await this.productHistoryPrice.save(dataHistoryPrice);
await this.productHistoryPrice.insert({ await this.productHistoryPrice.insert({
product: productData, product: productData,
@ -115,7 +109,6 @@ export class ProductService {
startDate: new Date(), startDate: new Date(),
partner: it[6] != '-' ? partnerData : null, partner: it[6] != '-' ? partnerData : null,
}); });
}
} else { } else {
let partnerData; let partnerData;
if (it[6] != '-' && it[6] != '') { if (it[6] != '-' && it[6] != '') {

View File

@ -762,7 +762,7 @@ export class TransactionService {
`${coaType[coaType.EXPENSE]}-SYSTEM`, `${coaType[coaType.EXPENSE]}-SYSTEM`,
); );
if (userData.partner) { if (!userData.partner) {
//GET SALES //GET SALES
supervisorData = await this.calculateCommission( supervisorData = await this.calculateCommission(
supervisorData, supervisorData,