travis2docker 7.0.0__tar.gz → 7.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {travis2docker-7.0.0 → travis2docker-7.0.2}/.bumpversion.cfg +1 -1
- {travis2docker-7.0.0 → travis2docker-7.0.2}/PKG-INFO +17 -5
- {travis2docker-7.0.0 → travis2docker-7.0.2}/README.rst +16 -4
- {travis2docker-7.0.0 → travis2docker-7.0.2}/docs/conf.py +1 -1
- {travis2docker-7.0.0 → travis2docker-7.0.2}/setup.py +1 -1
- travis2docker-7.0.2/src/travis2docker/__init__.py +1 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/cli.py +87 -50
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/docker_helper/build.py +12 -9
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/git_run.py +6 -3
- travis2docker-7.0.2/src/travis2docker/logging_colored.py +30 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/templates/build.sh +1 -2
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/travis2docker.py +6 -3
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker.egg-info/PKG-INFO +17 -5
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker.egg-info/SOURCES.txt +1 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/tests/test_travis2docker.py +3 -2
- travis2docker-7.0.0/src/travis2docker/__init__.py +0 -1
- {travis2docker-7.0.0 → travis2docker-7.0.2}/.coveragerc +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/AUTHORS.rst +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/CHANGELOG.rst +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/CONTRIBUTING.rst +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/LICENSE +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/MANIFEST.in +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/docs/authors.rst +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/docs/changelog.rst +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/docs/contributing.rst +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/docs/index.rst +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/docs/installation.rst +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/docs/readme.rst +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/docs/reference/index.rst +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/docs/reference/travis2docker.rst +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/docs/requirements.txt +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/docs/spelling_wordlist.txt +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/docs/usage.rst +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/requirements.txt +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/setup.cfg +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/__main__.py +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/exceptions.py +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/templates/.coveragerc +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/templates/.vscode/extensions.json +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/templates/.vscode/launch.json +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/templates/.vscode/settings.json +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/templates/10-build.sh +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/templates/20-run.sh +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/templates/Dockerfile_deployv +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/templates/entrypoint_deployv.sh +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker.egg-info/dependency_links.txt +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker.egg-info/entry_points.txt +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker.egg-info/not-zip-safe +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker.egg-info/requires.txt +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker.egg-info/top_level.txt +0 -0
- {travis2docker-7.0.0 → travis2docker-7.0.2}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: travis2docker
|
|
3
|
-
Version: 7.0.
|
|
3
|
+
Version: 7.0.2
|
|
4
4
|
Summary: Script to generate a development Dockerfile from the deployv image of a repository
|
|
5
5
|
Home-page: https://github.com/vauxoo/travis2docker
|
|
6
6
|
Author: Vauxoo
|
|
@@ -60,15 +60,16 @@ Usage
|
|
|
60
60
|
=====
|
|
61
61
|
|
|
62
62
|
`travisfile2dockerfile REPO_URL BRANCH`
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
Or with pull request
|
|
65
65
|
`travisfile2dockerfile REPO_URL pull/##`
|
|
66
|
-
|
|
67
|
-
In REPO_URL use the ssh url of
|
|
66
|
+
|
|
67
|
+
In REPO_URL use the ssh or https url of the git repository.
|
|
68
|
+
For private repositories use the ssh url.
|
|
68
69
|
|
|
69
70
|
For more information execute:
|
|
70
71
|
`travisfile2dockerfile --help`
|
|
71
|
-
|
|
72
|
+
|
|
72
73
|
Example:
|
|
73
74
|
`travisfile2dockerfile --root-path=$HOME/t2d git@github.com:Vauxoo/forecast.git 8.0`
|
|
74
75
|
|
|
@@ -137,6 +138,17 @@ SSH key without password
|
|
|
137
138
|
|
|
138
139
|
Dockerfile doesn't support a prompt to enter your password, so you need to remove it from your ssh keys.
|
|
139
140
|
|
|
141
|
+
Recommended: use Ed25519 keys. The tool copies ``~/.ssh/id_ed25519.pub`` to the
|
|
142
|
+
container's ``authorized_keys`` and warns if only RSA keys are found.
|
|
143
|
+
|
|
144
|
+
::
|
|
145
|
+
|
|
146
|
+
export fname=~/.ssh/id_ed25519
|
|
147
|
+
cp ${fname} ${fname}_with_pwd
|
|
148
|
+
ssh-keygen -p -N "" -f ${fname}
|
|
149
|
+
|
|
150
|
+
For legacy RSA keys:
|
|
151
|
+
|
|
140
152
|
::
|
|
141
153
|
|
|
142
154
|
export fname=~/.ssh/id_rsa
|
|
@@ -68,15 +68,16 @@ Usage
|
|
|
68
68
|
=====
|
|
69
69
|
|
|
70
70
|
`travisfile2dockerfile REPO_URL BRANCH`
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
Or with pull request
|
|
73
73
|
`travisfile2dockerfile REPO_URL pull/##`
|
|
74
|
-
|
|
75
|
-
In REPO_URL use the ssh url of
|
|
74
|
+
|
|
75
|
+
In REPO_URL use the ssh or https url of the git repository.
|
|
76
|
+
For private repositories use the ssh url.
|
|
76
77
|
|
|
77
78
|
For more information execute:
|
|
78
79
|
`travisfile2dockerfile --help`
|
|
79
|
-
|
|
80
|
+
|
|
80
81
|
Example:
|
|
81
82
|
`travisfile2dockerfile --root-path=$HOME/t2d git@github.com:Vauxoo/forecast.git 8.0`
|
|
82
83
|
|
|
@@ -145,6 +146,17 @@ SSH key without password
|
|
|
145
146
|
|
|
146
147
|
Dockerfile doesn't support a prompt to enter your password, so you need to remove it from your ssh keys.
|
|
147
148
|
|
|
149
|
+
Recommended: use Ed25519 keys. The tool copies ``~/.ssh/id_ed25519.pub`` to the
|
|
150
|
+
container's ``authorized_keys`` and warns if only RSA keys are found.
|
|
151
|
+
|
|
152
|
+
::
|
|
153
|
+
|
|
154
|
+
export fname=~/.ssh/id_ed25519
|
|
155
|
+
cp ${fname} ${fname}_with_pwd
|
|
156
|
+
ssh-keygen -p -N "" -f ${fname}
|
|
157
|
+
|
|
158
|
+
For legacy RSA keys:
|
|
159
|
+
|
|
148
160
|
::
|
|
149
161
|
|
|
150
162
|
export fname=~/.ssh/id_rsa
|
|
@@ -13,7 +13,7 @@ def read(*names, **kwargs):
|
|
|
13
13
|
|
|
14
14
|
setup(
|
|
15
15
|
name="travis2docker",
|
|
16
|
-
version="7.0.
|
|
16
|
+
version="7.0.2",
|
|
17
17
|
license="BSD-3-Clause",
|
|
18
18
|
description="Script to generate a development Dockerfile from the deployv image of a repository",
|
|
19
19
|
long_description="%s\n%s"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "7.0.2"
|
|
@@ -14,15 +14,18 @@ Why does this file exist, and why not put this in __main__?
|
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
16
|
import argparse
|
|
17
|
+
import logging
|
|
17
18
|
import os
|
|
18
19
|
import pathlib
|
|
19
|
-
from sys import stdout
|
|
20
20
|
|
|
21
21
|
from . import __version__
|
|
22
22
|
from .exceptions import InvalidRepoBranchError
|
|
23
23
|
from .git_run import GitRun
|
|
24
|
+
from .logging_colored import FORMAT_STR, ColoredFormatter
|
|
24
25
|
from .travis2docker import Travis2Docker
|
|
25
26
|
|
|
27
|
+
_logger = logging.getLogger(__name__)
|
|
28
|
+
|
|
26
29
|
|
|
27
30
|
def variables_sh_read(variables_sh_path):
|
|
28
31
|
variables_sh_path = pathlib.Path(variables_sh_path).expanduser()
|
|
@@ -50,50 +53,76 @@ def get_git_data(project, path, revision):
|
|
|
50
53
|
|
|
51
54
|
|
|
52
55
|
def main(return_result=False):
|
|
53
|
-
|
|
56
|
+
handler = logging.StreamHandler()
|
|
57
|
+
handler.setFormatter(ColoredFormatter(FORMAT_STR))
|
|
58
|
+
logging.basicConfig(level=logging.DEBUG, handlers=[handler])
|
|
59
|
+
default_root_path = os.environ.get("TRAVIS2DOCKER_ROOT_PATH")
|
|
60
|
+
if not default_root_path:
|
|
61
|
+
default_root_path = pathlib.Path("~").expanduser()
|
|
62
|
+
default_root_path = str(pathlib.Path(default_root_path) / ".t2d")
|
|
63
|
+
parser = argparse.ArgumentParser(
|
|
64
|
+
prog="travisfile2dockerfile",
|
|
65
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
66
|
+
description=(
|
|
67
|
+
"travis2docker (t2d) - Generate a development Dockerfile from the\n"
|
|
68
|
+
"deployv image of a repository.\n"
|
|
69
|
+
"\n"
|
|
70
|
+
"Clones the git repository, reads the variables.sh file of the given\n"
|
|
71
|
+
"revision and generates a Dockerfile plus 10-build.sh and 20-run.sh\n"
|
|
72
|
+
"helper scripts to build the image and run a development container."
|
|
73
|
+
),
|
|
74
|
+
epilog=(
|
|
75
|
+
"examples:\n"
|
|
76
|
+
" %(prog)s git@github.com:Vauxoo/forecast.git 16.0\n"
|
|
77
|
+
" %(prog)s git@github.com:Vauxoo/forecast.git pull/42\n"
|
|
78
|
+
" %(prog)s --docker-image quay.io/vauxoo/proj:tag git@github.com:org/proj.git 16.0\n"
|
|
79
|
+
" %(prog)s --no-clone --variables-sh-path ./variables.sh foo bar\n"
|
|
80
|
+
"\n"
|
|
81
|
+
"environment variables:\n"
|
|
82
|
+
" TRAVIS2DOCKER_ROOT_PATH Override the default root path (~) where\n"
|
|
83
|
+
" the .t2d working directory is created.\n"
|
|
84
|
+
),
|
|
85
|
+
)
|
|
54
86
|
parser.add_argument(
|
|
55
87
|
"git_repo_url",
|
|
56
|
-
help="
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"\nIf your repository is private, "
|
|
60
|
-
"don't use https url, "
|
|
61
|
-
"use ssh url",
|
|
88
|
+
help="Git URL of the repository to process. "
|
|
89
|
+
"It is cloned locally to extract the variables.sh file of the deployv image. "
|
|
90
|
+
"For private repositories use the SSH URL (git@...) instead of HTTPS.",
|
|
62
91
|
)
|
|
63
92
|
parser.add_argument(
|
|
64
93
|
"git_revision",
|
|
65
|
-
help="
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"or pull number with 'pull/#' e.g. pull/1 "
|
|
69
|
-
"NOTE: A sha e.g. b48228 NOT IMPLEMENTED YET",
|
|
94
|
+
help="Git revision to process. Accepts a branch name e.g. 'main' or '16.0', "
|
|
95
|
+
"or a pull request with 'pull/#' e.g. 'pull/1'. "
|
|
96
|
+
"NOTE: A sha e.g. b48228 is not supported yet.",
|
|
70
97
|
)
|
|
71
98
|
parser.add_argument(
|
|
72
99
|
"--docker-user",
|
|
73
100
|
dest="docker_user",
|
|
74
|
-
help="
|
|
101
|
+
help="Unix user that runs the commands inside the container. "
|
|
102
|
+
"It must exist in the base docker image. "
|
|
103
|
+
"Default: odoo",
|
|
75
104
|
)
|
|
76
105
|
parser.add_argument(
|
|
77
106
|
"--docker-image",
|
|
78
107
|
dest="default_docker_image",
|
|
79
|
-
help="
|
|
80
|
-
"
|
|
81
|
-
"'DOCKER_IMAGE_REPO:MAIN_APP-VERSION-SHA_SHORT'",
|
|
108
|
+
help="Base docker image for the generated Dockerfile, e.g. the one pushed "
|
|
109
|
+
"by the 'build_docker' pipeline as 'quay.io/vauxoo/PROJECT:TAG'. "
|
|
110
|
+
"Default: built from variables.sh values as 'DOCKER_IMAGE_REPO:MAIN_APP-VERSION-SHA_SHORT'",
|
|
82
111
|
)
|
|
83
|
-
default_root_path = os.environ.get("TRAVIS2DOCKER_ROOT_PATH")
|
|
84
|
-
if not default_root_path:
|
|
85
|
-
default_root_path = pathlib.Path("~").expanduser()
|
|
86
|
-
default_root_path = str(pathlib.Path(default_root_path) / ".t2d")
|
|
87
112
|
parser.add_argument(
|
|
88
113
|
"--root-path",
|
|
89
114
|
dest="root_path",
|
|
90
|
-
help=f"Root path to save scripts generated.\nDefault: {default_root_path}",
|
|
91
115
|
default=default_root_path,
|
|
116
|
+
help="Root directory to store the generated scripts and the cloned repositories. "
|
|
117
|
+
"The 'repo/' and 'script/' sub-directories are created inside it. "
|
|
118
|
+
f"Default: {default_root_path}",
|
|
92
119
|
)
|
|
93
120
|
parser.add_argument(
|
|
94
121
|
"--add-remote",
|
|
95
122
|
dest="remotes",
|
|
96
|
-
help="
|
|
123
|
+
help="Comma-separated list of GitHub user/organization names to add as git "
|
|
124
|
+
"remotes in the instance repositories. E.g. 'Vauxoo,moylop260'. "
|
|
125
|
+
"Default: none",
|
|
97
126
|
)
|
|
98
127
|
parser.add_argument(
|
|
99
128
|
"--exclude-after-success",
|
|
@@ -105,22 +134,25 @@ def main(return_result=False):
|
|
|
105
134
|
parser.add_argument(
|
|
106
135
|
"--run-extra-args",
|
|
107
136
|
dest="run_extra_args",
|
|
108
|
-
help="Extra arguments to `docker run
|
|
109
|
-
|
|
137
|
+
help="Extra arguments appended to the `docker run` command of 20-run.sh. "
|
|
138
|
+
"Note: '-ditP' is always used, no need to add it here. "
|
|
139
|
+
"Default: '-e LANG=C.UTF-8'",
|
|
140
|
+
default="-e LANG=C.UTF-8",
|
|
110
141
|
)
|
|
111
142
|
parser.add_argument(
|
|
112
143
|
"--run-extra-cmds",
|
|
113
144
|
dest="run_extra_cmds",
|
|
114
145
|
nargs="*",
|
|
115
146
|
default="",
|
|
116
|
-
help=
|
|
117
|
-
"
|
|
118
|
-
'E.g. "docker rmi -f \\$IMAGE"'
|
|
147
|
+
help="Extra commands to run at the end of the 20-run.sh script. "
|
|
148
|
+
"The built image can be referenced with the escaped variable \\$IMAGE. "
|
|
149
|
+
'E.g. "docker rmi -f \\$IMAGE". '
|
|
150
|
+
"Default: none",
|
|
119
151
|
)
|
|
120
152
|
parser.add_argument(
|
|
121
153
|
"--build-extra-args",
|
|
122
154
|
dest="build_extra_args",
|
|
123
|
-
help="Extra arguments to `docker build
|
|
155
|
+
help="Extra arguments appended to the `docker build` command of 10-build.sh. Default: '--rm'",
|
|
124
156
|
default="--rm",
|
|
125
157
|
)
|
|
126
158
|
parser.add_argument(
|
|
@@ -128,7 +160,9 @@ def main(return_result=False):
|
|
|
128
160
|
dest="build_extra_cmds",
|
|
129
161
|
nargs="*",
|
|
130
162
|
default="",
|
|
131
|
-
help=
|
|
163
|
+
help="Extra commands to run at the end of the 10-build.sh script. "
|
|
164
|
+
"The built image can be referenced with the escaped variable \\$IMAGE. "
|
|
165
|
+
"Default: none",
|
|
132
166
|
)
|
|
133
167
|
parser.add_argument(
|
|
134
168
|
"--travis-yml-path",
|
|
@@ -140,22 +174,26 @@ def main(return_result=False):
|
|
|
140
174
|
"--variables-sh-path",
|
|
141
175
|
dest="variables_sh_path",
|
|
142
176
|
default=None,
|
|
143
|
-
help="
|
|
144
|
-
"
|
|
177
|
+
help="Use a local variables.sh file (or the directory containing it) "
|
|
178
|
+
"instead of extracting it from the cloned repository. "
|
|
179
|
+
"Default: extracted from git_repo_url at git_revision",
|
|
145
180
|
)
|
|
146
181
|
parser.add_argument(
|
|
147
182
|
"--no-clone",
|
|
148
183
|
dest="no_clone",
|
|
149
184
|
action="store_true",
|
|
150
185
|
default=False,
|
|
151
|
-
help="
|
|
186
|
+
help="Skip cloning the repository. It requires --variables-sh-path pointing "
|
|
187
|
+
"to a local variables.sh file. "
|
|
188
|
+
"Default: False",
|
|
152
189
|
)
|
|
153
190
|
parser.add_argument(
|
|
154
191
|
"--add-rcfile",
|
|
155
192
|
dest="add_rcfile",
|
|
156
193
|
default="",
|
|
157
|
-
help="
|
|
158
|
-
"copy
|
|
194
|
+
help="Comma-separated list of configuration file paths (e.g. '~/.gitconfig,~/.vimrc') "
|
|
195
|
+
"to copy into the container user's $HOME directory. "
|
|
196
|
+
"Default: none",
|
|
159
197
|
)
|
|
160
198
|
parser.add_argument("-v", "--version", action="version", version="%(prog)s " + __version__)
|
|
161
199
|
parser.add_argument(
|
|
@@ -171,11 +209,10 @@ def main(return_result=False):
|
|
|
171
209
|
nargs="*",
|
|
172
210
|
action="append",
|
|
173
211
|
default=[],
|
|
174
|
-
help="
|
|
175
|
-
"
|
|
176
|
-
"E.g. --build-env-args
|
|
177
|
-
"
|
|
178
|
-
"ARG ENVVAR1\nENV ENVVAR1=$ENVVAR1",
|
|
212
|
+
help="Environment variable names to enable in the generated Dockerfile. "
|
|
213
|
+
"Each NAME generates an 'ENV NAME=TRUE' line, used to activate optional "
|
|
214
|
+
"installation steps of the image. E.g. '--build-env-args VIM_INSTALL ZSH_INSTALL'. "
|
|
215
|
+
"Default: none",
|
|
179
216
|
)
|
|
180
217
|
parser.add_argument(
|
|
181
218
|
"--deployv",
|
|
@@ -189,7 +226,9 @@ def main(return_result=False):
|
|
|
189
226
|
nargs="*",
|
|
190
227
|
default="",
|
|
191
228
|
dest="build_extra_steps",
|
|
192
|
-
help="
|
|
229
|
+
help="Extra Dockerfile instructions appended at the end of the generated "
|
|
230
|
+
"Dockerfile, each value as a separate line. "
|
|
231
|
+
"Default: none",
|
|
193
232
|
)
|
|
194
233
|
|
|
195
234
|
args = parser.parse_args()
|
|
@@ -200,7 +239,7 @@ def main(return_result=False):
|
|
|
200
239
|
}
|
|
201
240
|
for deprecated_arg, value in deprecated_args.items():
|
|
202
241
|
if value:
|
|
203
|
-
|
|
242
|
+
_logger.warning("%s is deprecated and its value will be ignored", deprecated_arg)
|
|
204
243
|
revision = args.git_revision
|
|
205
244
|
git_repo = args.git_repo_url
|
|
206
245
|
git_base = GitRun.get_data_url(git_repo, False)[0]
|
|
@@ -213,7 +252,7 @@ def main(return_result=False):
|
|
|
213
252
|
build_extra_cmds = "\n".join(args.build_extra_cmds)
|
|
214
253
|
run_extra_cmds = "\n".join(args.run_extra_cmds)
|
|
215
254
|
rcfiles_args = args.add_rcfile and args.add_rcfile.split(",")
|
|
216
|
-
build_env_args = [
|
|
255
|
+
build_env_args = [build_env_arg for build_env_args in args.build_env_args for build_env_arg in build_env_args]
|
|
217
256
|
rcfiles = [
|
|
218
257
|
(pathlib.Path(rc_file).expanduser(), "$HOME/%s" % pathlib.Path(rc_file).name) for rc_file in rcfiles_args
|
|
219
258
|
]
|
|
@@ -264,18 +303,16 @@ def main(return_result=False):
|
|
|
264
303
|
fname_scripts = t2d.compute_dockerfile()
|
|
265
304
|
if fname_scripts:
|
|
266
305
|
fname_list = "- " + "\n- ".join(fname_scripts)
|
|
267
|
-
|
|
306
|
+
_logger.info("Generated scripts:\n%s", fname_list)
|
|
268
307
|
if not default_docker_image:
|
|
269
|
-
stdout.write("=" * 80)
|
|
270
308
|
# TODO: Add the URL to open the pipelines
|
|
271
|
-
|
|
272
|
-
'
|
|
309
|
+
_logger.info(
|
|
310
|
+
'TIP: Use the parameter "--docker-image=quay.io/vauxoo/PROJECT:TAG" '
|
|
273
311
|
'get the PROJECT:TAG info in your "build_docker" pipeline similar to '
|
|
274
312
|
'\n"... INFO - deployv.deployv_addon_gitlab_tools.common.common.push_image - '
|
|
275
|
-
'Pushing image ... to quay.io/vauxoo/PROJECT:TAG"
|
|
313
|
+
'Pushing image ... to quay.io/vauxoo/PROJECT:TAG"'
|
|
276
314
|
)
|
|
277
|
-
stdout.write("=" * 80)
|
|
278
315
|
else:
|
|
279
|
-
|
|
316
|
+
_logger.info("No scripts were generated.")
|
|
280
317
|
if return_result:
|
|
281
318
|
return fname_scripts
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
# No plan to use logging here
|
|
2
|
-
# pylint: disable=print-used
|
|
3
|
-
|
|
4
1
|
import glob
|
|
2
|
+
import logging
|
|
5
3
|
import pathlib
|
|
6
4
|
import re
|
|
7
5
|
import subprocess
|
|
8
6
|
import sys
|
|
9
7
|
|
|
8
|
+
# Standalone script copied into the docker image and run with
|
|
9
|
+
# `python3 -c "import build;..."` so it configures its own logging
|
|
10
|
+
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)s %(name)s: %(message)s")
|
|
11
|
+
_logger = logging.getLogger("docker_helper.build")
|
|
12
|
+
|
|
10
13
|
|
|
11
14
|
def ssh_keyscan2known_hosts(url, known_hosts_path=None):
|
|
12
15
|
# python3 -c "import build;build.ssh_keyscan2known_hosts('url')"
|
|
@@ -15,12 +18,12 @@ def ssh_keyscan2known_hosts(url, known_hosts_path=None):
|
|
|
15
18
|
|
|
16
19
|
# Clear current known hosts
|
|
17
20
|
cmd = ["ssh-keygen", "-R", url]
|
|
18
|
-
|
|
21
|
+
_logger.info(" ".join(cmd))
|
|
19
22
|
subprocess.call(cmd)
|
|
20
23
|
|
|
21
24
|
# Scan new key of host and store
|
|
22
25
|
cmd = ["ssh-keyscan", "-p", "22", url]
|
|
23
|
-
|
|
26
|
+
_logger.info(" ".join(cmd))
|
|
24
27
|
keys_scanned = subprocess.check_output(cmd).decode(sys.stdout.encoding).strip()
|
|
25
28
|
with pathlib.Path(known_hosts_path).open("r+") as known_hosts_f:
|
|
26
29
|
known_hosts_f.write("\n" + keys_scanned)
|
|
@@ -54,7 +57,7 @@ def git_set_remote(path=None):
|
|
|
54
57
|
subprocess.call(cmd)
|
|
55
58
|
|
|
56
59
|
if not git_re_match:
|
|
57
|
-
|
|
60
|
+
_logger.warning("Remote not matched %s", remote)
|
|
58
61
|
continue
|
|
59
62
|
|
|
60
63
|
git_re_groups = git_re_match.groups()
|
|
@@ -65,7 +68,7 @@ def git_set_remote(path=None):
|
|
|
65
68
|
# Transform https url to ssh format
|
|
66
69
|
ssh_url_stb = "git@%s:%s/%s" % (host, org, repo)
|
|
67
70
|
cmd = git_cmd + ["remote", "set-url", "origin", ssh_url_stb]
|
|
68
|
-
|
|
71
|
+
_logger.info(" ".join(cmd))
|
|
69
72
|
subprocess.call(cmd)
|
|
70
73
|
|
|
71
74
|
# Unshallow repository
|
|
@@ -76,7 +79,7 @@ def git_set_remote(path=None):
|
|
|
76
79
|
ssh_keyscan2known_hosts(host)
|
|
77
80
|
hosts_scanned.add(host)
|
|
78
81
|
cmd = git_cmd + ["fetch", "--unshallow"]
|
|
79
|
-
|
|
82
|
+
_logger.info(" ".join(cmd))
|
|
80
83
|
subprocess.call(cmd)
|
|
81
84
|
|
|
82
85
|
# Add extra remote if "stb" so add "dev" if "dev" so add "stb"
|
|
@@ -84,5 +87,5 @@ def git_set_remote(path=None):
|
|
|
84
87
|
new_remote = "dev" if "dev" in new_org else "stb"
|
|
85
88
|
ssh_url_dev = "git@%s:%s/%s" % (host, new_org, repo)
|
|
86
89
|
cmd = git_cmd + ["remote", "add", new_remote, ssh_url_dev]
|
|
87
|
-
|
|
90
|
+
_logger.info(" ".join(cmd))
|
|
88
91
|
subprocess.call(cmd)
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
# pylint: disable=useless-object-inheritance,
|
|
1
|
+
# pylint: disable=useless-object-inheritance,except-pass
|
|
2
2
|
|
|
3
3
|
import contextlib
|
|
4
|
+
import logging
|
|
4
5
|
import pathlib
|
|
5
6
|
import re
|
|
6
7
|
import subprocess
|
|
7
8
|
|
|
9
|
+
_logger = logging.getLogger(__name__)
|
|
10
|
+
|
|
8
11
|
|
|
9
12
|
def decode_utf(field):
|
|
10
13
|
try:
|
|
@@ -60,8 +63,8 @@ class GitRun:
|
|
|
60
63
|
def run(self, cmd):
|
|
61
64
|
"""Execute git command in bash"""
|
|
62
65
|
cmd = ["git", "--git-dir=%s" % self.path] + cmd
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
_logger.debug("cmd list %s", cmd)
|
|
67
|
+
_logger.debug("cmd %s", " ".join(cmd))
|
|
65
68
|
res = None
|
|
66
69
|
with contextlib.suppress(BaseException):
|
|
67
70
|
res = subprocess.check_output(cmd)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, _NOTHING, DEFAULT = range(10)
|
|
4
|
+
# The background is set with 40 plus the number of the color, and the foreground with 30
|
|
5
|
+
# These are the sequences needed to get colored output
|
|
6
|
+
RESET_SEQ = "\033[0m"
|
|
7
|
+
COLOR_SEQ = "\033[1;%dm"
|
|
8
|
+
BOLD_SEQ = "\033[1m"
|
|
9
|
+
COLOR_PATTERN = "%s%s%%s%s" % (COLOR_SEQ, COLOR_SEQ, RESET_SEQ)
|
|
10
|
+
LEVEL_COLOR_MAPPING = {
|
|
11
|
+
logging.DEBUG: (BLUE, DEFAULT),
|
|
12
|
+
logging.INFO: (GREEN, DEFAULT),
|
|
13
|
+
logging.WARNING: (YELLOW, DEFAULT),
|
|
14
|
+
logging.ERROR: (RED, DEFAULT),
|
|
15
|
+
logging.CRITICAL: (WHITE, RED),
|
|
16
|
+
}
|
|
17
|
+
FORMAT_STR = "%(asctime)s %(levelname)s %(name)s: %(message)s"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def colorized_msg(msg, level):
|
|
21
|
+
fg_color, bg_color = LEVEL_COLOR_MAPPING.get(level, (GREEN, DEFAULT))
|
|
22
|
+
colorized_msg_str = COLOR_PATTERN % (30 + fg_color, 40 + bg_color, msg)
|
|
23
|
+
return colorized_msg_str
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ColoredFormatter(logging.Formatter):
|
|
27
|
+
def format(self, record):
|
|
28
|
+
level_colorized = colorized_msg(record.levelname, record.levelno)
|
|
29
|
+
record.levelname = level_colorized
|
|
30
|
+
return logging.Formatter.format(self, record)
|
|
@@ -137,10 +137,9 @@ install_dev_tools(){
|
|
|
137
137
|
git config --system core.pager delta
|
|
138
138
|
git config --system interactive.diffFilter "delta --color-only"
|
|
139
139
|
|
|
140
|
+
git config --system delta.diff-highlight true
|
|
140
141
|
git config --system delta.navigate true
|
|
141
142
|
git config --system delta.line-numbers true
|
|
142
|
-
git config --system delta.syntax-theme DarkNeon
|
|
143
|
-
git config --system delta.keep-plus-minus-markers true
|
|
144
143
|
fi
|
|
145
144
|
cat >> /etc/multitail.conf << EOF
|
|
146
145
|
# Odoo log
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
# pylint: disable=useless-object-inheritance,consider-using-with
|
|
1
|
+
# pylint: disable=useless-object-inheritance,consider-using-with
|
|
2
|
+
import logging
|
|
2
3
|
import pathlib
|
|
3
4
|
import re
|
|
4
5
|
import shutil
|
|
@@ -7,6 +8,8 @@ from tempfile import gettempdir
|
|
|
7
8
|
|
|
8
9
|
import jinja2
|
|
9
10
|
|
|
11
|
+
_logger = logging.getLogger(__name__)
|
|
12
|
+
|
|
10
13
|
RE_ENV_STR = r"(?P<var>[\w]*)[ ]*[\=][ ]*[\"\']{0,1}" + r"(?P<value>[\w\.\-\_/\$\{\}\:,\(\)\#\* ]*)[\"\']{0,1}"
|
|
11
14
|
RE_EXPORT_STR = r"^(?P<export>export|EXPORT)( )+" + RE_ENV_STR
|
|
12
15
|
|
|
@@ -149,11 +152,11 @@ class Travis2Docker:
|
|
|
149
152
|
if ed_key.is_file():
|
|
150
153
|
to_copy = ed_key
|
|
151
154
|
elif rsa_key.is_file():
|
|
152
|
-
|
|
155
|
+
_logger.warning("RSA keys are deprecated, consider changing to ed25519")
|
|
153
156
|
to_copy = rsa_key
|
|
154
157
|
|
|
155
158
|
if not to_copy:
|
|
156
|
-
|
|
159
|
+
_logger.warning("No public key found. No key added to ~/.ssh/authorized_keys. SSH login won't work.")
|
|
157
160
|
return
|
|
158
161
|
|
|
159
162
|
pub_key = to_copy.read_text(encoding="utf-8")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: travis2docker
|
|
3
|
-
Version: 7.0.
|
|
3
|
+
Version: 7.0.2
|
|
4
4
|
Summary: Script to generate a development Dockerfile from the deployv image of a repository
|
|
5
5
|
Home-page: https://github.com/vauxoo/travis2docker
|
|
6
6
|
Author: Vauxoo
|
|
@@ -60,15 +60,16 @@ Usage
|
|
|
60
60
|
=====
|
|
61
61
|
|
|
62
62
|
`travisfile2dockerfile REPO_URL BRANCH`
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
Or with pull request
|
|
65
65
|
`travisfile2dockerfile REPO_URL pull/##`
|
|
66
|
-
|
|
67
|
-
In REPO_URL use the ssh url of
|
|
66
|
+
|
|
67
|
+
In REPO_URL use the ssh or https url of the git repository.
|
|
68
|
+
For private repositories use the ssh url.
|
|
68
69
|
|
|
69
70
|
For more information execute:
|
|
70
71
|
`travisfile2dockerfile --help`
|
|
71
|
-
|
|
72
|
+
|
|
72
73
|
Example:
|
|
73
74
|
`travisfile2dockerfile --root-path=$HOME/t2d git@github.com:Vauxoo/forecast.git 8.0`
|
|
74
75
|
|
|
@@ -137,6 +138,17 @@ SSH key without password
|
|
|
137
138
|
|
|
138
139
|
Dockerfile doesn't support a prompt to enter your password, so you need to remove it from your ssh keys.
|
|
139
140
|
|
|
141
|
+
Recommended: use Ed25519 keys. The tool copies ``~/.ssh/id_ed25519.pub`` to the
|
|
142
|
+
container's ``authorized_keys`` and warns if only RSA keys are found.
|
|
143
|
+
|
|
144
|
+
::
|
|
145
|
+
|
|
146
|
+
export fname=~/.ssh/id_ed25519
|
|
147
|
+
cp ${fname} ${fname}_with_pwd
|
|
148
|
+
ssh-keygen -p -N "" -f ${fname}
|
|
149
|
+
|
|
150
|
+
For legacy RSA keys:
|
|
151
|
+
|
|
140
152
|
::
|
|
141
153
|
|
|
142
154
|
export fname=~/.ssh/id_rsa
|
|
@@ -27,6 +27,7 @@ src/travis2docker/__main__.py
|
|
|
27
27
|
src/travis2docker/cli.py
|
|
28
28
|
src/travis2docker/exceptions.py
|
|
29
29
|
src/travis2docker/git_run.py
|
|
30
|
+
src/travis2docker/logging_colored.py
|
|
30
31
|
src/travis2docker/travis2docker.py
|
|
31
32
|
src/travis2docker.egg-info/PKG-INFO
|
|
32
33
|
src/travis2docker.egg-info/SOURCES.txt
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
#
|
|
2
|
-
# pylint: disable=print-used,consider-using-with
|
|
1
|
+
# pylint: disable=consider-using-with
|
|
3
2
|
|
|
4
3
|
import os
|
|
5
4
|
import pathlib
|
|
@@ -74,6 +73,7 @@ def test_main_deployv(tmp_path, monkeypatch):
|
|
|
74
73
|
"BUILD_ENV1",
|
|
75
74
|
"--build-env-args",
|
|
76
75
|
"BUILD_ENV2",
|
|
76
|
+
"BUILD_ENV3",
|
|
77
77
|
"--build-extra-steps",
|
|
78
78
|
"touch /home/odoo/extra_step_done",
|
|
79
79
|
# Deprecated parameters must still be accepted (and ignored)
|
|
@@ -91,6 +91,7 @@ def test_main_deployv(tmp_path, monkeypatch):
|
|
|
91
91
|
assert "FROM quay.io/vauxoo/myproject:myproject-16.0-%s" % sha_short in dkr_content
|
|
92
92
|
assert "ENV BUILD_ENV1=TRUE" in dkr_content
|
|
93
93
|
assert "ENV BUILD_ENV2=TRUE" in dkr_content
|
|
94
|
+
assert "ENV BUILD_ENV3=TRUE" in dkr_content
|
|
94
95
|
assert "RUN touch /home/odoo/extra_step_done" in dkr_content
|
|
95
96
|
assert "ENTRYPOINT /entrypoint.sh" in dkr_content
|
|
96
97
|
assert "COPY build.sh /home/odoo/build.sh" in dkr_content
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "7.0.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/templates/.vscode/extensions.json
RENAMED
|
File without changes
|
|
File without changes
|
{travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/templates/.vscode/settings.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{travis2docker-7.0.0 → travis2docker-7.0.2}/src/travis2docker/templates/entrypoint_deployv.sh
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|