24 Commits

Author SHA1 Message Date
Gitea Action
16882046cf chore: update image tag to fd17be5 [skip ci] 2026-01-29 18:23:08 +00:00
fd17be5408 fix: harden GitOps deploy and rollback
All checks were successful
Build (develop) / Promote (main) / build-and-push-deploy (push) Successful in 1m22s
2026-01-29 15:21:09 -03:00
Gitea Action
ecd298442b chore: update image tag to 589fa29 [skip ci] 2026-01-29 17:59:46 +00:00
589fa2913c fix: correct pipeline to update k8s manifest
All checks were successful
Build (develop) / Promote (main) / build-and-push-deploy (push) Successful in 1m21s
2026-01-29 14:58:20 -03:00
587d097d9b ci: restrict workflow triggers to main branch only
Some checks failed
Build (develop) / Promote (main) / build-and-push-deploy (push) Failing after 1m15s
2026-01-29 14:52:27 -03:00
a694af97c6 feat: add app controller with version and health check endpoints
All checks were successful
Build (develop) / Promote (main) / build-and-push-deploy (push) Successful in 1m33s
2026-01-29 14:48:57 -03:00
6523c5f520 feat: Add API endpoints for application version and health checks.
All checks were successful
Build (develop) / Promote (main) / build-and-push-deploy (push) Successful in 1m21s
2026-01-29 14:31:33 -03:00
0c09ee795e feat: migrate registry to gitea and simplify workflow
All checks were successful
Build (develop) / Promote (main) / build-and-push-deploy (push) Successful in 1m24s
2026-01-29 14:23:24 -03:00
09396e334d feat: migrate registry to gitea and simplify workflow
All checks were successful
Build (develop) / Promote (main) / build-and-push-deploy (push) Successful in 1m25s
2026-01-29 14:20:09 -03:00
605d68b4b0 feat: migrate registry to gitea and simplify workflow
All checks were successful
Build (develop) / Promote (main) / build-and-push-deploy (push) Successful in 7m16s
2026-01-29 14:06:35 -03:00
c707d4a065 feat: migrate registry to gitea and simplify workflow
Some checks failed
Build (develop) / Promote (main) / build-and-push-deploy (push) Has been cancelled
2026-01-29 13:50:01 -03:00
0b28379145 feat: migrate registry to gitea and simplify workflow
Some checks failed
Build (develop) / Promote (main) / build-and-push-deploy (push) Failing after 6s
2026-01-29 13:47:26 -03:00
ca43de8756 fix: use harbor domain instead of ip to fix ssl error
Some checks failed
Build (develop) / Promote (main) / build-and-push-deploy (push) Failing after 20s
2026-01-29 13:31:20 -03:00
bb21ca33e4 fix: update registry url to oci.simplifiquehc.com.br
Some checks failed
Build (develop) / Promote (main) / build-and-push-deploy (push) Failing after 22s
2026-01-29 13:26:13 -03:00
48d6e64ada fix: update registry url to oci.simplifiquehc.com.br
Some checks failed
Build (develop) / Promote (main) / build-and-push-deploy (push) Failing after 24s
2026-01-29 13:24:58 -03:00
e0731db836 fix: update registry url to oci.simplifiquehc.com.br
Some checks failed
Build (develop) / Promote (main) / build-and-push-deploy (push) Failing after 34s
2026-01-29 13:17:15 -03:00
d2265390bd chore: organize project and update service
Some checks failed
Build (develop) / Promote (main) / build-and-push-deploy (push) Failing after 23s
2026-01-29 12:55:15 -03:00
a34c7c415c fix: update workflow to support homolog branch
Some checks failed
Build (develop) / Promote (main) / build-and-push-deploy (push) Failing after 25s
2026-01-29 12:50:47 -03:00
4975d5547d chore: organize project and update service
Some checks failed
Build (develop) / Promote (main) / build-and-push-deploy (push) Failing after 24s
2026-01-29 12:44:11 -03:00
fa6f0e0f49 chore: organize project and update service 2026-01-29 12:43:41 -03:00
c9335a27e5 Merge branch 'docs/k8s-workflow' into homolog 2026-01-29 12:42:01 -03:00
1270c04a2c Update deploy-api.yaml workflow 2026-01-29 02:17:39 -03:00
Luis Eduardo Estevao
ca892daffa feat: implement SalesService for product retrieval, filtering, pagination, and caching.
All checks were successful
Deploy NestJS API / build-and-push-deploy (push) Successful in 2m9s
2026-01-26 06:36:09 -03:00
8e09813741 Atualizar src/main.ts
All checks were successful
Deploy NestJS API / build-and-push-deploy (push) Successful in 2m18s
2026-01-20 18:17:02 -05:00
12 changed files with 151 additions and 60 deletions

