Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 33 additions & 41 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,58 +1,50 @@
# compiled output
/dist
/node_modules
/pgdata

# Logs
logs
*.log
# Node.js
node_modules
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store
# Build
dist

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Environment variables
# Ambiente / segredos
.env
.env.*
!.env.example

# Logs
logs
*.log

# Cloud Run / GCP
.gcloudignore
cloudbuild*.yaml

# Docker
Dockerfile
.dockerignore
.docker/

# temp directory
# IDEs
.vscode
.idea

# Sistema
.DS_Store
Thumbs.db

# Temporários
*.swp
*.tmp
.temp
.tmp
*~

# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Testes / cobertura
coverage
.nyc_output
test

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Banco local (NÃO subir dados do Cloud SQL)
pgdata
47 changes: 47 additions & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.gcloudignore
.git
.gitignore


node_modules/
npm-debug.log
yarn-error.log


dist/
build/
*.log


.env
.env.local
.env.*.local


.vscode/
.idea/
*.swp
*.swo
*~


.DS_Store
Thumbs.db


coverage/
.nyc_output/
test/


*.md
!README.md


.github/
.gitlab-ci.yml


*.tmp
*.temp

24 changes: 21 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
FROM node:23-alpine as builder

WORKDIR /app

COPY package*.json ./
RUN npm install
RUN npm ci --only=production && npm cache clean --force

COPY . .
RUN npm run build

FROM node:23-alpine

WORKDIR /app
USER node

RUN apk add --no-cache \
python3 \
make \
g++ \
&& rm -rf /var/cache/apk/*

COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
EXPOSE 3000
COPY --from=builder /app/package*.json ./

ENV NODE_ENV=production
ENV PORT=8080

EXPOSE 8080

USER node

CMD ["node", "dist/main"]
63 changes: 63 additions & 0 deletions cloudbuild-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
steps:
- name: 'gcr.io/cloud-builders/docker'
args:
- 'build'
- '-t'
- 'gcr.io/$PROJECT_ID/proae-backend-dev:$SHORT_SHA'
- '-t'
- 'gcr.io/$PROJECT_ID/proae-backend-dev:latest'
- '.'
id: 'build-image'

- name: 'gcr.io/cloud-builders/docker'
args:
- 'push'
- 'gcr.io/$PROJECT_ID/proae-backend-dev:$SHORT_SHA'
id: 'push-image-sha'

- name: 'gcr.io/cloud-builders/docker'
args:
- 'push'
- 'gcr.io/$PROJECT_ID/proae-backend-dev:latest'
id: 'push-image-latest'

# Deploy no Cloud Run
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
- 'run'
- 'deploy'
- 'proae-backend-dev'
- '--image'
- 'gcr.io/$PROJECT_ID/proae-backend-dev:$SHORT_SHA'
- '--region'
- '${_REGION}'
- '--platform'
- 'managed'
- '--allow-unauthenticated'
- '--service-account'
- '${_SERVICE_ACCOUNT}'
- '--add-cloudsql-instances'
- '${_CLOUD_SQL_CONNECTION_NAME}'
- '--set-env-vars'
- 'NODE_ENV=${_NODE_ENV},PORT=8080,USE_CLOUD_SQL=true,CLOUD_SQL_CONNECTION_NAME=${_CLOUD_SQL_CONNECTION_NAME}'
- '--set-secrets'
- 'DB_USERNAME=db-username-dev:latest,DB_PASSWORD=db-password-dev:latest,DB_NAME=db-name-dev:latest,JWT_SECRET=jwt-secret-dev:latest'
id: 'deploy-cloud-run'

options:
machineType: 'E2_HIGHCPU_8'
logging: CLOUD_LOGGING_ONLY

substitutions:
_REGION: 'us-central1'
_NODE_ENV: 'development'
_SERVICE_ACCOUNT: 'proae-backend-dev@${PROJECT_ID}.iam.gserviceaccount.com'
_CLOUD_SQL_CONNECTION_NAME: '${PROJECT_ID}:${_REGION}:proae-db-dev'

images:
- 'gcr.io/$PROJECT_ID/proae-backend-dev:$SHORT_SHA'
- 'gcr.io/$PROJECT_ID/proae-backend-dev:latest'

timeout: '1200s'

63 changes: 63 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
steps:
- name: 'gcr.io/cloud-builders/docker'
args:
- 'build'
- '-t'
- 'gcr.io/$PROJECT_ID/proae-backend:$SHORT_SHA'
- '-t'
- 'gcr.io/$PROJECT_ID/proae-backend:latest'
- '.'
id: 'build-image'

- name: 'gcr.io/cloud-builders/docker'
args:
- 'push'
- 'gcr.io/$PROJECT_ID/proae-backend:$SHORT_SHA'
id: 'push-image-sha'

- name: 'gcr.io/cloud-builders/docker'
args:
- 'push'
- 'gcr.io/$PROJECT_ID/proae-backend:latest'
id: 'push-image-latest'


- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
- 'run'
- 'deploy'
- 'proae-backend'
- '--image'
- 'gcr.io/$PROJECT_ID/proae-backend:$SHORT_SHA'
- '--region'
- '${_REGION}'
- '--platform'
- 'managed'
- '--allow-unauthenticated'
- '--service-account'
- '${_SERVICE_ACCOUNT}'
- '--add-cloudsql-instances'
- '${_CLOUD_SQL_CONNECTION_NAME}'
- '--set-env-vars'
- 'NODE_ENV=${_NODE_ENV},PORT=8080,USE_CLOUD_SQL=true,CLOUD_SQL_CONNECTION_NAME=${_CLOUD_SQL_CONNECTION_NAME}'
- '--set-secrets'
- 'DB_USERNAME=db-username:latest,DB_PASSWORD=db-password:latest,DB_NAME=db-name:latest,JWT_SECRET=jwt-secret:latest'
id: 'deploy-cloud-run'

options:
machineType: 'E2_HIGHCPU_8'
logging: CLOUD_LOGGING_ONLY

substitutions:
_REGION: 'us-central1'
_NODE_ENV: 'production'
_SERVICE_ACCOUNT: 'proae-backend@${PROJECT_ID}.iam.gserviceaccount.com'
_CLOUD_SQL_CONNECTION_NAME: '${PROJECT_ID}:${_REGION}:proae-db-prod'

images:
- 'gcr.io/$PROJECT_ID/proae-backend:$SHORT_SHA'
- 'gcr.io/$PROJECT_ID/proae-backend:latest'

timeout: '1200s'

Loading
Loading