Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Wellbore Domain Services
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSDU
OSDU Data Platform
Domain Data Management Services
Wellbore
Wellbore Domain Services
Commits
dc77a799
Commit
dc77a799
authored
4 years ago
by
Luc Yriarte
Browse files
Options
Downloads
Patches
Plain Diff
Re-add container build for gitlab CICD
parent
a084f969
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!7
Slb code push 2
Pipeline
#23282
failed
4 years ago
Stage: review
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
build/Dockerfile
+49
-0
49 additions, 0 deletions
build/Dockerfile
build/set_version.py
+55
-0
55 additions, 0 deletions
build/set_version.py
with
104 additions
and
0 deletions
build/Dockerfile
0 → 100644
+
49
−
0
View file @
dc77a799
##################################################################
# Create a first image with credentials. It will download the dep.
##################################################################
FROM
python:3.7-slim-buster
as
build
WORKDIR
/root/build_directory
LABEL
maintainer="OSDU Wellbore data domain services team <WellboreDDMS@slb.com>"
COPY
requirements.txt .
RUN
pip wheel uvicorn
--wheel-dir
=
python-packages
ARG
PIP_EXTRA_URL
ARG
PIP_WHEEL_DIR
RUN
pip wheel
-r
requirements.txt
--extra-index-url
=
$PIP_EXTRA_URL
--wheel-dir
=
$PIP_WHEEL_DIR
#################################################################
# Create a second image without credentials
#################################################################
FROM
python:3.7-slim-buster
COPY
--from=build /root/build_directory .
RUN
pip
install
--force-reinstall
--ignore-installed
--upgrade
--no-index
--no-deps
python-packages/
*
COPY
./app /app
ENV
PYTHONPATH=./
# record some detail of the build, must be passed as --build-arg
ARG
build_date
ARG
build_number
ARG
build_origin="Personal build"
ARG
commit_id
ARG
commit_branch
ENV
OS_WELLBORE_DDMS_BUILD_DETAILS build_date=$build_date;build_number=$build_number;build_origin=$build_origin;commit_id=$commit_id;commit_branch=$commit_branch
EXPOSE
8097
WORKDIR
./
# Make the container run as non-root user
#(https://medium.com/better-programming/running-a-container-with-a-non-root-user-e35830d1f42a)
RUN
addgroup
--system
appuser
&&
adduser
--system
appuser
&&
adduser appuser appuser
USER
appuser
CMD
["uvicorn", "app.wdms_app:wdms_app", "--host", "0.0.0.0", "--port", "8097"]
This diff is collapsed.
Click to expand it.
build/set_version.py
0 → 100644
+
55
−
0
View file @
dc77a799
import
re
import
shutil
import
sys
FILE_TO_UPDATE
=
'
app/__init__.py
'
VERSION_FIELD_NAME
=
'
__version__
'
BUILD_NUMBER_FIELD_NAME
=
'
__build_number__
'
FIELDS_TO_CAPTURE
=
[
VERSION_FIELD_NAME
,
BUILD_NUMBER_FIELD_NAME
]
# capture KEY = basic string
regexp_key_value_capture
=
re
.
compile
(
"
^[
\\
s]*(
"
+
'
|
'
.
join
(
FIELDS_TO_CAPTURE
)
+
"
)[
\\
s]*=[
\\
s]*[(
'
\\\"
)](.+)[(
'
\\\"
)].*
"
)
regexp_key_capture
=
re
.
compile
(
"
^[
\\
s]*(
"
+
'
|
'
.
join
(
FIELDS_TO_CAPTURE
)
+
"
)[
\\
s]*=.*
"
)
def
set_version
(
file_name
:
str
,
*
,
build_number
:
str
,
patch_number
:
str
):
initial_value
=
{
k
:
None
for
k
in
FIELDS_TO_CAPTURE
}
lines
=
[
'
# updated by script -------------------
\n
'
,
'
\n
'
]
# capture
with
open
(
file_name
)
as
f
:
for
line
in
f
:
lines
.
append
(
line
)
m
=
regexp_key_value_capture
.
match
(
line
)
if
m
is
not
None
and
len
(
m
.
groups
())
==
2
:
key
,
value
=
m
.
group
(
1
,
2
)
initial_value
[
key
]
=
value
# backup
shutil
.
copyfile
(
file_name
,
file_name
+
'
.bck
'
)
new_values
=
{
VERSION_FIELD_NAME
:
'"'
+
initial_value
[
VERSION_FIELD_NAME
]
+
f
'
.
{
patch_number
or
"
0000
"
}
'
+
'"'
,
BUILD_NUMBER_FIELD_NAME
:
f
'"
{
build_number
or
"
unknown
"
}
"'
,
}
with
open
(
file_name
,
'
w
'
)
as
f
:
for
line
in
lines
:
m
=
regexp_key_capture
.
match
(
line
)
if
m
is
not
None
:
key
=
m
.
group
(
1
)
if
key
in
new_values
:
f
.
write
(
'
# was:
'
+
line
)
line
=
f
'
{
key
}
=
{
new_values
[
key
]
}
\n\n
'
f
.
write
(
line
)
# other line kept untouched
if
__name__
==
"
__main__
"
:
kwargs
=
{
arg
.
split
(
'
=
'
)[
0
]:
arg
.
split
(
'
=
'
)[
1
]
for
arg
in
sys
.
argv
[
1
:]}
assert
'
build_number
'
in
kwargs
and
'
patch_number
'
in
kwargs
,
'
build_number and patch_number must be defined
'
set_version
(
FILE_TO_UPDATE
,
build_number
=
kwargs
[
'
build_number
'
],
patch_number
=
kwargs
[
'
patch_number
'
])
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