mirror of
https://github.com/b4tman/docker-squid.git
synced 2024-11-22 11:16:55 +00:00
multi-stage build
This commit is contained in:
commit
393e77b80d
99
Dockerfile
99
Dockerfile
@ -1,29 +1,13 @@
|
||||
FROM alpine:3.6
|
||||
MAINTAINER b4tman <b4tm4n@mail.ru>
|
||||
FROM alpine:3.6 as build
|
||||
|
||||
ENV SQUID_VER 4.0.21
|
||||
ENV SQUID_SIG_KEY B06884EDB779C89B044E64E3CD6DBF8EF3B17D3E
|
||||
ENV SQUID_CONFIG_FILE /etc/squid/squid.conf
|
||||
ENV TZ Europe/Moscow
|
||||
|
||||
RUN set -x && \
|
||||
deluser squid 2>/dev/null; delgroup squid 2>/dev/null; \
|
||||
addgroup -S squid -g 3128 && adduser -S -u 3128 -G squid -g squid -H -D -s /bin/false -h /var/cache/squid squid
|
||||
|
||||
RUN apk add --no-cache \
|
||||
libstdc++ \
|
||||
libcap \
|
||||
libressl2.5-libcrypto \
|
||||
libressl2.5-libssl \
|
||||
libltdl
|
||||
|
||||
RUN set -x && \
|
||||
apk add --no-cache --virtual .build-deps \
|
||||
apk add --no-cache \
|
||||
gcc \
|
||||
g++ \
|
||||
libc-dev \
|
||||
alpine-conf \
|
||||
tzdata \
|
||||
curl \
|
||||
gnupg \
|
||||
libressl-dev \
|
||||
@ -35,21 +19,29 @@ RUN set -x && \
|
||||
heimdal-dev \
|
||||
libtool \
|
||||
libcap-dev \
|
||||
linux-headers && \
|
||||
\
|
||||
linux-headers
|
||||
|
||||
RUN set -x && \
|
||||
mkdir -p /tmp/build && \
|
||||
cd /tmp/build && \
|
||||
curl -SsL http://www.squid-cache.org/Versions/v${SQUID_VER%.*.*}/squid-${SQUID_VER}.tar.gz -o squid-${SQUID_VER}.tar.gz && \
|
||||
curl -SsL http://www.squid-cache.org/Versions/v${SQUID_VER%.*.*}/squid-${SQUID_VER}.tar.gz.asc -o squid-${SQUID_VER}.tar.gz.asc && \
|
||||
\
|
||||
curl -SsL http://www.squid-cache.org/Versions/v${SQUID_VER%.*.*}/${SQUID_VER%.*}/squid-${SQUID_VER}.tar.gz -o squid-${SQUID_VER}.tar.gz && \
|
||||
curl -SsL http://www.squid-cache.org/Versions/v${SQUID_VER%.*.*}/${SQUID_VER%.*}/squid-${SQUID_VER}.tar.gz.asc -o squid-${SQUID_VER}.tar.gz.asc
|
||||
|
||||
RUN set -x && \
|
||||
cd /tmp/build && \
|
||||
export GNUPGHOME="$(mktemp -d)" && \
|
||||
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys ${SQUID_SIG_KEY} && \
|
||||
gpg --batch --verify squid-${SQUID_VER}.tar.gz.asc squid-${SQUID_VER}.tar.gz && \
|
||||
\
|
||||
rm -rf "$GNUPGHOME"
|
||||
|
||||
RUN set -x && \
|
||||
cd /tmp/build && \
|
||||
tar --strip 1 -xzf squid-${SQUID_VER}.tar.gz && \
|
||||
export CFLAGS="-g0 -O2" && \
|
||||
export CXXFLAGS="$CFLAGS" && \
|
||||
export LDFLAGS="-s" && \
|
||||
\
|
||||
CFLAGS="-g0 -O2" \
|
||||
CXXFLAGS="-g0 -O2" \
|
||||
LDFLAGS="-s" \
|
||||
\
|
||||
./configure \
|
||||
--build="$(uname -m)" \
|
||||
--host="$(uname -m)" \
|
||||
@ -95,28 +87,53 @@ RUN set -x && \
|
||||
--with-large-files \
|
||||
--with-default-user=squid \
|
||||
--with-openssl \
|
||||
--with-pidfile=/var/run/squid/squid.pid && \
|
||||
\
|
||||
sed -i -e 's/LOCK_UN/8/g' src/base/File.h && \
|
||||
\
|
||||
make && \
|
||||
make install && \
|
||||
install -d -o squid -g squid \
|
||||
--with-pidfile=/var/run/squid/squid.pid
|
||||
|
||||
RUN sed -i -e 's/LOCK_UN/8/g' /tmp/build/src/base/File.h
|
||||
|
||||
RUN set -x && \
|
||||
cd /tmp/build && \
|
||||
make -j $(grep -cs ^processor /proc/cpuinfo) && \
|
||||
make install
|
||||
|
||||
FROM alpine:3.6
|
||||
MAINTAINER b4tman <b4tm4n@mail.ru>
|
||||
|
||||
ENV SQUID_CONFIG_FILE /etc/squid/squid.conf
|
||||
ENV TZ Europe/Moscow
|
||||
|
||||
RUN set -x && \
|
||||
deluser squid 2>/dev/null; delgroup squid 2>/dev/null; \
|
||||
addgroup -S squid -g 3128 && adduser -S -u 3128 -G squid -g squid -H -D -s /bin/false -h /var/cache/squid squid
|
||||
|
||||
RUN apk add --no-cache \
|
||||
libstdc++ \
|
||||
heimdal-libs \
|
||||
libcap \
|
||||
libressl2.5-libcrypto \
|
||||
libressl2.5-libssl \
|
||||
libltdl
|
||||
|
||||
COPY --from=build /etc/squid/ /etc/squid/
|
||||
COPY --from=build /usr/lib/squid/ /usr/lib/squid/
|
||||
COPY --from=build /usr/share/squid/ /usr/share/squid/
|
||||
COPY --from=build /usr/sbin/squid /usr/sbin/squid
|
||||
|
||||
RUN install -d -o squid -g squid \
|
||||
/var/cache/squid \
|
||||
/var/log/squid \
|
||||
/var/run/squid && \
|
||||
chmod +x /usr/lib/squid/* &&\
|
||||
\
|
||||
/sbin/setup-timezone -z $TZ && \
|
||||
\
|
||||
apk del .build-deps && \
|
||||
cd / && \
|
||||
rm -rf /tmp/build "$GNUPGHOME"
|
||||
chmod +x /usr/lib/squid/*
|
||||
|
||||
RUN echo 'include /etc/squid/conf.d/*.conf' >> "$SQUID_CONFIG_FILE" && \
|
||||
install -d -m 755 -o squid -g squid /etc/squid/conf.d
|
||||
COPY squid-log.conf /etc/squid/conf.d/
|
||||
|
||||
RUN set -x && \
|
||||
apk add --no-cache --virtual .tz alpine-conf tzdata && \
|
||||
/sbin/setup-timezone -z $TZ && \
|
||||
apk del .tz
|
||||
|
||||
VOLUME ["/var/cache/squid"]
|
||||
EXPOSE 3128/tcp
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user