Skip to content

Commit 3ca0b7c

Browse files
authored
Merge pull request #32 from mastertech/refactor
Refactor do projeto
2 parents b221f5a + c1bd725 commit 3ca0b7c

File tree

126 files changed

+14114
-3991
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+14114
-3991
lines changed

.gitignore

100755100644
Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,5 @@
1-
# Byte-compiled / optimized / DLL files
2-
__pycache__/
3-
4-
# Distribution / packaging
5-
.Python
6-
7-
# Django stuff:
8-
*.log
9-
local_settings.py
10-
db.sqlite3
11-
12-
# Environments
13-
.env
14-
.venv
15-
env/
16-
venv/
17-
ENV/
18-
19-
# mypy
20-
.mypy_cache/
21-
22-
#Ide
23-
.vscode
1+
node_modules
242
.idea
25-
26-
Pipfile
27-
28-
.DS_Store
3+
.code
4+
build
5+
.vscode

Dockerfile

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
1-
FROM python:3.7.4-alpine3.10
1+
FROM nginx:alpine
22

3-
WORKDIR /usr/src/app
3+
WORKDIR /usr/share/nginx/html
44

5-
COPY requirements.txt ./
6-
RUN apk add --no-cache postgresql-libs && \
7-
apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev && \
8-
pip install --no-cache-dir -r requirements.txt && \
9-
apk --purge del .build-deps
10-
11-
COPY . .
12-
13-
RUN python manage.py collectstatic
5+
COPY nginx.conf /etc/nginx/conf.d/default.conf
146

