Skip to content

Commit dfc1784

Browse files
authored
Invoke: docker.compilebuildtool command (#182)
* Invoke: `docker.compilebuildtool` command Simplify how we pre-compile `build.tools` on development. * Import the variable from Read the Docs * Suggestions from review * Use the `constants_docker.py` file for this
1 parent 9932d8a commit dfc1784

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

dockerfiles/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# requirements file to launch Read the Docs using docker-compose
22
invoke==1.7.1
3+
awscli==1.29.7

dockerfiles/tasks.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,32 @@ def translations(c, action):
198198
c.run(f'{DOCKER_COMPOSE_COMMAND} run --rm web /bin/bash -c "cd readthedocs/ && python3 ../manage.py makemessages --locale en"', pty=True)
199199
c.run(f'{DOCKER_COMPOSE_COMMAND} run --rm web ./tx --token {transifex_token} push --source', pty=True)
200200
c.run(f'{DOCKER_COMPOSE_COMMAND} run --rm web /bin/bash -c "cd readthedocs/ && python3 ../manage.py compilemessages --locale en"', pty=True)
201+
202+
203+
@task(help={
204+
'tool': 'build.tool to compile (python, nodejs, rust, golang)',
205+
'version': 'specific version for the tool',
206+
'os': 'ubuntu-20.04 or ubuntu-22.04 (default)',
207+
})
208+
def compilebuildtool(c, tool, version, os='ubuntu-22.04'):
209+
"""Compile a ``build.tools`` to be able to use that tool/version from a build in a quick way."""
210+
from readthedocs.builds.constants_docker import RTD_DOCKER_BUILD_SETTINGS
211+
212+
valid_oss = RTD_DOCKER_BUILD_SETTINGS['os'].keys()
213+
if os not in valid_oss:
214+
print(f'Invalid os. You must specify one of {", ".join(valid_oss)}')
215+
sys.exit(1)
216+
217+
valid_tools = RTD_DOCKER_BUILD_SETTINGS['tools'].keys()
218+
if tool not in valid_tools:
219+
print(f'Invalid tool. You must specify one of {", ".join(valid_tools)}')
220+
sys.exit(1)
221+
222+
valid_versions = RTD_DOCKER_BUILD_SETTINGS['tools'][tool].keys()
223+
if version not in valid_versions:
224+
print(f'Invalid version for the specified tool. You must specify one of {", ".join(valid_versions)}')
225+
sys.exit(1)
226+
227+
final_version = RTD_DOCKER_BUILD_SETTINGS['tools'][tool][version]
228+
229+
c.run(f'OS={os} ./scripts/compile_version_upload_s3.sh {tool} {final_version}')

0 commit comments

Comments
 (0)