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

proxying pip (HTTPS/SSL) #23

Open
hoijui opened this issue Oct 1, 2017 · 2 comments
Open

proxying pip (HTTPS/SSL) #23

hoijui opened this issue Oct 1, 2017 · 2 comments

Comments

@hoijui
Copy link
Contributor

hoijui commented Oct 1, 2017

As a reference to others (and possibly myself), i explain how it worked for me.

i run this docker (docker-proxy) like this:

sudo docker build -t docker-proxy .
./run.sh ssl

Then i copy test/detect-proxy.sh to the root directory of my own docker containers sources.

My own docker containers Dockerfile looks like this:

# Base image
FROM python:2-slim

MAINTAINER me <[email protected]>

WORKDIR /src

# We need info about available system packages
RUN apt-get update

# These are required by detect-proxy.sh
RUN apt-get install -y --no-install-recommends ca-certificates net-tools netcat

ADD ./detect-proxy.sh /src/detect-proxy.sh
RUN /src/detect-proxy.sh

# These are required by one of our python dependencies
RUN apt-get install -y gcc libreadline-dev

# Install python requirements
# ... option 1 (final solution):
ADD ./requirements.txt /src/requirements.txt
RUN pip --cert /etc/ssl/certs/ca-certificates.crt install -r requirements.txt
# option 2 (may make sense during development):
RUN pip --cert /etc/ssl/certs/ca-certificates.crt install numpy
RUN pip --cert /etc/ssl/certs/ca-certificates.crt install enum34

# Execute the python script
CMD ["python", "/src/my_script.py"]

This way, all downloads (at least by apt-get and pip) done while building and running the docker,
go through the proxy.
One thing that might be clear anyway, but worth to note: The proxy cache is lost whenever we shut the docker-proxy container down (with Ctrl+C).

Is there a way to prevent that? In other words, can we keep/carry over proxy cache between different runs of ./run.sh?

@silarsis
Copy link
Owner

silarsis commented Oct 1, 2017

You can but it's a bit of stuffing around - essentially the squid cache directory would need to be externalised - either to local disk or to another container. ISTR I did that early on in the piece, then removed it later because it was too many moving parts.

@tomhatzer
Copy link

@hoijui you could also save the cache into a volume by providing the following parameters to docker run: --volume /srv/docker/squid/cache:/var/spool/squid3 (customize the cache path with your preferred local path)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants