1
0
mirror of https://github.com/b4tman/docker-squid.git synced 2024-10-22 14:05:07 +00:00

Compare commits

..

7 Commits

Author SHA1 Message Date
Dmitry Belyaev
244937d517
Merge pull request #93 from b4tman/refactor
refactor Dockerfile
2023-03-01 16:45:36 +03:00
4af565e3ae
build ssl-bump without docker/build-push-action 2023-03-01 16:30:13 +03:00
e4ff285091
build test image with output type=docker 2023-03-01 16:12:06 +03:00
00f78a3728
never pull test image 2023-03-01 15:53:52 +03:00
f8b9da006c
use builded image for test 2023-03-01 15:34:59 +03:00
0db0d2b19d
refactor Dockerfile 2023-03-01 14:30:21 +03:00
dependabot[bot]
23eacf4e57 Bump actions/cache from 3.2.4 to 3.2.6
Bumps [actions/cache](https://github.com/actions/cache) from 3.2.4 to 3.2.6.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v3.2.4...v3.2.6)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-01 10:06:58 +03:00
3 changed files with 46 additions and 57 deletions

View File

@ -15,6 +15,9 @@ on:
branches: branches:
- "master" - "master"
env:
TEST_TAG: b4tman/squid:test
jobs: jobs:
test: test:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@ -35,7 +38,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Cache Docker layers - name: Cache Docker layers
uses: actions/cache@v3.2.4 uses: actions/cache@v3.2.6
with: with:
path: /tmp/.buildx-cache path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }} key: ${{ runner.os }}-buildx-${{ github.sha }}
@ -47,10 +50,10 @@ jobs:
with: with:
context: . context: .
push: false push: false
tags: b4tman/squid load: true # automatically load the single-platform build result to docker images
tags: ${{ env.TEST_TAG }}
cache-from: type=local,src=/tmp/.buildx-cache cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
outputs: type=image,name=b4tman/squid,push=false
# Temp fix # Temp fix
# https://github.com/docker/build-push-action/issues/252 # https://github.com/docker/build-push-action/issues/252
@ -61,25 +64,12 @@ jobs:
mv /tmp/.buildx-cache-new /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Test image - name: Test image
run: docker-compose -f docker-compose.test.yml up sut run: docker compose -f docker-compose.test.yml up --pull never sut
- name: Build 'ssl-bump' image - name: Build 'ssl-bump' image
uses: docker/build-push-action@v4
with:
context: ssl-bump
push: false
file: ssl-bump/Dockerfile
tags: b4tman/squid:ssl-bump
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: | run: |
rm -rf /tmp/.buildx-cache sed -i "s%FROM b4tman/squid%FROM $TEST_TAG%" ssl-bump/Dockerfile
mv /tmp/.buildx-cache-new /tmp/.buildx-cache docker build ssl-bump
push: push:
needs: test needs: test
@ -137,7 +127,7 @@ jobs:
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v2
- name: Cache Docker layers - name: Cache Docker layers
uses: actions/cache@v3.2.4 uses: actions/cache@v3.2.6
with: with:
path: /tmp/.buildx-cache path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }} key: ${{ runner.os }}-buildx-${{ github.sha }}

View File

