Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dockerfiles
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Picasoft
Technique
Dockerfiles
Commits
6c2b25fc
Verified
Commit
6c2b25fc
authored
5 years ago
by
Quentin Duchemin
Browse files
Options
Downloads
Patches
Plain Diff
Add a manual push on production registry and automatic test script
parent
7c3dcfb6
No related branches found
Branches containing commit
No related tags found
1 merge request
!45
Add a testing procedure
Pipeline
#52559
failed
5 years ago
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitlab-ci.yml
+21
-0
21 additions, 0 deletions
.gitlab-ci.yml
docker_test.sh
+62
-0
62 additions, 0 deletions
docker_test.sh
get-modified-image.sh
+4
-2
4 additions, 2 deletions
get-modified-image.sh
with
87 additions
and
2 deletions
.gitlab-ci.yml
+
21
−
0
View file @
6c2b25fc
...
...
@@ -141,8 +141,27 @@ docker-bench-security:
-
master
-
dev-ci
push-test
:
stage
:
push
<<
:
*pull-modified-image
script
:
-
docker tag $REGISTRY_TEST/ci-builds/$MODIFIED_IMAGE:$CI_COMMIT_SHA $MODIFIED_IMAGE_FULL_TEST
-
echo $REGISTRY_PASSWORD | docker login $REGISTRY -u $REGISTRY_USERNAME --password-stdin
# MODIFIED_IMAGE_FULL_TEST already should include the registry URL
-
docker push $MODIFIED_IMAGE_FULL_TEST
after_script
:
-
docker logout $REGISTRY
only
:
changes
:
-
"
**/Dockerfile"
-
"
**/docker-compose.yml"
refs
:
-
master
-
dev-ci
# Push the generated image on the production registry,
# once it passed all security tests and has been successfully built
# and run on the test virtual machine
push-prod
:
stage
:
push
<<
:
*pull-modified-image
...
...
@@ -160,3 +179,5 @@ push-prod:
refs
:
-
master
-
dev-ci
when
:
-
manual
This diff is collapsed.
Click to expand it.
docker_test.sh
0 → 100755
+
62
−
0
View file @
6c2b25fc
#!/bin/sh
function
usage
()
{
echo
-e
"usage:
\t
$0
DIRECTORY, e.g.
$0
pica-mattermost"
echo
-e
"
\t
DIRECTORY : name of the directory containing docker-compose.yml
\n
"
echo
"This script simulates the first launch of a service : it will recreate all existing volumes for the service"
echo
"to be sure that it works independently of the former configuration, and then launch 'docker-compose up -d'."
echo
"This way, you can test your Dockerfile | docker-compose on the testing VM as if it was a brand new VM."
echo
-e
"
\n
Also, it will temporarily replace all occurences of 'picasoft.net' by 'test.picasoft.net' for convenience."
echo
-e
"
\n
This script will also use the image uploaded on the testing registry, not the production registry."
echo
-e
"
\n
USE THIS SCRIPT ONLY ON THE TESTING VM."
exit
1
}
if
[[
$(
hostname
)
!=
*
"test"
*
]]
;
then
echo
"ERROR : DO NOT USE OUTSIDE OF A TEST MACHINE !"
usage
fi
if
[[
$#
-ne
1
]]
;
then
echo
"ERROR : wrong number of arguments"
usage
fi
if
[[
!
-d
"
$1
"
]]
;
then
echo
"ERROR : directory does not exist (
$1
)"
usage
fi
# Go to the folder of the service which will be tested
cd
"
$1
"
echo
-e
"Starting procedure for
$1
...
\n
"
echo
-e
"
\n
==== Stop and remove existing containers ===="
docker-compose down
echo
"==== Reset and pull Dockerfiles repository ===="
echo
"Using branch"
$(
git branch
--show-current
)
git reset
--hard
git pull
echo
-e
"
\n
==== Remove and re-create named external volumes ===="
for
v
in
$(
docker-compose config
--volumes
)
;
do
docker volume
rm
"
$v
"
docker volume create
"
$v
"
done
echo
-e
"
\n
==== Pull new versions of images ===="
docker-compose pull
echo
-e
"
\n
==== Replace production URL with testing URL in all files ===="
for
f
in
$(
grep
-l
-r
".picasoft.net"
.
)
;
do
echo
-e
"
\t
*"
${
f
}
sed
-i
"s/.picasoft.net/.test.picasoft.net/g"
${
f
}
done
echo
-e
"
\n
==== Lauch
$1
and restore repository ===="
docker-compose up
-d
git reset
--hard
echo
-e
"
\n
==== Print logs (use Ctrl+C to stop) ===="
docker-compose logs
-f
This diff is collapsed.
Click to expand it.
get-modified-image.sh
+
4
−
2
View file @
6c2b25fc
...
...
@@ -17,6 +17,8 @@ done
echo
"export MODIFIED_IMAGE=
${
RES
}
"
>
variables
# Image name with wanted registry and tag, fetched from Docker Compose
RES
=
$(
cat
$RES
/docker-compose.yml |
grep
$RES
|
cut
-d
':'
-f2-
|
tr
-d
' '
)
RES
=
$(
cat
$RES
/docker-compose.yml |
grep
$RES
|
cut
-d
':'
-f2-
|
cut
-d
'/'
-f2-
|
tr
-d
' '
)
if
[
"
$RES
"
=
""
]
;
then
exit
1
;
fi
echo
"export MODIFIED_IMAGE_FULL=
${
RES
}
"
>>
variables
echo
"export MODIFIED_IMAGE_FULL_TEST=registry.test.picasoft.net/
${
RES
}
"
>>
variables
echo
"export MODIFIED_IMAGE_FULL=registry.picasoft.net/
${
RES
}
"
>>
variables
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment