Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
R
red-ci-cd
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
red-group-test
red-ci-cd
Commits
3407d480
Commit
3407d480
authored
Apr 10, 2020
by
John Red Medrano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new method for CI/CD
parent
a8ecdca0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
422 additions
and
336 deletions
+422
-336
.gitlab-ci.yml
.gitlab-ci.yml
+6
-331
Dockerfile.template
Dockerfile.template
+7
-1
docker-compose.yml.template
docker-compose.yml.template
+28
-4
test.env
test.env
+4
-0
working_gitlab.yml
working_gitlab.yml
+377
-0
No files found.
.gitlab-ci.yml
View file @
3407d480
stages
:
-
initial_repo
-
clean_initial_repo
-
rebuild_dev
-
clean_rebuild_dev
-
build_sit
-
clean_build_sit
-
rebuild_sit
-
clean_rebuild_sit
-
build_staging
-
clean_build_staging
-
rebuild_staging
-
clean_rebuild_staging
-
building_version_release
-
clean_building_version_release
initial_repo
:
stage
:
initial_repo
...
...
@@ -31,13 +18,12 @@ initial_repo:
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "sudo mkdir $root_path/dev"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev && sudo git clone http://tir:Qwerty1234@54.169.104.100:27015/red/red-ci-cd.git -b $dev"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && $dockercompose"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && $dockerfile"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && $testenv"
-
ssh -tt centos@13.251.192.208 "sudo cp $root_path/dev/$repo_folder/docker-compose.yml.template $root_path/dev/$repo_folder/docker-compose.yml"
-
ssh -tt centos@13.251.192.208 "sudo cp $root_path/dev/$repo_folder/Dockerfile.template $root_path/dev/$repo_folder/Dockerfile"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && $TIRdevINI"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder &&
ls
"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && docker-compose -f docker-compose.yml -p $var_dev_container down"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && docker-compose -f docker-compose.yml -p $var_dev_container up -d --build"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder &&
docker-compose build --build-arg test=hello xxx
"
#
- ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && docker-compose -f docker-compose.yml -p $var_dev_container down"
#
- ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && docker-compose -f docker-compose.yml -p $var_dev_container up -d --build"
-
echo "Initial dev environment for red test ci cd"
-
echo "Initial dev environment for red test ci cd"
...
...
@@ -63,315 +49,4 @@ clean_initial_repo:
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && docker-compose -f docker-compose.yml -p $var_dev_container down"
-
ssh -tt centos@13.251.192.208 "sudo rm -rf $root_path/dev"
rebuild_dev
:
stage
:
rebuild_dev
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/deploy-dev/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$dev'
when
:
always
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/version_release/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$dev'
when
:
always
# only:
# refs:
# - red-develop
# variables:
# - $CI_COMMIT_MESSAGE !~ /initial/
before_script
:
-
echo "rebuilding dev environment for red test ci cd"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
echo "pulling updates on $dev"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && sudo git pull origin $dev"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && docker-compose -f docker-compose.yml -p $var_dev_container down"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && docker-compose -f docker-compose.yml -p $var_dev_container up -d --build"
-
echo "the $dev branch is successfully updated"
variables
:
GIT_STRATEGY
:
clone
GIT_DEPTH
:
"
1"
script
:
-
echo "Building dev environment DONE"
-
echo "Closed"
clean_rebuild_dev
:
stage
:
clean_rebuild_dev
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/deploy-dev/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$dev'
when
:
on_failure
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/version_release/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$dev'
when
:
on_failure
script
:
-
echo "this is a clean up for clean_rebuild_dev"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && docker-compose -f docker-compose.yml -p $var_dev_container down"
-
ssh -tt centos@13.251.192.208 "sudo rm -rf $root_path/dev"
build_sit
:
stage
:
build_sit
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
=~
/deploy-sit/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$sit'
when
:
always
before_script
:
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "sudo mkdir $root_path/sit"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit && sudo git clone http://tir:Qwerty1234@54.169.104.100:27015/red/red-ci-cd.git -b $sit"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && $dockercompose_sit"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && $dockerfile_sit"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && $testenv"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && $TIRdevINI"
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/sit/$repo_folder/docker-compose.yml -p $var_sit_container down"
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/sit/$repo_folder/docker-compose.yml -p $var_sit_container up -d --build"
-
echo "building sit environment for red test ci cd"
variables
:
GIT_STRATEGY
:
clone
GIT_DEPTH
:
"
1"
script
:
-
echo "Building SIT Environment DONE"
-
echo "CLOSED"
clean_build_sit
:
stage
:
clean_build_sit
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
=~
/deploy-sit/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$sit'
when
:
always
script
:
-
echo "this is a clean up for clean_build_sit"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/sit/$repo_folder/docker-compose.yml -p $var_sit_container down"
-
ssh -tt centos@13.251.192.208 "sudo rm -rf $root_path/sit"
rebuild_sit
:
stage
:
rebuild_sit
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/deploy-sit/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$sit'
when
:
always
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/version_release/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$sit'
when
:
always
before_script
:
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
echo "pulling updates on $sit"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && sudo git pull origin $sit"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && docker-compose -f docker-compose.yml -p $var_sit_container down"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && docker-compose -f docker-compose.yml -p $var_sit_container up -d --build"
-
echo "the $dev branch is successfully updated"
variables
:
GIT_STRATEGY
:
clone
GIT_DEPTH
:
"
1"
script
:
-
echo "Building SIT Environment DONE"
-
echo "CLOSED"
clean_rebuild_sit
:
stage
:
clean_rebuild_sit
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/deploy-sit/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$sit'
when
:
on_failure
script
:
-
echo "this is a clean up for clean_build_sit"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && docker-compose -f docker-compose.yml -p $var_sit_container down"
-
ssh -tt centos@13.251.192.208 "sudo rm -rf $root_path/sit"
build_staging
:
stage
:
build_staging
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
=~
/deploy-staging/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$staging'
when
:
always
before_script
:
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "sudo mkdir $root_path/staging"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging && sudo git clone http://tir:Qwerty1234@54.169.104.100:27015/red/red-ci-cd.git -b $staging"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && $dockercompose_staging"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && $dockerfile_staging"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && $testenv"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && $TIRdevINI"
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/staging/$repo_folder/docker-compose.yml -p $var_staging_container down"
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/staging/$repo_folder/docker-compose.yml -p $var_staging_container up -d --build"
-
echo "building staging environment for red test ci cd"
variables
:
GIT_STRATEGY
:
clone
GIT_DEPTH
:
"
1"
script
:
-
echo "Building Staging Environment DONE"
-
echo "CLOSED"
clean_build_staging
:
stage
:
clean_build_staging
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
=~
/deploy-staging/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$staging'
when
:
on_failure
script
:
-
echo "this is a clean up for clean_build_staging"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/staging/$repo_folder/docker-compose.yml -p $var_staging_container down"
-
ssh -tt centos@13.251.192.208 "sudo rm -rf $root_path/staging"
rebuild_staging
:
stage
:
rebuild_staging
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/deploy-staging/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$staging'
when
:
always
before_script
:
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
echo "pulling updates on $staging"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && sudo git pull origin $staging"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && docker-compose -f docker-compose.yml -p $var_staging_container down"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && docker-compose -f docker-compose.yml -p $var_staging_container up -d --build"
-
echo "the $dev branch is successfully updated"
variables
:
GIT_STRATEGY
:
clone
GIT_DEPTH
:
"
1"
script
:
-
echo "ReBuilding Staging Environment DONE"
-
echo "CLOSED"
clean_rebuild_staging
:
stage
:
clean_rebuild_staging
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/deploy-staging/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$staging'
when
:
on_failure
script
:
-
echo "this is a clean up for clean_build_staging"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && docker-compose -f docker-compose.yml -p $var_staging_container down"
-
ssh -tt centos@13.251.192.208 "sudo rm -rf $root_path/staging"
building_version_release
:
stage
:
building_version_release
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
=~
/version_release/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$staging'
when
:
always
before_script
:
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "sudo mkdir $root_path/$version_folder"
-
ssh -tt centos@13.251.192.208 "cd $root_path/$version_folder && sudo git clone http://tir:Qwerty1234@54.169.104.100:27015/red/red-ci-cd.git -b $staging"
-
ssh -tt centos@13.251.192.208 "cd $root_path/$version_folder/$repo_folder && $docker_compose_version"
-
ssh -tt centos@13.251.192.208 "cd $root_path/$version_folder/$repo_folder && $dockerfile_version"
-
ssh -tt centos@13.251.192.208 "cd $root_path/$version_folder/$repo_folder && $testenv"
-
ssh -tt centos@13.251.192.208 "cd $root_path/$version_folder/$repo_folder && $TIRdevINI"
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/$version_folder/$repo_folder/docker-compose.yml -p $var_staging_container down"
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/$version_folder/$repo_folder/docker-compose.yml -p $var_staging_container up -d --build"
-
echo "building Release environment for red test ci cd"
variables
:
GIT_STRATEGY
:
clone
GIT_DEPTH
:
"
1"
script
:
-
echo "Building Release Environment DONE"
-
echo "CLOSED"
clean_building_version_release
:
stage
:
clean_building_version_release
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
=~
/version_release/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$staging'
when
:
on_failure
script
:
-
echo "this is a clean up for clean_building_version_release"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "sudo mkdir /var/www/gitlab_variable_red/sit"
-
ssh -tt centos@13.251.192.208 "cd /var/www/gitlab_variable_red/sit && sudo git clone http://tir:Qwerty1234@54.169.104.100:27015/red/red-ci-cd.git -b $sit"
-
ssh -tt centos@13.251.192.208 "cd /var/www/gitlab_variable_red/sit/red-ci-cd && $dockercompose_sit"
-
ssh -tt centos@13.251.192.208 "cd /var/www/gitlab_variable_red/sit/red-ci-cd && $dockerfile_sit"
-
ssh -tt centos@13.251.192.208 "cd /var/www/gitlab_variable_red/sit/red-ci-cd && $testenv"
-
ssh -tt centos@13.251.192.208 "cd /var/www/gitlab_variable_red/sit/red-ci-cd && $TIRdevINI"
-
ssh -tt centos@13.251.192.208 "cd /var/www/gitlab_variable_red/sit/red-ci-cd && sudo docker-compose up --build -d"
-
echo "building sit environment for red test ci cd"
-
echo "Triggered"
variables
:
GIT_STRATEGY
:
clone
GIT_DEPTH
:
"
1"
script
:
-
echo "Building SIT Environment DONE"
-
echo "CLOSED"
\ No newline at end of file
-
ssh -tt centos@13.251.192.208 "sudo rm -rf $root_path/dev"
\ No newline at end of file
Dockerfile.template
View file @
3407d480
FROM python:3.6
ARG test
# ENV xxx ${test}
ENV port $port
ENV wow2 "from dockerfile"
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ADD . /code
COPY . /code
WORKDIR /code
# RUN echo "Build number: $IMAGE_NAME"
RUN pip install -r requirements/local.txt
EXPOSE 7020
EXPOSE ${export}
# EXPOSE "${export}"
RUN python manage.py migrate
docker-compose.yml.template
View file @
3407d480
version: '3'
services:
web:
image: dev-rmsv2:latest
build: .
xxx:
# environment:
# - $IMAGE_NAME
# - $wow
env_file:
- test.env
image: red-test
build:
context: .
dockerfile: Dockerfile
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "7020:8000"
- "${export}:8000"
container_name: dev_rmsv2_api_container
restart: always
ddd:
# environment:
# - $IMAGE_NAME
# - $wow
env_file:
- test.env
image: red-test
build:
context: .
dockerfile: Dockerfile
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "${export}:8000"
container_name: dev_rmsv2_api_container
restart: always
test.env
0 → 100644
View file @
3407d480
MY_SECRET_KEY=SOME_SECRET
IMAGE_NAME=wow_red
wow=from_env
export=8080
\ No newline at end of file
working_gitlab.yml
0 → 100644
View file @
3407d480
stages
:
-
initial_repo
-
clean_initial_repo
-
rebuild_dev
-
clean_rebuild_dev
-
build_sit
-
clean_build_sit
-
rebuild_sit
-
clean_rebuild_sit
-
build_staging
-
clean_build_staging
-
rebuild_staging
-
clean_rebuild_staging
-
building_version_release
-
clean_building_version_release
initial_repo
:
stage
:
initial_repo
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
=~
/deploy-dev/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$dev'
when
:
always
before_script
:
-
echo "Building dev environment for red test ci cd"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "sudo mkdir $root_path/dev"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev && sudo git clone http://tir:Qwerty1234@54.169.104.100:27015/red/red-ci-cd.git -b $dev"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && $dockercompose"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && $dockerfile"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && $testenv"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && $TIRdevINI"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && ls"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && docker-compose -f docker-compose.yml -p $var_dev_container down"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && docker-compose -f docker-compose.yml -p $var_dev_container up -d --build"
-
echo "Initial dev environment for red test ci cd"
-
echo "Initial dev environment for red test ci cd"
variables
:
GIT_STRATEGY
:
clone
GIT_DEPTH
:
"
1"
script
:
-
echo "Successfully build dev environment"
-
echo "Closed"
clean_initial_repo
:
stage
:
clean_initial_repo
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
=~
/deploy-dev/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$dev'
when
:
on_failure
script
:
-
echo "this is a clean up for clean_initial_repo"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && docker-compose -f docker-compose.yml -p $var_dev_container down"
-
ssh -tt centos@13.251.192.208 "sudo rm -rf $root_path/dev"
rebuild_dev
:
stage
:
rebuild_dev
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/deploy-dev/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$dev'
when
:
always
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/version_release/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$dev'
when
:
always
# only:
# refs:
# - red-develop
# variables:
# - $CI_COMMIT_MESSAGE !~ /initial/
before_script
:
-
echo "rebuilding dev environment for red test ci cd"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
echo "pulling updates on $dev"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && sudo git pull origin $dev"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && docker-compose -f docker-compose.yml -p $var_dev_container down"
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && docker-compose -f docker-compose.yml -p $var_dev_container up -d --build"
-
echo "the $dev branch is successfully updated"
variables
:
GIT_STRATEGY
:
clone
GIT_DEPTH
:
"
1"
script
:
-
echo "Building dev environment DONE"
-
echo "Closed"
clean_rebuild_dev
:
stage
:
clean_rebuild_dev
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/deploy-dev/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$dev'
when
:
on_failure
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/version_release/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$dev'
when
:
on_failure
script
:
-
echo "this is a clean up for clean_rebuild_dev"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "cd $root_path/dev/$repo_folder && docker-compose -f docker-compose.yml -p $var_dev_container down"
-
ssh -tt centos@13.251.192.208 "sudo rm -rf $root_path/dev"
build_sit
:
stage
:
build_sit
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
=~
/deploy-sit/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$sit'
when
:
always
before_script
:
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "sudo mkdir $root_path/sit"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit && sudo git clone http://tir:Qwerty1234@54.169.104.100:27015/red/red-ci-cd.git -b $sit"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && $dockercompose_sit"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && $dockerfile_sit"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && $testenv"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && $TIRdevINI"
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/sit/$repo_folder/docker-compose.yml -p $var_sit_container down"
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/sit/$repo_folder/docker-compose.yml -p $var_sit_container up -d --build"
-
echo "building sit environment for red test ci cd"
variables
:
GIT_STRATEGY
:
clone
GIT_DEPTH
:
"
1"
script
:
-
echo "Building SIT Environment DONE"
-
echo "CLOSED"
clean_build_sit
:
stage
:
clean_build_sit
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
=~
/deploy-sit/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$sit'
when
:
always
script
:
-
echo "this is a clean up for clean_build_sit"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/sit/$repo_folder/docker-compose.yml -p $var_sit_container down"
-
ssh -tt centos@13.251.192.208 "sudo rm -rf $root_path/sit"
rebuild_sit
:
stage
:
rebuild_sit
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/deploy-sit/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$sit'
when
:
always
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/version_release/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$sit'
when
:
always
before_script
:
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
echo "pulling updates on $sit"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && sudo git pull origin $sit"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && docker-compose -f docker-compose.yml -p $var_sit_container down"
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && docker-compose -f docker-compose.yml -p $var_sit_container up -d --build"
-
echo "the $dev branch is successfully updated"
variables
:
GIT_STRATEGY
:
clone
GIT_DEPTH
:
"
1"
script
:
-
echo "Building SIT Environment DONE"
-
echo "CLOSED"
clean_rebuild_sit
:
stage
:
clean_rebuild_sit
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/deploy-sit/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$sit'
when
:
on_failure
script
:
-
echo "this is a clean up for clean_build_sit"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "cd $root_path/sit/$repo_folder && docker-compose -f docker-compose.yml -p $var_sit_container down"
-
ssh -tt centos@13.251.192.208 "sudo rm -rf $root_path/sit"
build_staging
:
stage
:
build_staging
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
=~
/deploy-staging/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$staging'
when
:
always
before_script
:
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "sudo mkdir $root_path/staging"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging && sudo git clone http://tir:Qwerty1234@54.169.104.100:27015/red/red-ci-cd.git -b $staging"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && $dockercompose_staging"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && $dockerfile_staging"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && $testenv"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && $TIRdevINI"
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/staging/$repo_folder/docker-compose.yml -p $var_staging_container down"
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/staging/$repo_folder/docker-compose.yml -p $var_staging_container up -d --build"
-
echo "building staging environment for red test ci cd"
variables
:
GIT_STRATEGY
:
clone
GIT_DEPTH
:
"
1"
script
:
-
echo "Building Staging Environment DONE"
-
echo "CLOSED"
clean_build_staging
:
stage
:
clean_build_staging
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
=~
/deploy-staging/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$staging'
when
:
on_failure
script
:
-
echo "this is a clean up for clean_build_staging"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/staging/$repo_folder/docker-compose.yml -p $var_staging_container down"
-
ssh -tt centos@13.251.192.208 "sudo rm -rf $root_path/staging"
rebuild_staging
:
stage
:
rebuild_staging
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/deploy-staging/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$staging'
when
:
always
before_script
:
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
echo "pulling updates on $staging"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && sudo git pull origin $staging"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && docker-compose -f docker-compose.yml -p $var_staging_container down"
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && docker-compose -f docker-compose.yml -p $var_staging_container up -d --build"
-
echo "the $dev branch is successfully updated"
variables
:
GIT_STRATEGY
:
clone
GIT_DEPTH
:
"
1"
script
:
-
echo "ReBuilding Staging Environment DONE"
-
echo "CLOSED"
clean_rebuild_staging
:
stage
:
clean_rebuild_staging
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
!~
/deploy-staging/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$staging'
when
:
on_failure
script
:
-
echo "this is a clean up for clean_build_staging"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "cd $root_path/staging/$repo_folder && docker-compose -f docker-compose.yml -p $var_staging_container down"
-
ssh -tt centos@13.251.192.208 "sudo rm -rf $root_path/staging"
building_version_release
:
stage
:
building_version_release
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
=~
/version_release/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$staging'
when
:
always
before_script
:
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "sudo mkdir $root_path/$version_folder"
-
ssh -tt centos@13.251.192.208 "cd $root_path/$version_folder && sudo git clone http://tir:Qwerty1234@54.169.104.100:27015/red/red-ci-cd.git -b $staging"
-
ssh -tt centos@13.251.192.208 "cd $root_path/$version_folder/$repo_folder && $docker_compose_version"
-
ssh -tt centos@13.251.192.208 "cd $root_path/$version_folder/$repo_folder && $dockerfile_version"
-
ssh -tt centos@13.251.192.208 "cd $root_path/$version_folder/$repo_folder && $testenv"
-
ssh -tt centos@13.251.192.208 "cd $root_path/$version_folder/$repo_folder && $TIRdevINI"
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/$version_folder/$repo_folder/docker-compose.yml -p $var_staging_container down"
-
ssh -tt centos@13.251.192.208 "docker-compose -f $root_path/$version_folder/$repo_folder/docker-compose.yml -p $var_staging_container up -d --build"
-
echo "building Release environment for red test ci cd"
variables
:
GIT_STRATEGY
:
clone
GIT_DEPTH
:
"
1"
script
:
-
echo "Building Release Environment DONE"
-
echo "CLOSED"
clean_building_version_release
:
stage
:
clean_building_version_release
image
:
ubuntu
rules
:
-
if
:
'
$CI_COMMIT_MESSAGE
=~
/version_release/
&&
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
==
$staging'
when
:
on_failure
script
:
-
echo "this is a clean up for clean_building_version_release"
-
'
which
ssh-agent
||
(
apt-get
update
-y
&&
apt-get
install
openssh-client
-y)'
-
eval $(ssh-agent -s)
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
echo "$CENTOS_SERVER" | ssh-add - > ~/.ssh/id_rsa
-
'
[[
-f
/.dockerenv
]]
&&
echo
-e
"Host
*\n\tStrictHostKeyChecking
no\n\n"
>
~/.ssh/config'
-
ssh -tt centos@13.251.192.208 "sudo mkdir /var/www/gitlab_variable_red/sit"
-
ssh -tt centos@13.251.192.208 "cd /var/www/gitlab_variable_red/sit && sudo git clone http://tir:Qwerty1234@54.169.104.100:27015/red/red-ci-cd.git -b $sit"
-
ssh -tt centos@13.251.192.208 "cd /var/www/gitlab_variable_red/sit/red-ci-cd && $dockercompose_sit"
-
ssh -tt centos@13.251.192.208 "cd /var/www/gitlab_variable_red/sit/red-ci-cd && $dockerfile_sit"
-
ssh -tt centos@13.251.192.208 "cd /var/www/gitlab_variable_red/sit/red-ci-cd && $testenv"
-
ssh -tt centos@13.251.192.208 "cd /var/www/gitlab_variable_red/sit/red-ci-cd && $TIRdevINI"
-
ssh -tt centos@13.251.192.208 "cd /var/www/gitlab_variable_red/sit/red-ci-cd && sudo docker-compose up --build -d"
-
echo "building sit environment for red test ci cd"
-
echo "Triggered"
variables
:
GIT_STRATEGY
:
clone
GIT_DEPTH
:
"
1"
script
:
-
echo "Building SIT Environment DONE"
-
echo "CLOSED"
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment