2018-06-28 23:39:02 +00:00
|
|
|
# We start from my nginx fork which includes the proxy-connect module from tEngine
|
|
|
|
# Source is available at https://github.com/rpardini/nginx-proxy-connect-stable-alpine
|
2020-10-07 23:57:49 +00:00
|
|
|
# This is already multi-arch!
|
2020-10-30 11:31:52 +00:00
|
|
|
ARG BASE_IMAGE="rpardini/nginx-proxy-connect-stable-alpine:nginx-1.18.0-alpine-3.12.1"
|
2020-10-07 23:57:49 +00:00
|
|
|
# Could be "-debug"
|
|
|
|
ARG BASE_IMAGE_SUFFIX=""
|
|
|
|
FROM ${BASE_IMAGE}${BASE_IMAGE_SUFFIX}
|
|
|
|
|
2020-10-30 12:24:08 +00:00
|
|
|
# Link image to original repository on GitHub
|
|
|
|
LABEL org.opencontainers.image.source https://github.com/rpardini/docker-registry-proxy
|
|
|
|
|
2020-10-07 23:57:49 +00:00
|
|
|
# apk packages that will be present in the final image both debug and release
|
|
|
|
RUN apk add --no-cache --update bash ca-certificates-bundle coreutils openssl
|
2020-06-08 12:49:21 +00:00
|
|
|
|
|
|
|
# If set to 1, enables building mitmproxy, which helps a lot in debugging, but is super heavy to build.
|
|
|
|
ARG DEBUG_BUILD="1"
|
|
|
|
ENV DO_DEBUG_BUILD="$DEBUG_BUILD"
|
2018-06-27 11:08:09 +00:00
|
|
|
|
2020-10-07 23:57:49 +00:00
|
|
|
# Build mitmproxy via pip. This is heavy, takes minutes do build and creates a 90mb+ layer. Oh well.
|
2020-09-22 08:15:15 +00:00
|
|
|
RUN [[ "a$DO_DEBUG_BUILD" == "a1" ]] && { echo "Debug build ENABLED." \
|
2020-10-08 00:32:00 +00:00
|
|
|
&& apk add --no-cache --update su-exec git g++ libffi libffi-dev libstdc++ openssl-dev python3 python3-dev py3-pip py3-wheel py3-six py3-idna py3-certifi py3-setuptools \
|
2020-10-30 11:02:56 +00:00
|
|
|
&& LDFLAGS=-L/lib pip install mitmproxy==5.2 \
|
2020-10-07 23:57:49 +00:00
|
|
|
&& apk del --purge git g++ libffi-dev openssl-dev python3-dev py3-pip py3-wheel \
|
2020-06-08 12:49:21 +00:00
|
|
|
&& rm -rf ~/.cache/pip \
|
2020-10-07 23:57:49 +00:00
|
|
|
; } || { echo "Debug build disabled." ; }
|
2018-11-04 10:23:52 +00:00
|
|
|
|
|
|
|
# Required for mitmproxy
|
|
|
|
ENV LANG=en_US.UTF-8
|
|
|
|
|
2020-06-08 12:49:21 +00:00
|
|
|
# Check the installed mitmproxy version, if built.
|
2020-10-08 00:45:49 +00:00
|
|
|
RUN [[ "a$DO_DEBUG_BUILD" == "a1" ]] && { mitmproxy --version && mitmweb --version ; } || { echo "Debug build disabled."; }
|
2018-06-27 11:08:09 +00:00
|
|
|
|
2018-06-28 23:39:02 +00:00
|
|
|
# Create the cache directory and CA directory
|
|
|
|
RUN mkdir -p /docker_mirror_cache /ca
|
2018-06-27 11:08:09 +00:00
|
|
|
|
|
|
|
# Expose it as a volume, so cache can be kept external to the Docker image
|
|
|
|
VOLUME /docker_mirror_cache
|
|
|
|
|
2018-06-28 23:39:02 +00:00
|
|
|
# Expose /ca as a volume. Users are supposed to volume mount this, as to preserve it across restarts.
|
|
|
|
# Actually, its required; if not, then docker clients will reject the CA certificate when the proxy is run the second time
|
|
|
|
VOLUME /ca
|
|
|
|
|
2018-06-27 11:08:09 +00:00
|
|
|
# Add our configuration
|
|
|
|
ADD nginx.conf /etc/nginx/nginx.conf
|
|
|
|
|
2018-06-28 23:39:02 +00:00
|
|
|
# Add our very hackish entrypoint and ca-building scripts, make them executable
|
|
|
|
ADD entrypoint.sh /entrypoint.sh
|
|
|
|
ADD create_ca_cert.sh /create_ca_cert.sh
|
|
|
|
RUN chmod +x /create_ca_cert.sh /entrypoint.sh
|
|
|
|
|
|
|
|
# Clients should only use 3128, not anything else.
|
|
|
|
EXPOSE 3128
|
|
|
|
|
2020-10-29 23:20:18 +00:00
|
|
|
# In debug mode, 8081 exposes the mitmweb interface (for incoming requests from Docker clients)
|
2018-11-04 10:23:52 +00:00
|
|
|
EXPOSE 8081
|
2020-10-29 23:20:18 +00:00
|
|
|
# In debug-hub mode, 8082 exposes the mitmweb interface (for outgoing requests to DockerHub)
|
|
|
|
EXPOSE 8082
|
2018-11-04 10:23:52 +00:00
|
|
|
|
2018-06-28 23:39:02 +00:00
|
|
|
## Default envs.
|
|
|
|
# A space delimited list of registries we should proxy and cache; this is in addition to the central DockerHub.
|
|
|
|
ENV REGISTRIES="k8s.gcr.io gcr.io quay.io"
|
|
|
|
# A space delimited list of registry:user:password to inject authentication for
|
|
|
|
ENV AUTH_REGISTRIES="some.authenticated.registry:oneuser:onepassword another.registry:user:password"
|
|
|
|
# Should we verify upstream's certificates? Default to true.
|
|
|
|
ENV VERIFY_SSL="true"
|
2018-11-04 10:23:52 +00:00
|
|
|
# Enable debugging mode; this inserts mitmproxy/mitmweb between the CONNECT proxy and the caching layer
|
2019-01-16 19:53:45 +00:00
|
|
|
ENV DEBUG="false"
|
2020-10-29 23:20:18 +00:00
|
|
|
# Enable debugging mode; this inserts mitmproxy/mitmweb between the caching layer and DockerHub's registry
|
|
|
|
ENV DEBUG_HUB="false"
|
2018-11-04 15:43:53 +00:00
|
|
|
# Enable nginx debugging mode; this uses nginx-debug binary and enabled debug logging, which is VERY verbose so separate setting
|
|
|
|
ENV DEBUG_NGINX="false"
|
2018-06-28 23:39:02 +00:00
|
|
|
|
2018-11-04 15:43:53 +00:00
|
|
|
# Did you want a shell? Sorry, the entrypoint never returns, because it runs nginx itself. Use 'docker exec' if you need to mess around internally.
|
2020-06-08 12:49:21 +00:00
|
|
|
ENTRYPOINT ["/entrypoint.sh"]
|