Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
cb80a8d9
Commit
cb80a8d9
authored
May 05, 2020
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved build script and Docker builds
Caching pip packages as suggested by Alfonso.
parent
31f80acb
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
57 deletions
+93
-57
build.py
bin/build.py
+76
-49
Dockerfile
src/data-hub/community-detection-microservice/Dockerfile
+5
-2
Dockerfile
src/data-hub/semantic-linking-microservice/Dockerfile
+4
-2
Dockerfile
src/rest-gateway/Dockerfile
+4
-2
Dockerfile
...ransaction-hub-in/trace-retrieval-microservice/Dockerfile
+4
-2
No files found.
bin/build.py
View file @
cb80a8d9
import
os
import
os
import
shutil
import
shutil
import
sys
import
sys
from
typing
import
Dict
DOCKER_
COMPOSE
_NAME
=
"Dockerfile"
DOCKER_
BUILD
_NAME
=
"Dockerfile"
ROOT
=
'./'
ROOT
=
'./'
SOURCEPATH
=
f
'{ROOT}src/'
SOURCEPATH
=
f
'{ROOT}src/'
DOCKER
_USERNAME
=
"alexx882"
DOCKER
HUB_REPO_OWNER
=
"alexx882"
p_image_name
=
None
if
len
(
sys
.
argv
)
==
2
:
# parameter contains image to build
p_image_name
=
sys
.
argv
[
1
]
paths
=
[]
def
print_help
():
for
r
,
_
,
f
in
os
.
walk
(
SOURCEPATH
):
print
(
"""
Use this script to build Docker images and upload them to Docker Hub.
For the upload to work, the current user must be logged in on the Docker CLI and must have push access to the repositories.
Parameters: [image_name]
image_name ... only build this image
"""
)
def
get_dockerfile_paths_and_names
()
->
Dict
[
str
,
str
]:
paths
=
[]
for
r
,
_
,
f
in
os
.
walk
(
SOURCEPATH
):
for
filename
in
f
:
for
filename
in
f
:
if
DOCKER_COMPOSE
_NAME
==
filename
:
if
DOCKER_BUILD
_NAME
==
filename
:
paths
.
append
(
os
.
path
.
normpath
(
r
))
paths
.
append
(
os
.
path
.
normpath
(
r
))
command_args
=
[{
'path'
:
path
,
command_args
=
[{
'path'
:
path
,
'name'
:
str
(
path
)
.
split
(
os
.
path
.
normpath
(
'/'
))[
-
1
]}
'name'
:
str
(
path
)
.
split
(
os
.
path
.
normpath
(
'/'
))[
-
1
]}
for
path
for
path
in
paths
]
in
paths
]
if
p_image_name
is
not
None
:
return
command_args
command_args
=
[
x
for
x
in
command_args
if
x
[
'name'
]
==
p_image_name
]
if
__name__
==
'__main__'
:
p_image_name
=
None
error
:
int
=
0
if
len
(
sys
.
argv
)
==
2
:
res_str
=
[]
arg
=
sys
.
argv
[
1
]
for
command_arg
in
command_args
:
if
arg
==
'help'
:
print_help
()
sys
.
exit
(
0
)
else
:
# parameter contains image name to be build
p_image_name
=
arg
command_args
=
get_dockerfile_paths_and_names
()
if
p_image_name
is
not
None
:
# filter for argument image name
command_args
=
[
x
for
x
in
command_args
if
(
p_image_name
in
x
[
'name'
])]
error
:
int
=
0
res_str
=
[]
for
command_arg
in
command_args
:
path
=
command_arg
[
'path'
]
path
=
command_arg
[
'path'
]
image_name
=
f
"{DOCKER_USERNAME
}/{command_arg['name']}"
image_name
=
f
"{DOCKERHUB_REPO_OWNER
}/{command_arg['name']}"
# copy Dockerfile into root dir to have access to modules folder
# copy Dockerfile into root dir to have access to modules folder
shutil
.
copy2
(
os
.
path
.
join
(
path
,
DOCKER_COMPOSE
_NAME
),
ROOT
)
shutil
.
copy2
(
os
.
path
.
join
(
path
,
DOCKER_BUILD
_NAME
),
ROOT
)
# build then remove Dockerfile
# build then remove Dockerfile
exit_val
=
os
.
system
(
f
"docker image build -t {image_name} {ROOT}"
)
exit_val
=
os
.
system
(
f
"docker image build -t {image_name} {ROOT}"
)
os
.
remove
(
os
.
path
.
join
(
ROOT
,
DOCKER_COMPOSE
_NAME
))
os
.
remove
(
os
.
path
.
join
(
ROOT
,
DOCKER_BUILD
_NAME
))
res_str
.
append
(
f
"{image_name} built with exit code {exit_val}"
)
res_str
.
append
(
f
"{image_name} built with exit code {exit_val}"
)
...
@@ -52,9 +80,8 @@ for command_arg in command_args:
...
@@ -52,9 +80,8 @@ for command_arg in command_args:
if
exit_val
!=
0
:
if
exit_val
!=
0
:
error
=
exit_val
error
=
exit_val
print
(
f
"Found {len(command_args)} images"
)
print
(
f
"Found {len(command_args)} images"
)
for
s
in
res_str
:
for
s
in
res_str
:
print
(
s
)
print
(
s
)
sys
.
exit
(
1
if
error
>
0
else
0
)
sys
.
exit
(
1
if
error
>
0
else
0
)
\ No newline at end of file
src/data-hub/community-detection-microservice/Dockerfile
View file @
cb80a8d9
...
@@ -9,10 +9,13 @@ RUN apt-get update
...
@@ -9,10 +9,13 @@ RUN apt-get update
EXPOSE
5000
EXPOSE
5000
WORKDIR
/app
WORKDIR
/app
COPY
src/modules/ /app/
COPY
src/data-hub/community-detection-microservice/app/ /app/
# https://www.aptible.com/documentation/faq/deploy/dockerfile-caching/pip-dockerfile-caching.html
COPY
src/data-hub/community-detection-microservice/app/requirements.txt /app/
RUN
pip
install
-r
requirements.txt
RUN
pip
install
-r
requirements.txt
COPY
src/modules/ /app/
COPY
src/data-hub/community-detection-microservice/app/ /app/
RUN
chmod
a+x main.py
RUN
chmod
a+x main.py
CMD
["python", "./main.py"]
CMD
["python", "./main.py"]
\ No newline at end of file
src/data-hub/semantic-linking-microservice/Dockerfile
View file @
cb80a8d9
...
@@ -9,10 +9,12 @@ RUN apt-get update
...
@@ -9,10 +9,12 @@ RUN apt-get update
EXPOSE
5000
EXPOSE
5000
WORKDIR
/app
WORKDIR
/app
COPY
src/data-hub/semantic-linking-microservice/app/ /app/
COPY
src/modules/ /app/
COPY
src/data-hub/semantic-linking-microservice/app/requirements.txt /app/
RUN
pip
install
-r
requirements.txt
RUN
pip
install
-r
requirements.txt
COPY
src/data-hub/semantic-linking-microservice/app/ /app/
COPY
src/modules/ /app/
RUN
chmod
a+x main.py
RUN
chmod
a+x main.py
CMD
["python", "./main.py"]
CMD
["python", "./main.py"]
\ No newline at end of file
src/rest-gateway/Dockerfile
View file @
cb80a8d9
...
@@ -9,10 +9,12 @@ RUN apt-get update
...
@@ -9,10 +9,12 @@ RUN apt-get update
EXPOSE
5000
EXPOSE
5000
WORKDIR
/app
WORKDIR
/app
COPY
src/rest-gateway/app/ /app/
COPY
src/modules/ /app/
COPY
src/rest-gateway/app/requirements.txt /app/
RUN
pip
install
-r
requirements.txt
RUN
pip
install
-r
requirements.txt
COPY
src/rest-gateway/app/ /app/
COPY
src/modules/ /app/
RUN
chmod
a+x main.py
RUN
chmod
a+x main.py
CMD
["python", "./main.py"]
CMD
["python", "./main.py"]
\ No newline at end of file
src/transaction-hub-in/trace-retrieval-microservice/Dockerfile
View file @
cb80a8d9
...
@@ -9,10 +9,12 @@ RUN apt-get update
...
@@ -9,10 +9,12 @@ RUN apt-get update
EXPOSE
5000
EXPOSE
5000
WORKDIR
/app
WORKDIR
/app
COPY
src/transaction-hub-in/trace-retrieval-microservice/app/ /app/
COPY
src/modules/ /app/
COPY
src/transaction-hub-in/trace-retrieval-microservice/app/requirements.txt /app/
RUN
pip
install
-r
requirements.txt
RUN
pip
install
-r
requirements.txt
COPY
src/transaction-hub-in/trace-retrieval-microservice/app/ /app/
COPY
src/modules/ /app/
RUN
chmod
a+x main.py
RUN
chmod
a+x main.py
CMD
["python", "./main.py"]
CMD
["python", "./main.py"]
\ 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