Skip to content

Commit

Permalink
Merge pull request #56 from prefeiturasp/homolog
Browse files Browse the repository at this point in the history
Homolog - Fechamento Sprint 2
  • Loading branch information
alcfernandes authored Apr 9, 2020
2 parents f3ce817 + 008afe7 commit e3ec214
Show file tree
Hide file tree
Showing 76 changed files with 4,196 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_URL_API=
124 changes: 124 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

/_material
/.idea

# dependencies
/node_modules
/.pnp
.pnp.js
package-lock.json

# testing
/coverage

# production
/build

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Created by https://www.gitignore.io/api/webstorm
# Edit at https://www.gitignore.io/?templates=webstorm

### WebStorm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### WebStorm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
.idea/**/sonarlint/

# SonarQube Plugin
.idea/**/sonarIssues.xml

# Markdown Navigator plugin
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator/

# End of https://www.gitignore.io/api/webstorm
yarn.lock

.env
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# just to create `build` directory
FROM node:10.15.3-alpine as builder
WORKDIR /app
COPY . ./
RUN export NODE_PATH=src/ \
&& npm install \
&& npm run-script build

# replace strings, this way we can pass parameters to static files.
# For more details:
# https://stackoverflow.com/questions/48595829/how-to-pass-environment-variables-to-a-frontend-web-application