View File

@@ -1,23 +1,41 @@
name: Deploy NestJS API name: Build (develop) / Promote (main)
on: [push] on:
push:
branches: [main]
jobs: jobs:
build-and-push-deploy: build-and-push-deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login no Harbor - name: Build and Push
run: | run: |
echo "${{ secrets.HARBOR_PASSWORD }}" | docker login 172.35.0.216 -u ${{ secrets.HARBOR_USERNAME }} --password-stdin REGISTRY="git.simplifiquehc.com.br"
IMAGE_NAME="$REGISTRY/simplifique/vendaweb-api"
SHA_TAG=$(echo ${{ gitea.sha }} | cut -c1-7)
- name: Build e Push echo "${{ secrets.K8S }}" | docker login "$REGISTRY" -u "${{ gitea.actor }}" --password-stdin
docker build -t "$IMAGE_NAME:$SHA_TAG" -t "$IMAGE_NAME:latest" .
docker push "$IMAGE_NAME:$SHA_TAG"
docker push "$IMAGE_NAME:latest"
- name: Update Manifest and Push to Git
run: | run: |
TAG=${{ gitea.sha }} SHA_TAG=$(echo ${{ gitea.sha }} | cut -c1-7)
docker build -t 172.35.0.216/library/vendaweb-api:$TAG . IMAGE_NAME="git.simplifiquehc.com.br/simplifique/vendaweb-api"
docker tag 172.35.0.216/library/vendaweb-api:$TAG 172.35.0.216/library/vendaweb-api:latest
MANIFEST_FILE="k8s/overlays/prod/deployment-image-digest-patch.yaml"
docker push 172.35.0.216/library/vendaweb-api:$TAG
docker push 172.35.0.216/library/vendaweb-api:latest sed -i "s|image: $IMAGE_NAME:.*|image: $IMAGE_NAME:$SHA_TAG|g" "$MANIFEST_FILE"
git config user.name "Gitea Action"
git config user.email "actions@simplifiquehc.com.br"
git add "$MANIFEST_FILE"
git commit -m "chore: update image tag to $SHA_TAG [skip ci]"
git push origin main

View File

@@ -1,39 +1,55 @@
# Estágio 1: Build ARG NODE_VERSION=16.20
FROM node:16-bullseye-slim AS builder ARG DEBIAN_VARIANT=bullseye
FROM node:${NODE_VERSION}-${DEBIAN_VARIANT} AS builder
WORKDIR /app WORKDIR /app
COPY package*.json ./
RUN npm install --legacy-peer-deps
COPY . .
RUN npm run build
FROM node:16-bullseye-slim ARG INSTANTCLIENT_ZIP_URL=https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip
# Instalar dependências do Oracle RUN apt-get update \
RUN apt-get update && apt-get install -y \ && apt-get install -y --no-install-recommends ca-certificates wget unzip libaio1 libnsl2 \
libaio1 \ && rm -rf /var/lib/apt/lists/* \
unzip \ && mkdir -p /opt/oracle \
wget \ && wget -q "${INSTANTCLIENT_ZIP_URL}" -O /opt/oracle/instantclient.zip \
&& mkdir -p /opt/oracle && unzip -q /opt/oracle/instantclient.zip -d /opt/oracle \
&& rm /opt/oracle/instantclient.zip \
&& rm -f /opt/oracle/instantclient_*/ojdbc*.jar \
/opt/oracle/instantclient_*/ucp*.jar \
/opt/oracle/instantclient_*/xstreams.jar \
/opt/oracle/instantclient_*/adrci \
/opt/oracle/instantclient_*/genezi \
/opt/oracle/instantclient_*/uidrvci \
&& ln -s "$(ls -d /opt/oracle/instantclient_* | head -n 1)" /opt/oracle/instantclient
# Instalar Oracle Instant Client
RUN wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basic-linuxx64.zip -O /opt/oracle/client.zip && \
unzip /opt/oracle/client.zip -d /opt/oracle && \
rm /opt/oracle/client.zip && \
ln -s /opt/oracle/instantclient_* /opt/oracle/instantclient
# Configurar o sistema para encontrar as bibliotecas do Oracle
ENV LD_LIBRARY_PATH=/opt/oracle/instantclient ENV LD_LIBRARY_PATH=/opt/oracle/instantclient
RUN echo "/opt/oracle/instantclient" > /etc/ld.so.conf.d/oracle-instantclient.conf && ldconfig ENV PATH=/opt/oracle/instantclient:$PATH
COPY package*.json ./
ENV NPM_CONFIG_LEGACY_PEER_DEPS=true
RUN npm ci
COPY . .
RUN npm run build \
&& npm prune --omit=dev --legacy-peer-deps \
&& npm cache clean --force
FROM node:${NODE_VERSION}-${DEBIAN_VARIANT}-slim AS runtime
WORKDIR /app WORKDIR /app
# Copiar apenas o necessário do estágio anterior ENV NODE_ENV=production
COPY --from=builder /app/dist ./dist ENV LD_LIBRARY_PATH=/opt/oracle/instantclient
ENV PATH=/opt/oracle/instantclient:$PATH
RUN apt-get update \
&& apt-get install -y --no-install-recommends libaio1 libnsl2 \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /opt/oracle /opt/oracle
COPY --from=builder /app/package*.json ./ COPY --from=builder /app/package*.json ./
COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
# Variáveis de ambiente padrão para o driver oracledb EXPOSE 8065
ENV OCI_LIB_DIR=/opt/oracle/instantclient
ENV OCI_INC_DIR=/opt/oracle/instantclient/sdk/include
CMD ["npm", "run", "start:prod"] CMD ["node", "dist/main"]