15-
RUN apk add --no-cache bash && \
16-
apk add nginx && \
17-
apk add supervisor && \
18-
cp -r shared/staticfiles/* /var/lib/nginx/html
7+
COPY build/ .
198

20-
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
21-
COPY nginx.conf /etc/nginx/conf.d/default.conf
9+
WORKDIR ~
2210

23-
RUN echo "command=gunicorn --workers 1 --bind :8080 nisia.wsgi:application" >> /etc/supervisor/conf.d/supervisord.conf
11+
COPY start.sh .
2412

25-
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
13+
CMD ["sh", "start.sh"]

Jenkinsfile

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,23 @@ pipeline {
1616
}
1717
}
1818
stages{
19-
stage("Install dependencies") {
20-
steps {
21-
sh "python3 -m venv venv"
22-
sh ". venv/bin/activate"
23-
sh "pip3 install -r requirements.txt"
24-
}
25-
}
26-
stage("Tests") {
27-
steps {
28-
script {
29-
def postgresPort = sh (
30-
script: "awk -v min=64000 -v max=65000 'BEGIN{srand(); print int(min+rand()*(max-min+1))}'",
31-
returnStdout: true
32-
).trim()
33-
docker.image("postgres:latest").withRun(
34-
"-e 'POSTGRES_DB=${params.APP_NAME}' " +
35-
"-e 'POSTGRES_USER=${params.APP_NAME}' " +
36-
"-e 'POSTGRES_PASSWORD=${params.APP_NAME}' " +
37-
"-p $postgresPort:5432") { c ->
38-
sh "while ! pg_isready -h localhost -p $postgresPort; do sleep 1; done"
39-
withEnv(["NISIA_DB_NAME=${params.APP_NAME}",
40-
"NISIA_DB_USER=${params.APP_NAME}",
41-
"NISIA_DB_PASS=${params.APP_NAME}",
42-
"NISIA_DB_HOST=localhost",
43-
"NISIA_DB_PORT=${postgresPort}",
44-
"NISIA_DEBUG=True"]) {
45-
sh "python3 manage.py migrate"
46-
sh "python3 manage.py test"
47-
}
48-
}
49-
}
50-
}
51-
}
52-
stage("Build and Deploy Staging") {
19+
stage("Build and deploy staging") {
5320
when { branch 'master' }
5421
stages {
22+
stage("Install dependencies") {
23+
steps {
24+
script {
25+
sh "npm install"
26+
}
27+
}
28+
}
29+
stage("Package") {
30+
steps {
31+
script {
32+
sh "npm run build"
33+
}
34+
}
35+
}
5536
stage("Build and push image") {
5637
steps {
5738
script {
@@ -87,15 +68,15 @@ pipeline {
8768
}
8869
}
8970
}
90-
stage("Deploy Staging") {
71+
stage("Deploy staging") {
9172
steps {
9273
sh "kubectl apply -f deploy/staging.yaml"
9374
sh "kubectl rollout restart deploy ${params.APP_SERVICE_NAME} -n staging"
9475
}
9576
}
9677
}
9778
}
98-
stage("Deploy Production") {
79+
stage("Deploy production") {
9980
when { buildingTag() }
10081
steps {
10182
sh "kubectl apply -f deploy/production.yaml"

gulpfile.js

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
const gulp = require("gulp");
2+
const clean = require("del");
3+
const htmlMin = require("gulp-htmlmin");
4+
const cssMin = require("gulp-csso");
5+
const jsUglify = require("gulp-uglify");
6+
const autoPrefixer = require("gulp-autoprefixer");
7+
const browserSync = require("browser-sync").create();
8+
const sass = require("gulp-sass")(require("sass"));
9+
const image = require('gulp-image');
10+
const sourcemaps = require("gulp-sourcemaps");
11+
const webpack = require("webpack-stream");
12+
const babel = require("gulp-babel");
13+
const replace = require("gulp-replace");
14+
15+
gulp.task("clean", () => clean("./build"));
16+
17+
gulp.task("html", () =>
18+
gulp
19+
.src("./src/*.html")
20+
.pipe(
21+
htmlMin({
22+
collapseWhitespace: true,
23+
removeComments: true,
24+
})
25+
)
26+
.pipe(gulp.dest("./build"))
27+
);
28+
29+
gulp.task("scss", () =>
30+
gulp
31+
.src("./src/scss/*.scss")
32+
.pipe(sourcemaps.init())
33+
.pipe(sass().on("error", sass.logError))
34+
.pipe(autoPrefixer())
35+
.pipe(cssMin())
36+
.pipe(sourcemaps.write())
37+
.pipe(gulp.dest("./build/css"))
38+
);
39+
40+
gulp.task("javascript", () =>
41+
gulp
42+
.src("./src/js/main.js")
43+
.pipe(webpack({
44+
mode: "development",
45+
devtool: "source-map",
46+
output: {
47+
filename: "scripts.min.js",
48+
},
49+
})
50+
)
51+
.pipe(replace(
52+
"LEADCOLLECTOR_URL",
53+
"http://leadcollector.homolog.mastertech.com.br"
54+
)
55+
)
56+
.pipe(replace(
57+
"LEADCOLLECTOR_TOKEN",
58+
"2bb4f7d7999ba46536b9caeafbaeafb38f464903"
59+
)
60+
)
61+
.pipe(gulp.dest("./build/js"))
62+
);
63+
64+
gulp.task("javascript:production", () =>
65+
gulp
66+
.src("./src/js/main.js")
67+
.pipe(
68+
webpack({
69+
mode: "production",
70+
output: {
71+
filename: "scripts.min.js",
72+
},
73+
})
74+
)
75+
.pipe(
76+
babel({
77+
presets: ["@babel/env"],
78+
})
79+
)
80+
.pipe(jsUglify())
81+
.pipe(gulp.dest("./build/js"))
82+
);
83+
84+
gulp.task("assets", () =>
85+
gulp.src(["./src/assets/**/*"]).pipe(gulp.dest("./build/assets/"))
86+
);
87+
88+
gulp.task("assets:optimize", () =>
89+
gulp
90+
.src(["./src/assets/**/*"])
91+
.pipe(
92+
image({
93+
pngquant: true,
94+
optipng: true,
95+
zopflipng: true,
96+
jpegRecompress: true,
97+
mozjpeg: true,
98+
gifsicle: true,
99+
svgo: true,
100+
concurrent: 10,
101+
})
102+
)
103+
.pipe(gulp.dest("./build/assets/"))
104+
);
105+
106+
gulp.task(
107+
"build",
108+
gulp.series("clean", gulp.parallel("html", "assets", "scss", "javascript"))
109+
);
110+
111+
gulp.task(
112+
"build:production",
113+
gulp.series(
114+
"clean",
115+
gulp.parallel("html", "assets:optimize", "scss", "javascript:production")
116+
)
117+
);
118+
119+
gulp.task("server", () => {
120+
browserSync.init({
121+
server: "./build/",
122+
});
123+
gulp.watch("./src/**/*", gulp.series("build"));
124+
gulp.watch("./src/**/*", (finish) => {
125+
browserSync.reload();
126+
finish();
127+
});
128+
});
129+
130+
gulp.task("default", gulp.series("build", "server"));

manage.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

nisia/.DS_Store

-6 KB
Binary file not shown.

nisia/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)