Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use devpi for PyPI cache #41

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions dockerfiles/Dockerfile.devpi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.6-alpine

# Required to compile cffi
RUN apk add --no-cache openssl-dev libffi-dev build-base

RUN pip3 install --no-cache-dir --upgrade devpi-server
RUN devpi-init --serverdir=/devpi

CMD ["devpi-server", "--host=0.0.0.0", "--absolute-urls", "--serverdir=/devpi", "--threads=3"]
18 changes: 18 additions & 0 deletions dockerfiles/docker-compose-devpi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# docker-compose-devpi.yml starts "devpi" service for local cache
version: '3'

volumes:
devpi:

services:

devpi:
build:
context: .
dockerfile: ${PWD}/common/dockerfiles/Dockerfile.devpi
ports:
- "3141:3141"
volumes:
- devpi:/devpi
networks:
readthedocs:
23 changes: 17 additions & 6 deletions dockerfiles/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

DOCKER_COMPOSE = 'common/dockerfiles/docker-compose.yml'
DOCKER_COMPOSE_SEARCH = 'common/dockerfiles/docker-compose-search.yml'
DOCKER_COMPOSE_DEVPI = 'common/dockerfiles/docker-compose-devpi.yml'
DOCKER_COMPOSE_OVERRIDE = 'docker-compose.override.yml'
DOCKER_COMPOSE_COMMAND = f'docker-compose -f {DOCKER_COMPOSE} -f {DOCKER_COMPOSE_OVERRIDE} -f {DOCKER_COMPOSE_SEARCH}'
DOCKER_COMPOSE_COMMAND = f'docker-compose -f {DOCKER_COMPOSE} -f {DOCKER_COMPOSE_OVERRIDE} -f {DOCKER_COMPOSE_SEARCH} -f {DOCKER_COMPOSE_DEVPI}'

@task(help={
'cache': 'Build Docker image using cache (default: False)',
Expand All @@ -27,19 +28,29 @@ def down(c, volumes=False):
c.run(f'{DOCKER_COMPOSE_COMMAND} down', pty=True)

@task
def up(c, no_search=False, init=False, no_reload=False):
def up(c, no_search=False, init=False, no_reload=False, no_devpi=False):
"""Start all the docker containers for a Read the Docs instance"""
# Environment variables
INIT = 'INIT='
DOCKER_NO_RELOAD = 'DOCKER_NO_RELOAD='
if init:
INIT = 'INIT=t'
DOCKER_NO_RELOAD = 'DOCKER_NO_RELOAD='
if no_reload:
DOCKER_NO_RELOAD = 'DOCKER_NO_RELOAD=t'

# Extra YAML files
NO_SEARCH = f'-f {DOCKER_COMPOSE_SEARCH}'
if no_search:
c.run(f'{INIT} {DOCKER_NO_RELOAD} docker-compose -f {DOCKER_COMPOSE} -f {DOCKER_COMPOSE_OVERRIDE} up', pty=True)
else:
c.run(f'{INIT} {DOCKER_NO_RELOAD} {DOCKER_COMPOSE_COMMAND} up', pty=True)
NO_SEARCH = ''
NO_DEVPI = f'-f {DOCKER_COMPOSE_DEVPI}'
if no_devpi:
NO_DEVPI = ''
EXTRAS = ' '.join([
NO_SEARCH,
NO_DEVPI,
])

c.run(f'{INIT} {DOCKER_NO_RELOAD} docker-compose -f {DOCKER_COMPOSE} -f {DOCKER_COMPOSE_OVERRIDE} {EXTRAS} up', pty=True)

@task
def shell(c, running=False, container='web'):
Expand Down