View File

@@ -31,9 +31,9 @@ O diretório `base` contém as definições padrão dos recursos que são comuns
### Deployment (`deployment.yaml`) ### Deployment (`deployment.yaml`)
- **Nome**: `vendaweb-api` - **Nome**: `vendaweb-api`
- **Replicas**: 15 (Configuração base) - **Replicas**: 3 (Base) / 15 (Produção via overlay)
- **Imagem**: `172.35.0.216/library/vendaweb-api:latest` - **Imagem**: `git.simplifiquehc.com.br/simplifique/vendaweb-api:<sha>`
- **Porta do Container**: 8065 - **Porta do Container**: 8067
- **Resources**: - **Resources**:
- Requests: CPU 100m, Memory 256Mi - Requests: CPU 100m, Memory 256Mi
- Limits: CPU 500m, Memory 512Mi - Limits: CPU 500m, Memory 512Mi
@@ -52,7 +52,7 @@ O diretório `base` contém as definições padrão dos recursos que são comuns
A sobreposição de produção personaliza a configuração base para o ambiente produtivo. A sobreposição de produção personaliza a configuração base para o ambiente produtivo.
- **Namespace**: `vendaweb-prod` - **Namespace**: `vendaweb-prod`
- **Patches**: Aplica modificações específicas (ex: digest da imagem, configurações específicas de serviço) via `kustomization.yaml`. - **Patches**: Aplica modificações específicas (ex: tag da imagem, NodePort do service, replicas) via `kustomization.yaml`.
## Deploy com ArgoCD (`k8s/argocd`) ## Deploy com ArgoCD (`k8s/argocd`)
@@ -68,7 +68,7 @@ O deploy é gerenciado pelo ArgoCD, que sincroniza o estado do cluster com o rep
- Path: `k8s/overlays/prod` (Aponta para o overlay de produção) - Path: `k8s/overlays/prod` (Aponta para o overlay de produção)
- **Destino (Destination)**: - **Destino (Destination)**:
- Cluster: `https://kubernetes.default.svc` - Cluster: `https://kubernetes.default.svc`
- Namespace: `vendaweb-api` (Nota: O patch define `vendaweb-prod`, verifique a consistência) - Namespace: `vendaweb-prod`
- **Sync Policy**: Automatizado com `selfHeal` ativado e criação automática de namespace. - **Sync Policy**: Automatizado com `selfHeal` ativado e criação automática de namespace.
--- ---

View File