@ -1,6 +1,6 @@
FROM alpine:3.17.2 as build FROM alpine:3.17.2 as build
ENV SQUID_VER 5.7 ARG SQUID_VER=5.7
RUN set -x && \ RUN set -x && \
apk add --no-cache \ apk add --no-cache \
@ -21,32 +21,33 @@ RUN set -x && \
libcap-dev \ libcap-dev \
linux-headers linux-headers
WORKDIR /tmp/build
RUN set -x && \ 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 -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-${SQUID_VER}.tar.gz.asc -o squid-${SQUID_VER}.tar.gz.asc
COPY squid-keys.asc /tmp COPY squid-keys.asc /tmp/build
RUN set -x && \ RUN set -x && \
cd /tmp/build && \ GNUPGHOME="$(mktemp -d)" && \
export GNUPGHOME="$(mktemp -d)" && \ export GNUPGHOME && \
gpg --import /tmp/squid-keys.asc && \ gpg --import squid-keys.asc && \
gpg --batch --verify squid-${SQUID_VER}.tar.gz.asc squid-${SQUID_VER}.tar.gz && \ gpg --batch --verify squid-${SQUID_VER}.tar.gz.asc squid-${SQUID_VER}.tar.gz && \
rm -rf "$GNUPGHOME" rm -rf "$GNUPGHOME"
RUN set -x && \ RUN set -x && \
cd /tmp/build && \
tar --strip 1 -xzf squid-${SQUID_VER}.tar.gz && \ tar --strip 1 -xzf squid-${SQUID_VER}.tar.gz && \
\ \
MACHINE=$(uname -m) && \
\
CFLAGS="-g0 -O2" \ CFLAGS="-g0 -O2" \
CXXFLAGS="-g0 -O2" \ CXXFLAGS="-g0 -O2" \
LDFLAGS="-s" \ LDFLAGS="-s" \
\ \
./configure \ ./configure \
--build="$(uname -m)" \ --build="$MACHINE" \
--host="$(uname -m)" \ --host="$MACHINE" \
--prefix=/usr \ --prefix=/usr \
--datadir=/usr/share/squid \ --datadir=/usr/share/squid \
--sysconfdir=/etc/squid \ --sysconfdir=/etc/squid \
@ -92,16 +93,18 @@ RUN set -x && \
--with-openssl \ --with-openssl \
--with-pidfile=/var/run/squid/squid.pid --with-pidfile=/var/run/squid/squid.pid
RUN set -x && \ RUN set -x && \
cd /tmp/build && \ nproc=$(n=$(nproc) ; max_n=6 ; echo $(( n <= max_n ? n : max_n )) ) && \
nproc=$(n=$(nproc) ; max_n=6 ; [ $n -le $max_n ] && echo $n || echo $max_n) && \
make -j $nproc && \ make -j $nproc && \
make install && \ make install
cd tools/squidclient && make && make install-strip
RUN sed -i '1s;^;include /etc/squid/conf.d/*.conf\n;' /etc/squid/squid.conf WORKDIR /tmp/build/tools/squidclient
RUN echo 'include /etc/squid/conf.d.tail/*.conf' >> /etc/squid/squid.conf RUN make && make install-strip
RUN sed -i '1s;^;include /etc/squid/conf.d/*.conf\n;' /etc/squid/squid.conf && \
echo 'include /etc/squid/conf.d.tail/*.conf' >> /etc/squid/squid.conf
# --- --- --- --- --- --- --- --- ---
FROM alpine:3.17.2 FROM alpine:3.17.2
@ -124,17 +127,15 @@ COPY --from=build /usr/share/squid/ /usr/share/squid/
COPY --from=build /usr/sbin/squid /usr/sbin/squid COPY --from=build /usr/sbin/squid /usr/sbin/squid
COPY --from=build /usr/bin/squidclient /usr/bin/squidclient COPY --from=build /usr/bin/squidclient /usr/bin/squidclient
RUN install -d -o squid -g squid \ RUN install -d -o squid -g squid \
/var/cache/squid \ /var/cache/squid \
/var/log/squid \ /var/log/squid \
/var/run/squid && \ /var/run/squid && \
chmod +x /usr/lib/squid/* chmod +x /usr/lib/squid/* && \
install -d -m 755 -o squid -g squid \
RUN install -d -m 755 -o squid -g squid \
/etc/squid/conf.d \ /etc/squid/conf.d \
/etc/squid/conf.d.tail /etc/squid/conf.d.tail && \
RUN touch /etc/squid/conf.d/placeholder.conf touch /etc/squid/conf.d/placeholder.conf
COPY squid-log.conf /etc/squid/conf.d.tail/ COPY squid-log.conf /etc/squid/conf.d.tail/
RUN set -x && \ RUN set -x && \

View File

@ -1,10 +1,7 @@
version: '2.3' version: '2.3'
services: services:
proxy: proxy:
image: squidproxy image: "${TEST_TAG}"
build:
context: .
dockerfile: Dockerfile
healthcheck: healthcheck:
test: ["CMD", "sh", "-exc", "squidclient -T 3 mgr:info 2> /dev/null | grep -qF '200 OK'"] test: ["CMD", "sh", "-exc", "squidclient -T 3 mgr:info 2> /dev/null | grep -qF '200 OK'"]
interval: 5s interval: 5s
@ -12,9 +9,10 @@ services:
retries: 5 retries: 5
start_period: 1s start_period: 1s
sut: sut:
image: squidproxy image: "${TEST_TAG}"
links: links:
- proxy - proxy
depends_on: depends_on:
- proxy - proxy
command: sh -exc "sleep 10 && squidclient -h proxy -T 3 'https://postman-echo.com/get?squidtest=ok' 2> /dev/null | grep -qF '200 OK'" command: sh -exc "sleep 10 && squidclient -h proxy -T 3 'https://postman-echo.com/get?squidtest=ok' 2> /dev/null | grep -qF '200 OK'"