travis2docker 7.0.2__tar.gz → 7.0.4__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.
Files changed (52) hide show
  1. {travis2docker-7.0.2 → travis2docker-7.0.4}/.bumpversion.cfg +1 -1
  2. {travis2docker-7.0.2 → travis2docker-7.0.4}/PKG-INFO +32 -8
  3. {travis2docker-7.0.2 → travis2docker-7.0.4}/README.rst +31 -7
  4. {travis2docker-7.0.2 → travis2docker-7.0.4}/docs/conf.py +1 -1
  5. {travis2docker-7.0.2 → travis2docker-7.0.4}/setup.py +1 -1
  6. travis2docker-7.0.4/src/travis2docker/__init__.py +1 -0
  7. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/cli.py +5 -0
  8. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/templates/Dockerfile_deployv +18 -0
  9. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/templates/build.sh +20 -6
  10. travis2docker-7.0.4/src/travis2docker/templates/devcontainer.json +14 -0
  11. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/travis2docker.py +35 -1
  12. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker.egg-info/PKG-INFO +32 -8
  13. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker.egg-info/SOURCES.txt +1 -0
  14. {travis2docker-7.0.2 → travis2docker-7.0.4}/tests/test_travis2docker.py +61 -0
  15. travis2docker-7.0.2/src/travis2docker/__init__.py +0 -1
  16. {travis2docker-7.0.2 → travis2docker-7.0.4}/.coveragerc +0 -0
  17. {travis2docker-7.0.2 → travis2docker-7.0.4}/AUTHORS.rst +0 -0
  18. {travis2docker-7.0.2 → travis2docker-7.0.4}/CHANGELOG.rst +0 -0
  19. {travis2docker-7.0.2 → travis2docker-7.0.4}/CONTRIBUTING.rst +0 -0
  20. {travis2docker-7.0.2 → travis2docker-7.0.4}/LICENSE +0 -0
  21. {travis2docker-7.0.2 → travis2docker-7.0.4}/MANIFEST.in +0 -0
  22. {travis2docker-7.0.2 → travis2docker-7.0.4}/docs/authors.rst +0 -0
  23. {travis2docker-7.0.2 → travis2docker-7.0.4}/docs/changelog.rst +0 -0
  24. {travis2docker-7.0.2 → travis2docker-7.0.4}/docs/contributing.rst +0 -0
  25. {travis2docker-7.0.2 → travis2docker-7.0.4}/docs/index.rst +0 -0
  26. {travis2docker-7.0.2 → travis2docker-7.0.4}/docs/installation.rst +0 -0
  27. {travis2docker-7.0.2 → travis2docker-7.0.4}/docs/readme.rst +0 -0
  28. {travis2docker-7.0.2 → travis2docker-7.0.4}/docs/reference/index.rst +0 -0
  29. {travis2docker-7.0.2 → travis2docker-7.0.4}/docs/reference/travis2docker.rst +0 -0
  30. {travis2docker-7.0.2 → travis2docker-7.0.4}/docs/requirements.txt +0 -0
  31. {travis2docker-7.0.2 → travis2docker-7.0.4}/docs/spelling_wordlist.txt +0 -0
  32. {travis2docker-7.0.2 → travis2docker-7.0.4}/docs/usage.rst +0 -0
  33. {travis2docker-7.0.2 → travis2docker-7.0.4}/requirements.txt +0 -0
  34. {travis2docker-7.0.2 → travis2docker-7.0.4}/setup.cfg +0 -0
  35. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/__main__.py +0 -0
  36. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/docker_helper/build.py +0 -0
  37. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/exceptions.py +0 -0
  38. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/git_run.py +0 -0
  39. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/logging_colored.py +0 -0
  40. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/templates/.coveragerc +0 -0
  41. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/templates/.vscode/extensions.json +0 -0
  42. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/templates/.vscode/launch.json +0 -0
  43. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/templates/.vscode/settings.json +0 -0
  44. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/templates/10-build.sh +0 -0
  45. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/templates/20-run.sh +0 -0
  46. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker/templates/entrypoint_deployv.sh +0 -0
  47. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker.egg-info/dependency_links.txt +0 -0
  48. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker.egg-info/entry_points.txt +0 -0
  49. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker.egg-info/not-zip-safe +0 -0
  50. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker.egg-info/requires.txt +0 -0
  51. {travis2docker-7.0.2 → travis2docker-7.0.4}/src/travis2docker.egg-info/top_level.txt +0 -0
  52. {travis2docker-7.0.2 → travis2docker-7.0.4}/tox.ini +0 -0
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 7.0.2
2
+ current_version = 7.0.4
3
3
  commit = True