@@ -14,7 +14,7 @@ Os workflows estão definidos no diretório `.gitea/workflows/`. O principal wor
Este workflow é acionado automaticamente no evento: Este workflow é acionado automaticamente no evento:
- `push`: Em qualquer branch (configuração atual `on: [push]`). - `push`: Na branch `main`.
### Jobs ### Jobs
@@ -39,10 +39,13 @@ Este job é responsável por construir a imagem Docker e enviá-la para o regist
3. **Build e Push** 3. **Build e Push**
- Constrói a imagem Docker da aplicação. - Constrói a imagem Docker da aplicação.
- Tags geradas: - Tags geradas:
- `172.35.0.216/library/vendaweb-api:$TAG` (onde `$TAG` é o SHA do commit do Gitea `gitea.sha`) - `git.simplifiquehc.com.br/simplifique/vendaweb-api:$TAG` (onde `$TAG` é o SHA curto do commit)
- `172.35.0.216/library/vendaweb-api:latest` - `git.simplifiquehc.com.br/simplifique/vendaweb-api:latest`
- Envia ambas as tags para o registry. - Envia ambas as tags para o registry.
4. **Atualizar Manifest e Push no Git**
- Atualiza `k8s/overlays/prod/deployment-image-digest-patch.yaml` para apontar para a tag `$TAG`.
## Variáveis e Segredos (Secrets) ## Variáveis e Segredos (Secrets)
Para que o workflow funcione corretamente, as seguintes secrets devem estar configuradas nas configurações do repositório no Gitea: Para que o workflow funcione corretamente, as seguintes secrets devem estar configuradas nas configurações do repositório no Gitea:

View File

@@ -11,9 +11,17 @@ spec:
path: k8s/overlays/prod path: k8s/overlays/prod
destination: destination:
server: https://kubernetes.default.svc server: https://kubernetes.default.svc
namespace: vendaweb-api namespace: vendaweb-prod
syncPolicy: syncPolicy:
automated: automated:
selfHeal: true selfHeal: true
prune: true
retry:
limit: 2
backoff:
duration: 5s
factor: 2
maxDuration: 3m
syncOptions: syncOptions:
- CreateNamespace=true - CreateNamespace=true
- PruneLast=true

View File

@@ -5,7 +5,15 @@ metadata:
labels: labels:
app: vendaweb-api app: vendaweb-api
spec: spec:
replicas: 15 replicas: 3
revisionHistoryLimit: 5
minReadySeconds: 10
progressDeadlineSeconds: 600
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
selector: selector:
matchLabels: matchLabels:
app: vendaweb-api app: vendaweb-api
@@ -15,10 +23,11 @@ spec:
app: vendaweb-api app: vendaweb-api
spec: spec:
imagePullSecrets: imagePullSecrets:
- name: harbor-secret - name: gitea-auth
terminationGracePeriodSeconds: 30
containers: containers:
- name: api - name: api
image: 172.35.0.216/library/vendaweb-api:latest image: git.simplifiquehc.com.br/simplifique/vendaweb-api:589fa29
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
ports: ports:
- name: http - name: http

View File

@@ -7,4 +7,4 @@ spec:
spec: spec:
containers: containers:
- name: api - name: api
image: 172.35.0.216/library/vendaweb-api@sha256:aac490fcb4ef7baa95f1df01fa50d2d44bdb4ed12b235e5dd89e1d7dc3cd0a3a image: git.simplifiquehc.com.br/simplifique/vendaweb-api:fd17be5

View File

@@ -0,0 +1,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: vendaweb-api
spec:
replicas: 15

View File

@@ -7,5 +7,6 @@ resources:
- ../../base - ../../base
patches: patches:
- path: deployment-image-digest-patch.yaml
- path: service-patch.yaml - path: service-patch.yaml
- path: deployment-prod-patch.yaml
- path: deployment-image-digest-patch.yaml

View File

@@ -14,7 +14,7 @@ export class AppController {
@Get('health') @Get('health')
@ApiOperation({ summary: 'Health check' }) @ApiOperation({ summary: 'Health check' })
healthCheck() { healthCheck() {
return { status: 'SIMPLIFIQUE HOME CENTER 2026' }; return { status: 'SIMPLIFIQUE HOME CENTER 202' };
} }
} }

View File

@@ -16,7 +16,7 @@ async function bootstrap() {
do cadastro de parceiros, consulta de venda de movimentação e pagamentos, e fechamento das comissões dos parceiros.`) do cadastro de parceiros, consulta de venda de movimentação e pagamentos, e fechamento das comissões dos parceiros.`)
.setVersion("2023.1.2") .setVersion("2023.1.2")
.addTag("VendaWeb") .addTag("VendaWeb")
.addTag("Autenticação") .addTag("Auth")
.build(); .build();
const document = SwaggerModule.createDocument(app, options); const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup("docs", app, document); SwaggerModule.setup("docs", app, document);

View File

