travis2docker 6.4.28__tar.gz → 7.0.1__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-6.4.28 → travis2docker-7.0.1}/.bumpversion.cfg +1 -1
- {travis2docker-6.4.28 → travis2docker-7.0.1}/MANIFEST.in +0 -1
- {travis2docker-6.4.28 → travis2docker-7.0.1}/PKG-INFO +32 -34
- {travis2docker-6.4.28 → travis2docker-7.0.1}/README.rst +25 -26
- {travis2docker-6.4.28 → travis2docker-7.0.1}/docs/conf.py +1 -1
- travis2docker-7.0.1/requirements.txt +1 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/setup.cfg +0 -3
- {travis2docker-6.4.28 → travis2docker-7.0.1}/setup.py +10 -9
- travis2docker-7.0.1/src/travis2docker/__init__.py +1 -0
- travis2docker-7.0.1/src/travis2docker/cli.py +318 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker/docker_helper/build.py +18 -15
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker/git_run.py +20 -17
- travis2docker-7.0.1/src/travis2docker/logging_colored.py +30 -0
- travis2docker-7.0.1/src/travis2docker/travis2docker.py +165 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker.egg-info/PKG-INFO +32 -34
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker.egg-info/SOURCES.txt +1 -16
- travis2docker-7.0.1/src/travis2docker.egg-info/requires.txt +1 -0
- travis2docker-7.0.1/tests/test_travis2docker.py +171 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/tox.ini +3 -4
- travis2docker-6.4.28/examples/example_1.yml +0 -22
- travis2docker-6.4.28/examples/example_2.yml +0 -30
- travis2docker-6.4.28/examples/example_3.yml +0 -37
- travis2docker-6.4.28/examples/example_4.yml +0 -41
- travis2docker-6.4.28/examples/example_5.yml +0 -42
- travis2docker-6.4.28/requirements.txt +0 -4
- travis2docker-6.4.28/src/travis2docker/__init__.py +0 -1
- travis2docker-6.4.28/src/travis2docker/cli.py +0 -289
- travis2docker-6.4.28/src/travis2docker/templates/Dockerfile +0 -89
- travis2docker-6.4.28/src/travis2docker/templates/entrypoint.sh +0 -10
- travis2docker-6.4.28/src/travis2docker/templates/rvm_env.sh +0 -18
- travis2docker-6.4.28/src/travis2docker/travis-ci-apt-source-whitelist/.git +0 -1
- travis2docker-6.4.28/src/travis2docker/travis-ci-apt-source-whitelist/.gitignore +0 -34
- travis2docker-6.4.28/src/travis2docker/travis-ci-apt-source-whitelist/.travis.yml +0 -10
- travis2docker-6.4.28/src/travis2docker/travis-ci-apt-source-whitelist/LICENSE +0 -22
- travis2docker-6.4.28/src/travis2docker/travis-ci-apt-source-whitelist/README.md +0 -15
- travis2docker-6.4.28/src/travis2docker/travis-ci-apt-source-whitelist/add_all.rb +0 -16
- travis2docker-6.4.28/src/travis2docker/travis-ci-apt-source-whitelist/bin/travis-add-source +0 -47
- travis2docker-6.4.28/src/travis2docker/travis-ci-apt-source-whitelist/ubuntu.json +0 -317
- travis2docker-6.4.28/src/travis2docker/travis2docker.py +0 -416
- travis2docker-6.4.28/src/travis2docker.egg-info/requires.txt +0 -8
- travis2docker-6.4.28/tests/test_travis2docker.py +0 -156
- {travis2docker-6.4.28 → travis2docker-7.0.1}/.coveragerc +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/AUTHORS.rst +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/CHANGELOG.rst +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/CONTRIBUTING.rst +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/LICENSE +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/docs/authors.rst +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/docs/changelog.rst +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/docs/contributing.rst +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/docs/index.rst +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/docs/installation.rst +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/docs/readme.rst +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/docs/reference/index.rst +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/docs/reference/travis2docker.rst +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/docs/requirements.txt +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/docs/spelling_wordlist.txt +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/docs/usage.rst +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker/__main__.py +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker/exceptions.py +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker/templates/.coveragerc +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker/templates/.vscode/extensions.json +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker/templates/.vscode/launch.json +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker/templates/.vscode/settings.json +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker/templates/10-build.sh +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker/templates/20-run.sh +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker/templates/Dockerfile_deployv +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker/templates/build.sh +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker/templates/entrypoint_deployv.sh +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker.egg-info/dependency_links.txt +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker.egg-info/entry_points.txt +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker.egg-info/not-zip-safe +0 -0
- {travis2docker-6.4.28 → travis2docker-7.0.1}/src/travis2docker.egg-info/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: travis2docker
|
|
3
|
-
Version:
|
|
4
|
-
Summary: Script to generate Dockerfile from
|
|
3
|
+
Version: 7.0.1
|
|
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
|
|
7
7
|
Author-email: info@vauxoo.com
|
|
@@ -13,22 +13,20 @@ Classifier: Operating System :: POSIX
|
|
|
13
13
|
Classifier: Operating System :: Microsoft :: Windows
|
|
14
14
|
Classifier: Programming Language :: Python
|
|
15
15
|
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
19
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
22
22
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
23
23
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
24
24
|
Classifier: Topic :: Utilities
|
|
25
|
+
Requires-Python: >=3.10
|
|
25
26
|
Description-Content-Type: text/x-rst
|
|
26
27
|
License-File: LICENSE
|
|
27
28
|
License-File: AUTHORS.rst
|
|
28
|
-
Requires-Dist:
|
|
29
|
-
Requires-Dist: PyYAML==6.0.*; python_version >= "3.7"
|
|
30
|
-
Requires-Dist: Jinja2==2.11.3; python_version < "3.7"
|
|
31
|
-
Requires-Dist: Jinja2==3.1.*; python_version >= "3.7"
|
|
29
|
+
Requires-Dist: Jinja2==3.1.*
|
|
32
30
|
Dynamic: author
|
|
33
31
|
Dynamic: author-email
|
|
34
32
|
Dynamic: classifier
|
|
@@ -38,6 +36,7 @@ Dynamic: home-page
|
|
|
38
36
|
Dynamic: license
|
|
39
37
|
Dynamic: license-file
|
|
40
38
|
Dynamic: requires-dist
|
|
39
|
+
Dynamic: requires-python
|
|
41
40
|
Dynamic: summary
|
|
42
41
|
|
|
43
42
|
========
|
|
@@ -46,7 +45,7 @@ Overview
|
|
|
46
45
|
|
|
47
46
|
|
|
48
47
|
|
|
49
|
-
Script to generate Dockerfile from .
|
|
48
|
+
Script to generate a development Dockerfile from the deployv image of a repository (based on its ``variables.sh`` file)
|
|
50
49
|
|
|
51
50
|
* Free software: BSD license
|
|
52
51
|
|
|
@@ -61,32 +60,33 @@ Usage
|
|
|
61
60
|
=====
|
|
62
61
|
|
|
63
62
|
`travisfile2dockerfile REPO_URL BRANCH`
|
|
64
|
-
|
|
63
|
+
|
|
65
64
|
Or with pull request
|
|
66
65
|
`travisfile2dockerfile REPO_URL pull/##`
|
|
67
|
-
|
|
68
|
-
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.
|
|
69
69
|
|
|
70
70
|
For more information execute:
|
|
71
71
|
`travisfile2dockerfile --help`
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
Example:
|
|
74
74
|
`travisfile2dockerfile --root-path=$HOME/t2d git@github.com:Vauxoo/forecast.git 8.0`
|
|
75
75
|
|
|
76
76
|
The output is:
|
|
77
|
-
`${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0
|
|
78
|
-
`${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/2`
|
|
79
|
-
|
|
80
|
-
The first one is the build for env `TESTS=1`, the second one is for env with `LINT_CHECK=1`
|
|
77
|
+
`${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0`
|
|
81
78
|
|
|
82
79
|
To build image:
|
|
83
|
-
`${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/
|
|
80
|
+
`${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/10-build.sh`
|
|
84
81
|
|
|
85
82
|
To create container:
|
|
86
|
-
`${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/
|
|
83
|
+
`${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/20-run.sh --entrypoint=bash`
|
|
87
84
|
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
The repository needs a ``variables.sh`` file in its root path (the one used by
|
|
86
|
+
the deployv images built from the CI). By default the docker image is built
|
|
87
|
+
from its values as ``DOCKER_IMAGE_REPO:MAIN_APP-VERSION-SHA_SHORT``; use
|
|
88
|
+
``--docker-image=quay.io/vauxoo/PROJECT:TAG`` to pick the image pushed by the
|
|
89
|
+
``build_docker`` pipeline instead.
|
|
90
90
|
|
|
91
91
|
Optional tools (``--build-env-args``)
|
|
92
92
|
=====================================
|
|
@@ -138,25 +138,23 @@ SSH key without password
|
|
|
138
138
|
|
|
139
139
|
Dockerfile doesn't support a prompt to enter your password, so you need to remove it from your ssh keys.
|
|
140
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
|
+
|
|
141
144
|
::
|
|
142
145
|
|
|
143
|
-
export fname=~/.ssh/
|
|
146
|
+
export fname=~/.ssh/id_ed25519
|
|
144
147
|
cp ${fname} ${fname}_with_pwd
|
|
145
|
-
|
|
146
|
-
cp ${fname}_without_pwd ${fname}
|
|
148
|
+
ssh-keygen -p -N "" -f ${fname}
|
|
147
149
|
|
|
148
|
-
|
|
149
|
-
**********************
|
|
150
|
+
For legacy RSA keys:
|
|
150
151
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
`docker pull vauxoo/odoo-80-image-shippable-auto`
|
|
154
|
-
|
|
155
|
-
Note: You can define a custom image to use with `--docker-image` parameter.
|
|
156
|
-
|
|
157
|
-
For example if you want use the original image of travis you can add the following parameters:
|
|
152
|
+
::
|
|
158
153
|
|
|
159
|
-
|
|
154
|
+
export fname=~/.ssh/id_rsa
|
|
155
|
+
cp ${fname} ${fname}_with_pwd
|
|
156
|
+
openssl rsa -in ${fname} -out ${fname}_without_pwd
|
|
157
|
+
cp ${fname}_without_pwd ${fname}
|
|
160
158
|
|
|
161
159
|
Install docker
|
|
162
160
|
**************
|
|
@@ -53,7 +53,7 @@ Overview
|
|
|
53
53
|
|
|
54
54
|
.. end-badges
|
|
55
55
|
|
|
56
|
-
Script to generate Dockerfile from .
|
|
56
|
+
Script to generate a development Dockerfile from the deployv image of a repository (based on its ``variables.sh`` file)
|
|
57
57
|
|
|
58
58
|
* Free software: BSD license
|
|
59
59
|
|
|
@@ -68,32 +68,33 @@ 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
|
|
|
83
84
|
The output is:
|
|
84
|
-
`${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0
|
|
85
|
-
`${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/2`
|
|
86
|
-
|
|
87
|
-
The first one is the build for env `TESTS=1`, the second one is for env with `LINT_CHECK=1`
|
|
85
|
+
`${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0`
|
|
88
86
|
|
|
89
87
|
To build image:
|
|
90
|
-
`${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/
|
|
88
|
+
`${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/10-build.sh`
|
|
91
89
|
|
|
92
90
|
To create container:
|
|
93
|
-
`${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/
|
|
91
|
+
`${HOME}/t2d/script/git_github.com_Vauxoo_forecast.git/8.0/20-run.sh --entrypoint=bash`
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
The repository needs a ``variables.sh`` file in its root path (the one used by
|
|
94
|
+
the deployv images built from the CI). By default the docker image is built
|
|
95
|
+
from its values as ``DOCKER_IMAGE_REPO:MAIN_APP-VERSION-SHA_SHORT``; use
|
|
96
|
+
``--docker-image=quay.io/vauxoo/PROJECT:TAG`` to pick the image pushed by the
|
|
97
|
+
``build_docker`` pipeline instead.
|
|
97
98
|
|
|
98
99
|
Optional tools (``--build-env-args``)
|
|
99
100
|
=====================================
|
|
@@ -145,25 +146,23 @@ 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
|
+
|
|
148
152
|
::
|
|
149
153
|
|
|
150
|
-
export fname=~/.ssh/
|
|
154
|
+
export fname=~/.ssh/id_ed25519
|
|
151
155
|
cp ${fname} ${fname}_with_pwd
|
|
152
|
-
|
|
153
|
-
cp ${fname}_without_pwd ${fname}
|
|
156
|
+
ssh-keygen -p -N "" -f ${fname}
|
|
154
157
|
|
|
155
|
-
|
|
156
|
-
**********************
|
|
158
|
+
For legacy RSA keys:
|
|
157
159
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
`docker pull vauxoo/odoo-80-image-shippable-auto`
|
|
161
|
-
|
|
162
|
-
Note: You can define a custom image to use with `--docker-image` parameter.
|
|
163
|
-
|
|
164
|
-
For example if you want use the original image of travis you can add the following parameters:
|
|
160
|
+
::
|
|
165
161
|
|
|
166
|
-
|
|
162
|
+
export fname=~/.ssh/id_rsa
|
|
163
|
+
cp ${fname} ${fname}_with_pwd
|
|
164
|
+
openssl rsa -in ${fname} -out ${fname}_without_pwd
|
|
165
|
+
cp ${fname}_without_pwd ${fname}
|
|
167
166
|
|
|
168
167
|
Install docker
|
|
169
168
|
**************
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Jinja2==3.1.*
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
|
|
3
|
+
import pathlib
|
|
3
4
|
import re
|
|
4
5
|
from glob import glob
|
|
5
|
-
from os.path import basename, dirname, join, splitext
|
|
6
6
|
|
|
7
7
|
from setuptools import find_packages, setup
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
def read(*names, **kwargs):
|
|
11
|
-
return
|
|
11
|
+
return pathlib.Path(__file__).parent.joinpath(*names).read_text(encoding=kwargs.get("encoding", "utf8"))
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
setup(
|
|
15
15
|
name="travis2docker",
|
|
16
|
-
version="
|
|
16
|
+
version="7.0.1",
|
|
17
17
|
license="BSD-3-Clause",
|
|
18
|
-
description="Script to generate Dockerfile from
|
|
18
|
+
description="Script to generate a development Dockerfile from the deployv image of a repository",
|
|
19
19
|
long_description="%s\n%s"
|
|
20
20
|
% (
|
|
21
|
-
re.compile("^.. start-badges.*^.. end-badges", re.
|
|
22
|
-
re.sub(":[a-z]+:`~?(.*?)`", r"``\1``", read("CHANGELOG.rst")),
|
|
21
|
+
re.compile(r"^.. start-badges.*^.. end-badges", re.MULTILINE | re.DOTALL).sub("", read("README.rst")),
|
|
22
|
+
re.sub(r":[a-z]+:`~?(.*?)`", r"``\1``", read("CHANGELOG.rst")),
|
|
23
23
|
),
|
|
24
24
|
long_description_content_type="text/x-rst",
|
|
25
25
|
author="Vauxoo",
|
|
@@ -27,7 +27,7 @@ setup(
|
|
|
27
27
|
url="https://github.com/vauxoo/travis2docker",
|
|
28
28
|
packages=find_packages("src"),
|
|
29
29
|
package_dir={"": "src"},
|
|
30
|
-
py_modules=[
|
|
30
|
+
py_modules=[pathlib.Path(path).stem for path in glob("src/*.py")],
|
|
31
31
|
include_package_data=True,
|
|
32
32
|
zip_safe=False,
|
|
33
33
|
classifiers=[
|
|
@@ -39,12 +39,12 @@ setup(
|
|
|
39
39
|
"Operating System :: Microsoft :: Windows",
|
|
40
40
|
"Programming Language :: Python",
|
|
41
41
|
"Programming Language :: Python :: 3",
|
|
42
|
-
"Programming Language :: Python :: 3.8",
|
|
43
|
-
"Programming Language :: Python :: 3.9",
|
|
44
42
|
"Programming Language :: Python :: 3.10",
|
|
45
43
|
"Programming Language :: Python :: 3.11",
|
|
46
44
|
"Programming Language :: Python :: 3.12",
|
|
47
45
|
"Programming Language :: Python :: 3.13",
|
|
46
|
+
"Programming Language :: Python :: 3.14",
|
|
47
|
+
"Programming Language :: Python :: 3.15",
|
|
48
48
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
49
49
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
50
50
|
# uncomment if you test on these interpreters:
|
|
@@ -56,6 +56,7 @@ setup(
|
|
|
56
56
|
keywords=[
|
|
57
57
|
# eg: 'keyword1', 'keyword2', 'keyword3',
|
|
58
58
|
],
|
|
59
|
+
python_requires=">=3.10",
|
|
59
60
|
install_requires=read("requirements.txt").split("\n"),
|
|
60
61
|
extras_require={
|
|
61
62
|
# eg:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "7.0.1"
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
"""Module that contains the command line app.
|
|
2
|
+
|
|
3
|
+
Why does this file exist, and why not put this in __main__?
|
|
4
|
+
|
|
5
|
+
You might be tempted to import things from __main__ later, but that will cause
|
|
6
|
+
problems: the code will get executed twice:
|
|
7
|
+
|
|
8
|
+
- When you run `python -mtravis2docker` python will execute
|
|
9
|
+
``__main__.py`` as a script. That means there won't be any
|
|
10
|
+
``travis2docker.__main__`` in ``sys.modules``.
|
|
11
|
+
- When you import __main__ it will get executed again (as a module) because
|
|
12
|
+
there's no ``travis2docker.__main__`` in ``sys.modules``.
|
|
13
|
+
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import argparse
|
|
17
|
+
import logging
|
|
18
|
+
import os
|
|
19
|
+
import pathlib
|
|
20
|
+
|
|
21
|
+
from . import __version__
|
|
22
|
+
from .exceptions import InvalidRepoBranchError
|
|
23
|
+
from .git_run import GitRun
|
|
24
|
+
from .logging_colored import FORMAT_STR, ColoredFormatter
|
|
25
|
+
from .travis2docker import Travis2Docker
|
|
26
|
+
|
|
27
|
+
_logger = logging.getLogger(__name__)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def variables_sh_read(variables_sh_path):
|
|
31
|
+
variables_sh_path = pathlib.Path(variables_sh_path).expanduser()
|
|
32
|
+
if variables_sh_path.is_dir():
|
|
33
|
+
variables_sh_path /= "variables.sh"
|
|
34
|
+
if not variables_sh_path.is_file():
|
|
35
|
+
return None
|
|
36
|
+
return variables_sh_path.read_text()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def get_git_data(project, path, revision):
|
|
40
|
+
git_obj = GitRun(project, path, path_prefix_repo=True)
|
|
41
|
+
git_obj.update()
|
|
42
|
+
data = {
|
|
43
|
+
"sha": git_obj.get_sha(revision),
|
|
44
|
+
"variables_sh": git_obj.show_file("variables.sh", revision),
|
|
45
|
+
"repo_owner": git_obj.owner,
|
|
46
|
+
"repo_project": git_obj.repo,
|
|
47
|
+
"git_email": git_obj.get_config_data("user.email"),
|
|
48
|
+
"git_user": git_obj.get_config_data("user.name"),
|
|
49
|
+
"revision": revision,
|
|
50
|
+
"project": project,
|
|
51
|
+
}
|
|
52
|
+
return data
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def main(return_result=False):
|
|
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
|
+
)
|
|
86
|
+
parser.add_argument(
|
|
87
|
+
"git_repo_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.",
|
|
91
|
+
)
|
|
92
|
+
parser.add_argument(
|
|
93
|
+
"git_revision",
|
|
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.",
|
|
97
|
+
)
|
|
98
|
+
parser.add_argument(
|
|
99
|
+
"--docker-user",
|
|
100
|
+
dest="docker_user",
|
|
101
|
+
help="Unix user that runs the commands inside the container. "
|
|
102
|
+
"It must exist in the base docker image. "
|
|
103
|
+
"Default: odoo",
|
|
104
|
+
)
|
|
105
|
+
parser.add_argument(
|
|
106
|
+
"--docker-image",
|
|
107
|
+
dest="default_docker_image",
|
|
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'",
|
|
111
|
+
)
|
|
112
|
+
parser.add_argument(
|
|
113
|
+
"--root-path",
|
|
114
|
+
dest="root_path",
|
|
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}",
|
|
119
|
+
)
|
|
120
|
+
parser.add_argument(
|
|
121
|
+
"--add-remote",
|
|
122
|
+
dest="remotes",
|
|
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",
|
|
126
|
+
)
|
|
127
|
+
parser.add_argument(
|
|
128
|
+
"--exclude-after-success",
|
|
129
|
+
dest="exclude_after_success",
|
|
130
|
+
action="store_true",
|
|
131
|
+
default=False,
|
|
132
|
+
help="Deprecated. Ignored: the travis_after_success section does not exist anymore",
|
|
133
|
+
)
|
|
134
|
+
parser.add_argument(
|
|
135
|
+
"--run-extra-args",
|
|
136
|
+
dest="run_extra_args",
|
|
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",
|
|
141
|
+
)
|
|
142
|
+
parser.add_argument(
|
|
143
|
+
"--run-extra-cmds",
|
|
144
|
+
dest="run_extra_cmds",
|
|
145
|
+
nargs="*",
|
|
146
|
+
default="",
|
|
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",
|
|
151
|
+
)
|
|
152
|
+
parser.add_argument(
|
|
153
|
+
"--build-extra-args",
|
|
154
|
+
dest="build_extra_args",
|
|
155
|
+
help="Extra arguments appended to the `docker build` command of 10-build.sh. Default: '--rm'",
|
|
156
|
+
default="--rm",
|
|
157
|
+
)
|
|
158
|
+
parser.add_argument(
|
|
159
|
+
"--build-extra-cmds",
|
|
160
|
+
dest="build_extra_cmds",
|
|
161
|
+
nargs="*",
|
|
162
|
+
default="",
|
|
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",
|
|
166
|
+
)
|
|
167
|
+
parser.add_argument(
|
|
168
|
+
"--travis-yml-path",
|
|
169
|
+
dest="travis_yml_path",
|
|
170
|
+
default=None,
|
|
171
|
+
help="Deprecated. Ignored: the .travis.yml file is not used anymore",
|
|
172
|
+
)
|
|
173
|
+
parser.add_argument(
|
|
174
|
+
"--variables-sh-path",
|
|
175
|
+
dest="variables_sh_path",
|
|
176
|
+
default=None,
|
|
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",
|
|
180
|
+
)
|
|
181
|
+
parser.add_argument(
|
|
182
|
+
"--no-clone",
|
|
183
|
+
dest="no_clone",
|
|
184
|
+
action="store_true",
|
|
185
|
+
default=False,
|
|
186
|
+
help="Skip cloning the repository. It requires --variables-sh-path pointing "
|
|
187
|
+
"to a local variables.sh file. "
|
|
188
|
+
"Default: False",
|
|
189
|
+
)
|
|
190
|
+
parser.add_argument(
|
|
191
|
+
"--add-rcfile",
|
|
192
|
+
dest="add_rcfile",
|
|
193
|
+
default="",
|
|
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",
|
|
197
|
+
)
|
|
198
|
+
parser.add_argument("-v", "--version", action="version", version="%(prog)s " + __version__)
|
|
199
|
+
parser.add_argument(
|
|
200
|
+
"--runs-at-the-end-script",
|
|
201
|
+
dest="runs_at_the_end_script",
|
|
202
|
+
nargs="*",
|
|
203
|
+
default="",
|
|
204
|
+
help="Deprecated. Ignored: the script section of .travis.yml does not exist anymore",
|
|
205
|
+
)
|
|
206
|
+
parser.add_argument(
|
|
207
|
+
"--build-env-args",
|
|
208
|
+
dest="build_env_args",
|
|
209
|
+
nargs="*",
|
|
210
|
+
action="append",
|
|
211
|
+
default=[],
|
|
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",
|
|
216
|
+
)
|
|
217
|
+
parser.add_argument(
|
|
218
|
+
"--deployv",
|
|
219
|
+
dest="deployv",
|
|
220
|
+
action="store_true",
|
|
221
|
+
default=True,
|
|
222
|
+
help="Deprecated. The deployv image is now the only supported mode",
|
|
223
|
+
)
|
|
224
|
+
parser.add_argument(
|
|
225
|
+
"--build-extra-steps",
|
|
226
|
+
nargs="*",
|
|
227
|
+
default="",
|
|
228
|
+
dest="build_extra_steps",
|
|
229
|
+
help="Extra Dockerfile instructions appended at the end of the generated "
|
|
230
|
+
"Dockerfile, each value as a separate line. "
|
|
231
|
+
"Default: none",
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
args = parser.parse_args()
|
|
235
|
+
deprecated_args = {
|
|
236
|
+
"--exclude-after-success": args.exclude_after_success,
|
|
237
|
+
"--travis-yml-path": args.travis_yml_path,
|
|
238
|
+
"--runs-at-the-end-script": args.runs_at_the_end_script,
|
|
239
|
+
}
|
|
240
|
+
for deprecated_arg, value in deprecated_args.items():
|
|
241
|
+
if value:
|
|
242
|
+
_logger.warning("%s is deprecated and its value will be ignored", deprecated_arg)
|
|
243
|
+
revision = args.git_revision
|
|
244
|
+
git_repo = args.git_repo_url
|
|
245
|
+
git_base = GitRun.get_data_url(git_repo, False)[0]
|
|
246
|
+
docker_user = args.docker_user
|
|
247
|
+
root_path = args.root_path
|
|
248
|
+
default_docker_image = args.default_docker_image
|
|
249
|
+
remotes = args.remotes and args.remotes.split(",")
|
|
250
|
+
run_extra_args = args.run_extra_args
|
|
251
|
+
build_extra_args = args.build_extra_args
|
|
252
|
+
build_extra_cmds = "\n".join(args.build_extra_cmds)
|
|
253
|
+
run_extra_cmds = "\n".join(args.run_extra_cmds)
|
|
254
|
+
rcfiles_args = args.add_rcfile and args.add_rcfile.split(",")
|
|
255
|
+
build_env_args = [build_env_arg for build_env_args in args.build_env_args for build_env_arg in build_env_args]
|
|
256
|
+
rcfiles = [
|
|
257
|
+
(pathlib.Path(rc_file).expanduser(), "$HOME/%s" % pathlib.Path(rc_file).name) for rc_file in rcfiles_args
|
|
258
|
+
]
|
|
259
|
+
if args.no_clone:
|
|
260
|
+
os_kwargs = {
|
|
261
|
+
"repo_owner": "local_file",
|
|
262
|
+
"repo_project": "local_file",
|
|
263
|
+
"revision": revision,
|
|
264
|
+
"sha": "local_file",
|
|
265
|
+
"project": git_repo,
|
|
266
|
+
}
|
|
267
|
+
else:
|
|
268
|
+
os_kwargs = get_git_data(git_repo, pathlib.Path(root_path) / "repo", revision)
|
|
269
|
+
|
|
270
|
+
if args.variables_sh_path:
|
|
271
|
+
os_kwargs["variables_sh"] = variables_sh_read(args.variables_sh_path)
|
|
272
|
+
|
|
273
|
+
if not os_kwargs.get("variables_sh"):
|
|
274
|
+
msg = (
|
|
275
|
+
"The file %s is empty or does not exist." % args.variables_sh_path
|
|
276
|
+
if args.variables_sh_path
|
|
277
|
+
else "The repo or the branch is incorrect value, because "
|
|
278
|
+
+ "It can not got the variables.sh content from %s %s. " % (git_repo, revision)
|
|
279
|
+
+ "\nPlease, verify access repository,"
|
|
280
|
+
+ "\nverify exists url and revision, "
|
|
281
|
+
+ "\nverify exists variables.sh"
|
|
282
|
+
)
|
|
283
|
+
raise InvalidRepoBranchError(msg)
|
|
284
|
+
os_kwargs.update({"remotes": remotes, "git_base": git_base})
|
|
285
|
+
if docker_user:
|
|
286
|
+
os_kwargs.update({"user": docker_user})
|
|
287
|
+
t2d = Travis2Docker(
|
|
288
|
+
work_path=pathlib.Path(root_path) / "script" / GitRun.url2dirname(git_repo) / revision,
|
|
289
|
+
image=default_docker_image,
|
|
290
|
+
os_kwargs=os_kwargs,
|
|
291
|
+
copy_paths=[(pathlib.Path("~/.ssh").expanduser(), "$HOME/.ssh")] + rcfiles,
|
|
292
|
+
build_env_args=build_env_args,
|
|
293
|
+
build_extra_steps=args.build_extra_steps,
|
|
294
|
+
)
|
|
295
|
+
t2d.build_extra_params = {
|
|
296
|
+
"extra_params": build_extra_args,
|
|
297
|
+
"extra_cmds": build_extra_cmds,
|
|
298
|
+
}
|
|
299
|
+
t2d.run_extra_params = {
|
|
300
|
+
"extra_params": run_extra_args,
|
|
301
|
+
"extra_cmds": run_extra_cmds,
|
|
302
|
+
}
|
|
303
|
+
fname_scripts = t2d.compute_dockerfile()
|
|
304
|
+
if fname_scripts:
|
|
305
|
+
fname_list = "- " + "\n- ".join(fname_scripts)
|
|
306
|
+
_logger.info("Generated scripts:\n%s", fname_list)
|
|
307
|
+
if not default_docker_image:
|
|
308
|
+
# TODO: Add the URL to open the pipelines
|
|
309
|
+
_logger.info(
|
|
310
|
+
'TIP: Use the parameter "--docker-image=quay.io/vauxoo/PROJECT:TAG" '
|
|
311
|
+
'get the PROJECT:TAG info in your "build_docker" pipeline similar to '
|
|
312
|
+
'\n"... INFO - deployv.deployv_addon_gitlab_tools.common.common.push_image - '
|
|
313
|
+
'Pushing image ... to quay.io/vauxoo/PROJECT:TAG"'
|
|
314
|
+
)
|
|
315
|
+
else:
|
|
316
|
+
_logger.info("No scripts were generated.")
|
|
317
|
+
if return_result:
|
|
318
|
+
return fname_scripts
|