4
4
  tag = True
5
5
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: travis2docker
3
- Version: 7.0.2
3
+ Version: 7.0.4
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
@@ -88,30 +88,54 @@ from its values as ``DOCKER_IMAGE_REPO:MAIN_APP-VERSION-SHA_SHORT``; use
88
88
  ``--docker-image=quay.io/vauxoo/PROJECT:TAG`` to pick the image pushed by the
89
89
  ``build_docker`` pipeline instead.
90
90
 
91
- Optional tools (``--build-env-args``)
92
- =====================================
91
+ Optional build steps (``--build-env-args``)
92
+ ===========================================
93
93
 
94
- Some development tools are **not** installed by default. They are enabled with
95
- a flag passed as a build environment variable using ``--build-env-args``, which
96
- generates an ``ENV <FLAG>=TRUE`` line in the Dockerfile. If the flag is not
97
- defined, the installation step is skipped.
94
+ Some development tools and build steps are **not** enabled by default. They are
95
+ enabled with a flag passed as a build environment variable using
96
+ ``--build-env-args``, which generates an ``ENV <FLAG>=TRUE`` line in the
97
+ Dockerfile. If the flag is not defined, the step is skipped.
98
98
 
99
99
  .. list-table::
100
100
  :widths: 30 70
101
101
  :header-rows: 1
102
102
 
103
103
  * - Flag
104
- - Installs
104
+ - Enables
105
105
  * - ``VIM_INSTALL``
106
106
  - vim + spf13-vim, vim-openerp, jedi-vim, wakatime and the pylint_odoo/eslint syntastic configuration
107
107
  * - ``ZSH_INSTALL``
108
108
  - zsh + oh-my-zsh with the ``odoo-shippable`` theme
109
+ * - ``CHOWN_UID_GID``
110
+ - Aligns the odoo user UID/GID to 5410 to match OrchestSH images. Slow: it re-chowns the whole filesystem
109
111
 
110
112
  Example enabling more than one::
111
113
 
112
114
  travisfile2dockerfile --build-env-args VIM_INSTALL ZSH_INSTALL \
113
115
  git@github.com:Vauxoo/forecast.git 8.0
114
116
 
117
+ VS Code support (``DEPLOYV_VSCODE``)
118
+ ====================================
119
+
120
+ Opt-in with the environment variable ``DEPLOYV_VSCODE=1``::
121
+
122
+ DEPLOYV_VSCODE=1 travisfile2dockerfile git@github.com:Vauxoo/forecast.git 8.0
123
+
124
+ It is disabled by default so vim/terminal users do not pay the extra build
125
+ time. When enabled:
126
+
127
+ - The Dockerfile pre-installs the VS Code server and the extensions listed in
128
+ ``templates/.vscode/extensions.json`` at **build** time, so attaching VS Code
129
+ to the container does not download anything live. The server version is
130
+ pinned to the commit of your local ``code`` binary when available (run
131
+ ``travisfile2dockerfile`` again after upgrading VS Code to re-pin it);
132
+ otherwise the latest stable server is used. If the pinned server does not
133
+ match your client, VS Code just falls back to downloading its own version;
134
+ the pre-installed extensions are version-independent and are reused anyway.
135
+ - A ``.devcontainer.json`` is generated next to the Dockerfile pointing to the
136
+ image built by ``10-build.sh``, so opening that folder in VS Code offers
137
+ "Reopen in Container" automatically.
138
+
115
139
  codebase-memory-deployv