@@ -1448,7 +1448,7 @@ export class SalesService {
const queryRunner = connectionDb.createQueryRunner(); const queryRunner = connectionDb.createQueryRunner();
await queryRunner.connect(); await queryRunner.connect();
try { try {
const sql = 'SELECT ESVCALCULOFRETE.CODTABELAFRETE as "id" ' + /*const sql = 'SELECT ESVCALCULOFRETE.CODTABELAFRETE as "id" ' +
' ,ESVCALCULOFRETE.CODFILIAL as "store" ' + ' ,ESVCALCULOFRETE.CODFILIAL as "store" ' +
' ,ESVCALCULOFRETE.CODCIDADE as "cityId" ' + ' ,ESVCALCULOFRETE.CODCIDADE as "cityId" ' +
' ,PCCIDADE.NOMECIDADE as "cityName" ' + ' ,PCCIDADE.NOMECIDADE as "cityName" ' +
@@ -1462,7 +1462,22 @@ export class SalesService {
' AND ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE ' + ' AND ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE ' +
' AND ESVCALCULOFRETE.CODCIDADE = :1 ' + ' AND ESVCALCULOFRETE.CODCIDADE = :1 ' +
' AND ESVCALCULOFRETE.IDCART = :2 ' + ' AND ESVCALCULOFRETE.IDCART = :2 ' +
' ORDER BY VLFRETE'; ' ORDER BY VLFRETE';*/
const sql = `SELECT 0 as "id"
,'1' as "store"
,ESVCALCULOFRETE.CODCIDADE as "cityId"
,PCCIDADE.NOMECIDADE as "cityName"
,NULL as "carrierId"
,'SIMPLIFIQUE HOMECENTER' as "carrierName"
,0 as "minSale"
,ESVCALCULOFRETE.VLFRETE as "deliveryValue"
,NULL as "deliveryTime"
FROM ESVCALCULOFRETE, PCCIDADE
WHERE ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE
AND ESVCALCULOFRETE.CODCIDADE = :1
AND ESVCALCULOFRETE.IDCART = :2
ORDER BY VLFRETE`;
const deliveryTaxTable = await queryRunner.manager const deliveryTaxTable = await queryRunner.manager
.query(sql, [cityId, cartId]); .query(sql, [cityId, cartId]);
@@ -1514,7 +1529,22 @@ export class SalesService {
const queryRunner = connectionDb.createQueryRunner(); const queryRunner = connectionDb.createQueryRunner();
await queryRunner.connect(); await queryRunner.connect();
try { try {
const sql = 'SELECT ESVCALCULOFRETE.CODTABELAFRETE as "id" ' + const sql = `SELECT 0 as "id"
,'1' as "store"
,ESVCALCULOFRETE.CODCIDADE as "cityId"
,PCCIDADE.NOMECIDADE as "cityName"
,NULL as "carrierId"
,'SIMPLIFIQUE HOMECENTER' as "carrierName"
,0 as "minSale"
,ESVCALCULOFRETE.VLFRETE as "deliveryValue"
,NULL as "deliveryTime"
FROM ESVCALCULOFRETE, PCCIDADE
WHERE ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE
AND ESVCALCULOFRETE.CODCIDADE = :1
AND ESVCALCULOFRETE.IDCART = :2
ORDER BY VLFRETE`;
/*const sql = 'SELECT ESVCALCULOFRETE.CODTABELAFRETE as "id" ' +
' ,ESVCALCULOFRETE.CODFILIAL as "store" ' + ' ,ESVCALCULOFRETE.CODFILIAL as "store" ' +
' ,ESVCALCULOFRETE.CODCIDADE as "cityId" ' + ' ,ESVCALCULOFRETE.CODCIDADE as "cityId" ' +
' ,PCCIDADE.NOMECIDADE as "cityName" ' + ' ,PCCIDADE.NOMECIDADE as "cityName" ' +
@@ -1528,7 +1558,7 @@ export class SalesService {
' AND ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE ' + ' AND ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE ' +
' AND ESVCALCULOFRETE.CODCIDADE = :1 ' + ' AND ESVCALCULOFRETE.CODCIDADE = :1 ' +
' AND ESVCALCULOFRETE.IDCART = :2 ' + ' AND ESVCALCULOFRETE.IDCART = :2 ' +
' ORDER BY VLFRETE'; ' ORDER BY VLFRETE';*/
let deliveryTaxTable = await queryRunner.manager let deliveryTaxTable = await queryRunner.manager
.query(sql, [dataDeliveryTax.cityId, dataDeliveryTax.cartId]); .query(sql, [dataDeliveryTax.cityId, dataDeliveryTax.cartId]);