FROM nginx:alpine
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
COPY --from=builder /app/build /usr/share/nginx/html
COPY ./conf/default.conf /etc/nginx/conf.d/default.conf
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
206 changes: 206 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
pipeline {
agent {
node {
label 'py-uniformes'
}
}

options {
buildDiscarder(logRotator(numToKeepStr: '5', artifactNumToKeepStr: '5'))
disableConcurrentBuilds()
skipDefaultCheckout()
}

stages {
stage('CheckOut') {
steps {
checkout scm
}
}

stage('Analise codigo') {
when {
branch 'homolog'
}
steps {
sh 'sonar-scanner \
-Dsonar.projectKey=SME-PTRF-FrontEnd \
-Dsonar.sources=. \
-Dsonar.host.url=http://sonar.sme.prefeitura.sp.gov.br \
-Dsonar.login=2799f74a0ac29025303f4d22d73de80af6e79112'
}
}

stage('Deploy DEV') {
when {
branch 'develop'
}
steps {
sh 'echo build docker image desenvolvimento'
// Start JOB para build das imagens Docker e push SME Registry
script {
step([$class: "RundeckNotifier",
includeRundeckLogs: true,
jobId: "4eeb8a3d-d845-41c5-a7aa-8cacc6a04167",
nodeFilters: "",
//options: """
// PARAM_1=value1
// PARAM_2=value2
// PARAM_3=
// """,
rundeckInstance: "Rundeck-SME",
shouldFailTheBuild: true,
shouldWaitForRundeckJob: true,
tags: "",
tailLog: true])
}




//Start JOB de deploy Kubernetes
sh 'echo Deploy ambiente desenvolvimento'
script {
step([$class: "RundeckNotifier",
includeRundeckLogs: true,
jobId: "087505bb-e6d6-4e44-9cf4-70d3fb71623b",
nodeFilters: "",
//options: """
// PARAM_1=value1
// PARAM_2=value2
// PARAM_3=
// """,
rundeckInstance: "Rundeck-SME",
shouldFailTheBuild: true,
shouldWaitForRundeckJob: true,
tags: "",
tailLog: true])
}
}
}

stage('Deploy homologacao') {
when {
branch 'homolog'
}
steps {
timeout(time: 24, unit: "HOURS") {
// telegramSend("${JOB_NAME}...O Build ${BUILD_DISPLAY_NAME} - Requer uma aprovação para deploy !!!\n Consulte o log para detalhes -> [Job logs](${env.BUILD_URL}console)\n")
input message: 'Deseja realizar o deploy?', ok: 'SIM', submitter: 'ebufaino, marcos_nastri, calvin_rossinhole, ollyver_ottoboni, kelwy_oliveira, alessandro_fernandes, anderson_morais'
}
sh 'echo Deploying ambiente homologacao'

// Start JOB para build das imagens Docker e push SME Registry

script {
step([$class: "RundeckNotifier",
includeRundeckLogs: true,

//JOB DE BUILD
jobId: "902708ac-cd58-4959-a9b6-8769568362db",
nodeFilters: "",
//options: """
// PARAM_1=value1
// PARAM_2=value2
// PARAM_3=
// """,
rundeckInstance: "Rundeck-SME",
shouldFailTheBuild: true,
shouldWaitForRundeckJob: true,
tags: "",
tailLog: true])
}
//Start JOB deploy Kubernetes

script {
step([$class: "RundeckNotifier",
includeRundeckLogs: true,
jobId: "bb5f3c18-d40e-48bd-861f-e71b7b5ae812",
nodeFilters: "",
//options: """
// PARAM_1=value1
// PARAM_2=value2
// PARAM_3=
// """,
rundeckInstance: "Rundeck-SME",
shouldFailTheBuild: true,
shouldWaitForRundeckJob: true,
tags: "",
tailLog: true])
}
}
}

stage('Deploy PROD') {
when {
branch 'master'
}
steps {
timeout(time: 24, unit: "HOURS") {
// telegramSend("${JOB_NAME}...O Build ${BUILD_DISPLAY_NAME} - Requer uma aprovação para deploy !!!\n Consulte o log para detalhes -> [Job logs](${env.BUILD_URL}console)\n")
input message: 'Deseja realizar o deploy?', ok: 'SIM', submitter: 'ebufaino, marcos_nastri, calvin_rossinhole, ollyver_ottoboni, kelwy_oliveira, alessandro_fernandes, anderson_morais'
}
sh 'echo Build image docker Produção'
// Start JOB para build das imagens Docker e push SME Registry

script {
step([$class: "RundeckNotifier",
includeRundeckLogs: true,

//JOB DE BUILD
jobId: "4162072c-52f7-4afa-ab70-d3c88e7f114c",
nodeFilters: "",
//options: """
// PARAM_1=value1
// PARAM_2=value2
// PARAM_3=
// """,
rundeckInstance: "Rundeck-SME",
shouldFailTheBuild: true,
shouldWaitForRundeckJob: true,
tags: "",
tailLog: true])
}
//Start JOB deploy kubernetes

script {
step([$class: "RundeckNotifier",
includeRundeckLogs: true,
jobId: "eedd8718-9bea-429e-8a47-38971584069c",
nodeFilters: "",
//options: """
// PARAM_1=value1
// PARAM_2=value2
// PARAM_3=
// """,
rundeckInstance: "Rundeck-SME",
shouldFailTheBuild: true,
shouldWaitForRundeckJob: true,
tags: "",
tailLog: true])
}
}
}
}

post {
always {
echo 'One way or another, I have finished'
}
success {
telegramSend("${JOB_NAME}...O Build ${BUILD_DISPLAY_NAME} - Esta ok !!!\n Consulte o log para detalhes -> [Job logs](${env.BUILD_URL}console)\n\n Uma nova versão da aplicação esta disponivel!!!")
}
unstable {
telegramSend("O Build ${BUILD_DISPLAY_NAME} <${env.BUILD_URL}> - Esta instavel ...\nConsulte o log para detalhes -> [Job logs](${env.BUILD_URL}console)")
}
failure {
telegramSend("${JOB_NAME}...O Build ${BUILD_DISPLAY_NAME} - Quebrou. \nConsulte o log para detalhes -> [Job logs](${env.BUILD_URL}console)")
}
changed {
echo 'Things were different before...'
}
aborted {
telegramSend("O Build ${BUILD_DISPLAY_NAME} - Foi abortado.\nConsulte o log para detalhes -> [Job logs](${env.BUILD_URL}console)")
}
}
}
12 changes: 12 additions & 0 deletions conf/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

server {
listen 80;
server_name SERVER_NAME;

location / {
root /usr/share/nginx/html/;
index index.html index.htm;
try_files $uri /index.html;
}

}
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3"
services:

frontend:
build: .
container_name: ptrf-frontend
# image: ptrf-frontend
env_file: .env
ports:
- 8080:80
Loading

0 comments on commit e3ec214

Please sign in to comment.