116
140
  =======================
117
141
 
@@ -96,30 +96,54 @@ from its values as ``DOCKER_IMAGE_REPO:MAIN_APP-VERSION-SHA_SHORT``; use
96
96
  ``--docker-image=quay.io/vauxoo/PROJECT:TAG`` to pick the image pushed by the
97
97
  ``build_docker`` pipeline instead.
98
98
 
99
- Optional tools (``--build-env-args``)
100
- =====================================
99
+ Optional build steps (``--build-env-args``)
100
+ ===========================================
101
101
 
102
- Some development tools are **not** installed by default. They are enabled with
103
- a flag passed as a build environment variable using ``--build-env-args``, which
104
- generates an ``ENV <FLAG>=TRUE`` line in the Dockerfile. If the flag is not
105
- defined, the installation step is skipped.
102
+ Some development tools and build steps are **not** enabled by default. They are
103
+ enabled with a flag passed as a build environment variable using
104
+ ``--build-env-args``, which generates an ``ENV <FLAG>=TRUE`` line in the
105
+ Dockerfile. If the flag is not defined, the step is skipped.
106
106
 
107
107
  .. list-table::
108
108
  :widths: 30 70
109
109
  :header-rows: 1
110
110
 
111
111
  * - Flag
112
- - Installs
112
+ - Enables
113
113
  * - ``VIM_INSTALL``
114
114
  - vim + spf13-vim, vim-openerp, jedi-vim, wakatime and the pylint_odoo/eslint syntastic configuration
115
115
  * - ``ZSH_INSTALL``
116
116
  - zsh + oh-my-zsh with the ``odoo-shippable`` theme
117
+ * - ``CHOWN_UID_GID``
118
+ - Aligns the odoo user UID/GID to 5410 to match OrchestSH images. Slow: it re-chowns the whole filesystem
117
119
 
118
120
  Example enabling more than one::
119
121
 
120
122
  travisfile2dockerfile --build-env-args VIM_INSTALL ZSH_INSTALL \
121
123
  git@github.com:Vauxoo/forecast.git 8.0
122
124
 
125
+ VS Code support (``DEPLOYV_VSCODE``)
126
+ ====================================
127
+
128
+ Opt-in with the environment variable ``DEPLOYV_VSCODE=1``::
129
+
130
+ DEPLOYV_VSCODE=1 travisfile2dockerfile git@github.com:Vauxoo/forecast.git 8.0
131
+
132
+ It is disabled by default so vim/terminal users do not pay the extra build
133
+ time. When enabled:
134
+
135
+ - The Dockerfile pre-installs the VS Code server and the extensions listed in
136
+ ``templates/.vscode/extensions.json`` at **build** time, so attaching VS Code
137
+ to the container does not download anything live. The server version is
138
+ pinned to the commit of your local ``code`` binary when available (run
139
+ ``travisfile2dockerfile`` again after upgrading VS Code to re-pin it);
140
+ otherwise the latest stable server is used. If the pinned server does not
141
+ match your client, VS Code just falls back to downloading its own version;
142
+ the pre-installed extensions are version-independent and are reused anyway.
143
+ - A ``.devcontainer.json`` is generated next to the Dockerfile pointing to the
144
+ image built by ``10-build.sh``, so opening that folder in VS Code offers
145
+ "Reopen in Container" automatically.
146
+
123
147
  codebase-memory-deployv
124
148
  =======================
125
149
 
@@ -26,7 +26,7 @@ project = u'travis2docker'
26
26
  year = '2016'
27
27
  author = u'Vauxoo'
28
28
  copyright = '{0}, {1}'.format(year, author)
29
- version = release = u'7.0.2'
29
+ version = release = u'7.0.4'
30
30
 
31
31
  pygments_style = 'trac'
32
32
  templates_path = ['.']
@@ -13,7 +13,7 @@ def read(*names, **kwargs):
13
13
 
14
14
  setup(
15
15
  name="travis2docker",
16
- version="7.0.2",
16
+ version="7.0.4",
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.4"
@@ -284,6 +284,10 @@ def main(return_result=False):
284
284
  os_kwargs.update({"remotes": remotes, "git_base": git_base})
285
285
  if docker_user:
286
286
  os_kwargs.update({"user": docker_user})
287
+ # Opt-in with DEPLOYV_VSCODE=1: pre-install the VS Code server and extensions in the
288
+ # image and generate a .devcontainer.json. Disabled by default so e.g. vim users
289
+ # do not pay the extra build time downloading VS Code stuff they will never use
290
+ vscode = os.environ.get("DEPLOYV_VSCODE", "").strip().lower() not in ("", "0", "false", "no")
287
291
  t2d = Travis2Docker(
288
292
  work_path=pathlib.Path(root_path) / "script" / GitRun.url2dirname(git_repo) / revision,
289
293
  image=default_docker_image,
@@ -291,6 +295,7 @@ def main(return_result=False):
291
295
  copy_paths=[(pathlib.Path("~/.ssh").expanduser(), "$HOME/.ssh")] + rcfiles,
292
296
  build_env_args=build_env_args,
293
297
  build_extra_steps=args.build_extra_steps,
298
+ vscode=vscode,
294
299
  )
295
300
  t2d.build_extra_params = {
296
301
  "extra_params": build_extra_args,
@@ -41,6 +41,24 @@ RUN . /home/odoo/build.sh && \
41
41
  [ -e /entrypoint ] && mv /entrypoint /deployv_entrypoint ; \
42
42
  mkdir -p /run/sshd
43
43
 
44
+ {% if vscode %}
45
+ # DEPLOYV_VSCODE: pre-install the VS Code server and extensions at build time
46
+ # so attaching VS Code to the container does not download anything live
47
+ RUN arch=$(uname -m) && case "$arch" in x86_64) arch=x64 ;; aarch64|arm64) arch=arm64 ;; esac && \
48
+ tmp_dir=$(mktemp -d) && \
49
+ curl -fsSL "https://update.code.visualstudio.com/{{ vscode_version }}/server-linux-$arch/stable" \
50
+ | tar -xz -C "$tmp_dir" --strip-components=1 && \
51
+ commit=$(sed -n 's/.*"commit": *"\([^"]*\)".*/\1/p' "$tmp_dir/product.json") && \
52
+ mkdir -p /home/odoo/.vscode-server/bin && \
53
+ mv "$tmp_dir" "/home/odoo/.vscode-server/bin/$commit" && \
54
+ "/home/odoo/.vscode-server/bin/$commit/bin/code-server" \
55
+ --extensions-dir /home/odoo/.vscode-server/extensions \
56
+ --user-data-dir /home/odoo/.vscode-server/data \
57
+ {%- for extension in vscode_extensions %}
58
+ --install-extension {{ extension }} \
59
+ {%- endfor %}
60
+ && chown -R {{ user }}:{{ user }} /home/odoo/.vscode-server
61
+ {% endif %}
44
62
  {% for step in build_extra_steps %}
45
63
  RUN {{ step }}
46
64
  {% endfor %}
@@ -94,7 +94,7 @@ install_dev_tools(){
94
94
  # emacs \
95
95
  # byobu \
96
96
  # multitail # Set the terminal with red letters build the docker
97
- sudo -E pip install -q \
97
+ pip install -q \
98
98
  ipython \
99
99
  py-spy \
100
100
  virtualenv \
@@ -115,7 +115,7 @@ install_dev_tools(){
115
115
  # pre install pre-commit-vauxoo?
116
116
  # sudo su odoo -c "git init /tmp/test && cd /tmp/test && pre-commit-vauxoo -f"
117
117
  touch /home/odoo/full_test-requirements.txt
118
- sudo -E pip install -r /home/odoo/full_test-requirements.txt
118
+ pip install -r /home/odoo/full_test-requirements.txt
119
119
 
120
120
  # Install git-delta from .deb since not all Ubuntu versions ship the package
121
121
  GIT_DELTA_VERSION=0.18.2
@@ -220,21 +220,35 @@ set_odoo_ids(){
220
220
  # OrchestSH images (ORCHESTSH=True) use UID/GID 5410 for the odoo user;
221
221
  # older images use 1000/1001. A mismatch causes permission issues when
222
222
  # sharing files across containers, so align both to 5410 when they differ.
223
+ if [ -z ${CHOWN_UID_GID+x} ];
224
+ then
225
+ echo "CHOWN_UID_GID was not defined. Skipping odoo UID/GID alignment. Use t2d parameter --build-env-args=CHOWN_UID_GID to be autoconfigured."
226
+ return 0;
227
+ fi
223
228
  CURRENT_UID=$(id -u odoo)
224
229
  CURRENT_GID=$(id -g odoo)
225
230
  NEW_ID=5410
231
+ if [ "${CURRENT_UID}" = "${NEW_ID}" ] && [ "${CURRENT_GID}" = "${NEW_ID}" ]; then
232
+ echo "odoo UID/GID already set to ${NEW_ID}. Nothing to do."
233
+ return 0;
234
+ fi
226
235
  if [ "${CURRENT_GID}" != "${NEW_ID}" ]; then
227
236
  echo "Changing odoo GID from ${CURRENT_GID} to ${NEW_ID}"
228
237
  groupmod -g "${NEW_ID}" odoo
229
- # groupmod does not re-chown any file
230
- find / -xdev -gid "${CURRENT_GID}" -exec chown -h ":${NEW_ID}" {} + 2>/dev/null || true
231
238
  fi
232
239
  if [ "${CURRENT_UID}" != "${NEW_ID}" ]; then
233
240
  echo "Changing odoo UID from ${CURRENT_UID} to ${NEW_ID}"
234
241
  usermod -u "${NEW_ID}" odoo
235
- # usermod only re-chowns files inside the home directory
236
- find / -xdev -uid "${CURRENT_UID}" -exec chown -h "${NEW_ID}" {} + 2>/dev/null || true
237
242
  fi
243
+ # groupmod does not re-chown any file and usermod only re-chowns files inside
244
+ # the home directory, so the leftovers are re-chowned here. Both predicates are
245
+ # evaluated in a single filesystem traversal using the "," operator: walking the
246
+ # whole filesystem twice is what makes this step slow. The branch whose ID did
247
+ # not change simply re-applies the very same ID, so it is a no-op.
248
+ find / -xdev \
249
+ \( -uid "${CURRENT_UID}" -exec chown -h "${NEW_ID}" {} + \) , \
250
+ \( -gid "${CURRENT_GID}" -exec chown -h ":${NEW_ID}" {} + \) \
251
+ 2>/dev/null || true
238
252
  }
239
253
 
240
254
  configure_vim(){
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "{{ name }}",
3
+ "image": "{{ image }}",
4
+ "remoteUser": "{{ user }}",
5
+ "workspaceFolder": "/home/odoo/instance",
6
+ "customizations": {
7
+ "vscode": {
8
+ "extensions": {{ vscode_extensions | tojson }},
9
+ "settings": {
10
+ "python.analysis.extraPaths": ["/home/odoo/instance/odoo"]
11
+ }
12
+ }
13
+ }
14
+ }
@@ -1,9 +1,11 @@
1
1
  # pylint: disable=useless-object-inheritance,consider-using-with
2
+ import json
2
3
  import logging
3
4
  import pathlib
4
5
  import re
5
6
  import shutil
6
7
  import stat
8
+ import subprocess
7
9
  from tempfile import gettempdir
8
10
 
9
11
  import jinja2
@@ -42,6 +44,20 @@ class Travis2Docker:
42
44
  def chmod_execution(file_path):
43
45
  file_path.chmod(file_path.stat().st_mode | stat.S_IEXEC)
44
46
 
47
+ @staticmethod
48
+ def get_vscode_version():
49
+ """Return "commit:SHA" of the local VS Code client to pre-install the matching
50
+ server into the image, or "latest" if there is no "code" binary available"""
51
+ code_bin = shutil.which("code")
52
+ if code_bin:
53
+ try:
54
+ lines = subprocess.check_output([code_bin, "--version"]).decode("UTF-8").splitlines()
55
+ if len(lines) >= 2 and lines[1].strip():
56
+ return "commit:%s" % lines[1].strip()
57
+ except (subprocess.CalledProcessError, OSError):
58
+ pass
59
+ return "latest"
60
+
45
61
  def __init__(
46
62
  self,
47
63
  image=None,
@@ -52,8 +68,10 @@ class Travis2Docker:
52
68
  copy_paths=None,
53
69
  build_env_args=None,
54
70
  build_extra_steps=None,
71
+ vscode=False,
55
72
  ):
56
73
  self.curr_work_path = None
74
+ self.vscode = vscode
57
75
  self.build_extra_params = {}
58
76
  self.run_extra_params = {}
59
77
  self.build_env_args = build_env_args
@@ -76,6 +94,10 @@ class Travis2Docker:
76
94
  copy_paths.append([templates_dir / ".vscode", "/home/odoo/.vscode"])
77
95
  copy_paths.append([templates_dir / ".coveragerc", "/home/odoo/.coveragerc"])
78
96
  os_kwargs.setdefault("user", "odoo")
97
+ if self.vscode:
98
+ extensions_data = json.loads((templates_dir / ".vscode" / "extensions.json").read_text())
99
+ os_kwargs.setdefault("vscode_extensions", extensions_data["recommendations"])
100
+ os_kwargs.setdefault("vscode_version", self.get_vscode_version())
79
101
  if dockerfile is None:
80
102
  dockerfile = "Dockerfile"
81
103
  if templates_path is None:
@@ -116,16 +138,28 @@ class Travis2Docker:
116
138
  "image": self.image,
117
139
  "build_env_args": self.build_env_args,
118
140
  "build_extra_steps": self.build_extra_steps,
141
+ "vscode": self.vscode,
119
142
  }
120
143
  kwargs.update(self.os_kwargs)
121
144
  with curr_dockerfile.open("w") as f_dockerfile:
122
145
  dockerfile_content = self.dockerfile_template.render(kwargs).strip("\n ")
123
146
  f_dockerfile.write(dockerfile_content)
147
+ if self.vscode:
148
+ self.compute_devcontainer()
124
149
  self.compute_build_scripts()
125
150
  work_paths = [str(self.curr_work_path)]
126
151
  self.curr_work_path = None
127
152
  return work_paths
128
153
 
154
+ def compute_devcontainer(self):
155
+ """Generate a .devcontainer.json so VS Code offers reopening the generated
156
+ image as a Development Container"""
157
+ name = self.os_kwargs.get("repo_project") or self.variables_sh_data.get("main_app", "odoo")
158
+ devcontainer_content = self.jinja_env.get_template("devcontainer.json").render(
159
+ image=self.new_image, name=name, **self.os_kwargs
160
+ )
161
+ (self.curr_work_path / ".devcontainer.json").write_text(devcontainer_content)
162
+
129
163
  def copy_path(self, path):
130
164
  """:param paths list: List of paths to copy"""
131
165
  src = pathlib.Path(path).expanduser()
@@ -135,7 +169,7 @@ class Travis2Docker:
135
169
  if src.is_dir():
136
170
  try:
137
171
  shutil.copytree(src, dest_path)
138
- except shutil.Error: # pylint: disable=except-pass
172
+ except shutil.Error: # ruff: ignore[except-pass]
139
173
  pass # There are permissions errors to copy
140
174
  elif src.is_file():
141
175
  shutil.copy(src, dest_path)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: travis2docker
3
- Version: 7.0.2
3
+ Version: 7.0.4
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
@@ -88,30 +88,54 @@ from its values as ``DOCKER_IMAGE_REPO:MAIN_APP-VERSION-SHA_SHORT``; use
88
88
  ``--docker-image=quay.io/vauxoo/PROJECT:TAG`` to pick the image pushed by the
89
89
  ``build_docker`` pipeline instead.
90
90
 
91
- Optional tools (``--build-env-args``)
92
- =====================================
91
+ Optional build steps (``--build-env-args``)
92
+ ===========================================
93
93
 
94
- Some development tools are **not** installed by default. They are enabled with
95
- a flag passed as a build environment variable using ``--build-env-args``, which
96
- generates an ``ENV <FLAG>=TRUE`` line in the Dockerfile. If the flag is not
97
- defined, the installation step is skipped.
94
+ Some development tools and build steps are **not** enabled by default. They are
95
+ enabled with a flag passed as a build environment variable using
96
+ ``--build-env-args``, which generates an ``ENV <FLAG>=TRUE`` line in the
97
+ Dockerfile. If the flag is not defined, the step is skipped.
98
98
 
99
99
  .. list-table::
100
100
  :widths: 30 70
101
101
  :header-rows: 1
102
102
 
103
103
  * - Flag
104
- - Installs
104
+ - Enables
105
105
  * - ``VIM_INSTALL``
106
106
  - vim + spf13-vim, vim-openerp, jedi-vim, wakatime and the pylint_odoo/eslint syntastic configuration
107
107
  * - ``ZSH_INSTALL``
108
108
  - zsh + oh-my-zsh with the ``odoo-shippable`` theme
109
+ * - ``CHOWN_UID_GID``
110
+ - Aligns the odoo user UID/GID to 5410 to match OrchestSH images. Slow: it re-chowns the whole filesystem
109
111
 
110
112
  Example enabling more than one::
111
113
 
112
114
  travisfile2dockerfile --build-env-args VIM_INSTALL ZSH_INSTALL \
113
115
  git@github.com:Vauxoo/forecast.git 8.0
114
116
 
117
+ VS Code support (``DEPLOYV_VSCODE``)
118
+ ====================================
119
+
120
+ Opt-in with the environment variable ``DEPLOYV_VSCODE=1``::
121
+
122
+ DEPLOYV_VSCODE=1 travisfile2dockerfile git@github.com:Vauxoo/forecast.git 8.0
123
+
124
+ It is disabled by default so vim/terminal users do not pay the extra build
125
+ time. When enabled:
126
+
127
+ - The Dockerfile pre-installs the VS Code server and the extensions listed in
128
+ ``templates/.vscode/extensions.json`` at **build** time, so attaching VS Code
129
+ to the container does not download anything live. The server version is
130
+ pinned to the commit of your local ``code`` binary when available (run
131
+ ``travisfile2dockerfile`` again after upgrading VS Code to re-pin it);
132
+ otherwise the latest stable server is used. If the pinned server does not
133
+ match your client, VS Code just falls back to downloading its own version;
134
+ the pre-installed extensions are version-independent and are reused anyway.
135
+ - A ``.devcontainer.json`` is generated next to the Dockerfile pointing to the
136
+ image built by ``10-build.sh``, so opening that folder in VS Code offers
137
+ "Reopen in Container" automatically.
138
+
115
139
  codebase-memory-deployv
116
140
  =======================
117
141
 
@@ -42,6 +42,7 @@ src/travis2docker/templates/10-build.sh
42
42
  src/travis2docker/templates/20-run.sh
43
43
  src/travis2docker/templates/Dockerfile_deployv
44
44
  src/travis2docker/templates/build.sh
45
+ src/travis2docker/templates/devcontainer.json
45
46
  src/travis2docker/templates/entrypoint_deployv.sh
46
47
  src/travis2docker/templates/.vscode/extensions.json
47
48
  src/travis2docker/templates/.vscode/launch.json
@@ -1,7 +1,9 @@
1
1
  # pylint: disable=consider-using-with
2
2
 
3
+ import json
3
4
  import os
4
5
  import pathlib
6
+ import re
5
7
  import subprocess
6
8
  import sys
7
9
  from shutil import which
@@ -104,6 +106,51 @@ def test_main_deployv(tmp_path, monkeypatch):
104
106
  check_dockerfile_lint(scripts)
105
107
 
106
108
 
109
+ def test_main_deployv_vscode(tmp_path, monkeypatch):
110
+ monkeypatch.chdir(tmp_path)
111
+ monkeypatch.setenv("DEPLOYV_VSCODE", "1")
112
+ repo = create_repo(tmp_path, {"variables.sh": VARIABLES_SH})
113
+ sys.argv = [
114
+ "travis2docker",
115
+ repo,
116
+ "main",
117
+ "--root-path",
118
+ str(tmp_path / "t2d"),
119
+ ]
120
+ scripts = cli_main(return_result=True)
121
+ assert len(scripts) == 1, "Scripts returned should be 1"
122
+ work_path = pathlib.Path(scripts[0])
123
+ dkr_content = (work_path / "Dockerfile").read_text()
124
+ assert "update.code.visualstudio.com" in dkr_content
125
+ assert "/home/odoo/.vscode-server" in dkr_content
126
+ assert "--install-extension ms-python.python" in dkr_content
127
+ devcontainer = json.loads((work_path / ".devcontainer.json").read_text())
128
+ assert devcontainer["name"] == "myproject"
129
+ assert devcontainer["remoteUser"] == "odoo"
130
+ assert devcontainer["workspaceFolder"] == "/home/odoo/instance"
131
+ assert devcontainer["image"].endswith(":main")
132
+ assert "ms-python.python" in devcontainer["customizations"]["vscode"]["extensions"]
133
+ check_dockerfile_lint(scripts)
134
+
135
+
136
+ def test_main_deployv_without_vscode(tmp_path, monkeypatch):
137
+ monkeypatch.chdir(tmp_path)
138
+ monkeypatch.delenv("DEPLOYV_VSCODE", raising=False)
139
+ repo = create_repo(tmp_path, {"variables.sh": VARIABLES_SH})
140
+ sys.argv = [
141
+ "travis2docker",
142
+ repo,
143
+ "main",
144
+ "--root-path",
145
+ str(tmp_path / "t2d"),
146
+ ]
147
+ scripts = cli_main(return_result=True)
148
+ work_path = pathlib.Path(scripts[0])
149
+ dkr_content = (work_path / "Dockerfile").read_text()
150
+ assert ".vscode-server" not in dkr_content
151
+ assert not (work_path / ".devcontainer.json").exists()
152
+
153
+
107
154
  def test_main_docker_image_parameter(tmp_path, monkeypatch):
108
155
  monkeypatch.chdir(tmp_path)
109
156
  repo = create_repo(tmp_path, {"variables.sh": VARIABLES_SH})
@@ -169,3 +216,17 @@ def test_main_without_variables_sh(tmp_path, monkeypatch):
169
216
  ]
170
217
  with pytest.raises(InvalidRepoBranchError):
171
218
  cli_main(return_result=True)
219
+
220
+
221
+ def test_build_sh_pip_without_sudo():
222
+ """build.sh runs as root in the Dockerfile, so pip must not go through sudo:
223
+ sudo resets PATH to its secure_path and images whose python lives outside of
224
+ it (e.g. uv managed /opt/python/current/bin) fail with "sudo: pip: command not found"
225
+ """
226
+ build_sh = pathlib.Path(__file__).resolve().parent.parent / "src" / "travis2docker" / "templates" / "build.sh"
227
+ sudo_pip_lines = [
228
+ line.strip()
229
+ for line in build_sh.read_text().splitlines()
230
+ if not line.strip().startswith("#") and re.search(r"\bsudo\b.*\bpip3?\b", line)
231
+ ]
232
+ assert not sudo_pip_lines, "pip called through sudo in build.sh: %s" % sudo_pip_lines
@@ -1 +0,0 @@
1
- __version__ = "7.0.2"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes