Commit 3136db93 authored by dangdoan's avatar dangdoan

Merge branch 'test-meger' into 'develop'

Test meger

See merge request !12
parents b755de72 26aef736
NODE_ENV=development
\ No newline at end of file
......@@ -11,16 +11,15 @@ build:
- export CI_REGISTRY_PW=$CI_REGISTRY_PW
- export CI_REGISTRY_USER=$CI_REGISTRY_USER
- echo "To release new docker image for development and staging, we use tag 'dev' only !!!"
- tag=$(echo $CI_COMMIT_MESSAGE | sed -r 's/.*(\[tag\])//')
- export tag=$tag
- export tag=dev
- cicd_path=$(pwd)/cicd
script:
- bash $cicd_path/build.sh
only:
- release
tags:
- chinguyen_nodejs_managestudent
- runner-builder
deploy:
stage: deploy
before_script:
......@@ -28,7 +27,6 @@ deploy:
- cicd_path=$(pwd)/cicd
- export CI_REGISTRY_PW=$CI_REGISTRY_PW
- export CI_REGISTRY_USER=$CI_REGISTRY_USER
- tag=$(echo $CI_COMMIT_MESSAGE | sed -r 's/.*(\[tag\])//')
- |
if [ ! -d $mount_data_folder ]; then
sudo mkdir $mount_data_folder
......@@ -40,9 +38,9 @@ deploy:
sudo chown -R gitlab-runner.gitlab-runner $mount_data_folder/$project_name
fi
script:
- export tag=$tag
- export tag=dev
- bash $cicd_path/deploy.sh
only:
- release
tags:
- chinguyen_nodejs_managestudent
- asset-ci-cd
\ No newline at end of file
### STAGE 1: RUN ###
FROM node
RUN chmod 1777 /tmp
RUN mkdir /data
RUN apt-get update -y
RUN apt-get install -y libgdiplus
RUN apt-get install -y libreoffice
RUN apt-get install -y libfontconfig
RUN apt-get install -y phantomjs
ENV OPENSSL_CONF=/opt/openssl.cnf
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN cp -r ./swagger/supports/* ./node_modules
ENTRYPOINT ["node", "swagger.js"]
\ No newline at end of file
#! /bin/bash
function cp_ad()
{
sourceCheck=$1;
desPath=$2;
defaultSourceCheck=$3;
if [[ -z $sourceCheck ]] || [[ -z $desPath ]]
then
echo "Source path or destination path is empty";
exit 1;
fi
for item in "$sourceCheck"/*
do
if [[ -d $item ]]
then
relativePath=$(echo ${item/$defaultSourceCheck/});
pathRm=$desPath$relativePath;
echo $pathRm;
rm -rf $pathRm;
cp_ad $item $desPath $defaultSourceCheck;
fi
relativePath=$(echo ${item/$defaultSourceCheck/});
pathRm=$desPath$relativePath;
echo $pathRm
rm -rf $pathRm
done
}
cp_ad $1 $2 $3;
cp -rf $1/* $2;
#! /bin/bash
function download_angular()
{
sourceCheck=$1;
if [[ -z $sourceCheck ]]
then
echo "Source path is empty";
exit 1;
fi
for item in "$sourceCheck"/*
do
if [[ -d $item ]]
then
download_angular $item;
fi
sed -i '/return this.httpClient.request<Blob>/!{p;d;};n;n;n;a\\t\tresponseType: \x27blob\x27 as \x27json\x27,' $item
echo $item;
done
}
download_angular $1;
#!/bin/bash
echo "Waiting for the application goes online..."
sleep 15
swaggerUrl="http://localhost:$port_mapping/swagger/v1/swagger.json"
api=$(curl $swaggerUrl)
status=$?
if test $status -ne 0
then
exit 1
fi
api=$(jq 'del(.components.securitySchemes)' <<<$api)
api=$(jq 'del(.security)' <<<$api)
echo $api > apiFinal.json
request='{"spec":{},"type":"CLIENT","lang":"typescript-angular"}'
request=$(jq --argfile apiFinal apiFinal.json '.spec = $apiFinal' <<<$request)
echo $request > ts.json
rm -rf client
java -jar CICD/swagger-codegen-cli.jar generate -i apiFinal.json -l typescript-angular -o client --additional-properties modelPropertyNaming=original
rm -rf ts.json;
rm -rf production_file;
rm -rf apiFinal.json;
temp_path=$(pwd);
mkdir production_file;
cp -r client/*.ts production_file/; cp -r client/api production_file/; cp -r client/model production_file/; rm -rf client; mv production_file client
bash CICD/swagger_download client
git clone --single-branch --branch $fe_model_branch "http://${GIT_USER}:${GIT_USER_PW}@$fe_git_address.git"
cd $fe_git_project_name
git pull origin $fe_model_branch;
bash $temp_path/CICD/cp_ad $temp_path/client $temp_path/$fe_git_project_name/src/app $temp_path/client
git add --all; git commit -m "Update model auto" --allow-empty; git push "http://${GIT_USER}:${GIT_USER_PW}@$fe_git_address.git" HEAD:$fe_model_branch
\ No newline at end of file
#!/bin/bash
echo $image_name:$tag
sudo docker build -t $image_name:$tag -f Dockerfile .
sudo docker logout registry.gitlab.com
echo "$CI_REGISTRY_PW" | sudo docker login registry.gitlab.com -u "$CI_REGISTRY_USER" --password-stdin
sudo docker push $image_name:$tag
\ No newline at end of file
#!/bin/bash
jq -r 'keys[] as $k | "\($k)=\(.[$k])"' $environment_json_path > .env
sed -i 's|PROJECT-NAME|'$project_name'|' docker-compose.yaml
sed -i 's|ENVIRONMENT-NAME|'$environment_name'|' docker-compose.yaml
sed -i 's|IMAGE-NAME|'$image_name'|' docker-compose.yaml
sed -i 's|IMAGE-TAG|'$tag'|' docker-compose.yaml
sed -i 's|P-MAPPING|'$port_mapping'|' docker-compose.yaml
sed -i 's|MOUNT-DATA-FOLDER|'$mount_data_folder'|' docker-compose.yaml
echo "$CI_REGISTRY_PW" | sudo docker login registry.gitlab.com -u "$CI_REGISTRY_USER" --password-stdin
sudo docker-compose down
sudo docker-compose pull
sudo docker-compose --env-file .env up -d
\ No newline at end of file
#!/bin/bash
if [ "$check" == "[tag]" ]; then
sed -i 's|#||g' Dockerfile
sudo docker build -t $image_name:$tag -f Dockerfile .
sudo docker logout registry.gitlab.com
echo "$CI_REGISTRY_PW" | sudo docker login registry.gitlab.com -u "$CI_REGISTRY_USER" --password-stdin
sudo docker push $image_name:$tag
sudo docker rmi $image_name:$tag
fi
version: '3.5'
services:
app:
container_name: ENVIRONMENT-NAME-PROJECT-NAME
image: IMAGE-NAME:IMAGE-TAG
volumes:
- MOUNT-DATA-FOLDER/PROJECT-NAME:/media
ports:
- P-MAPPING:3000
restart: unless-stopped
pull_policy: always
\ No newline at end of file
#!/bin/bash
export project_name="chinguyen_nodejs_managestudents"
export image_name="registry.gitlab.com/meusolutions/chinguyen_nodejs_managestudents"
export port_mapping="5000"
export environment_name="staging"
export mount_data_folder="/var/data"
-----BEGIN OPENSSH PRIVATE KEY-----
b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COSZvzqWG+4Yb6JGMkQmLRwFDLVeHM4GfoNfWqUsUjNvDtFRD4y0xwINo
vycF560Do/xOygOtW00v7SOQSOd55uQkEAAADBANg+3576hlpkIqWlsJRxw/l+pAXLsYOt
R1fSJ8OV2bJZnHQ78SCQYukdO/ehYpEDMahk9CUyfVwBIAudKnychxCF5xX1Cql2EOa1Zn
7hDkHD7JBow9UVAASN9ymlauKTaSpgg+M8Fpodi+QYmYh4jKG8Wh96AhGxgXKc/5Gds7mH
Il0Sqjsqbx8bRl6e+AOrWgSexYeDLOLOWhKHW9VppIFww3/o8Wt6CYhc5Kx4YqVaxuOBIQ
ryVVjQNdDuF365vwAAABVEaWV1UUBERVNLVE9QLTEzOTZLT0QBAgME
-----END OPENSSH PRIVATE KEY-----
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello World');
})
var server = app.listen(8081, function () {
var host = server.address().address
var port = server.address().port
console.log("Ung dung Node.js dang lang nghe tai dia chi: http://%s:%s", host, port)
})
\ No newline at end of file
......@@ -34,8 +34,8 @@
"dependencies": {
"body-parser": "1.19.0",
"cors": "2.8.5",
"cross-env": "^7.0.0",
"express": "4.17.1",
"cross-env": "7.0.0",
"express": "^4.17.1",
"express-boom": "3.0.0",
"express-validator": "^6.9.2",
"kafka-node": "^5.0.0",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment