Add Squid Docker images
This commit is contained in:
parent
fcc8f976bd
commit
d32937f263
|
@ -0,0 +1,30 @@
|
|||
# Copyright 2021 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM debian:buster-slim
|
||||
|
||||
ENV SQUID_VERSION=4.6 \
|
||||
SQUID_CACHE_DIR=/var/spool/squid \
|
||||
SQUID_LOG_DIR=/var/log/squid \
|
||||
SQUID_USER=proxy
|
||||
|
||||
RUN apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y squid=${SQUID_VERSION}* \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY entrypoint.sh /sbin/entrypoint.sh
|
||||
RUN chmod 755 /sbin/entrypoint.sh
|
||||
|
||||
EXPOSE 3128/tcp
|
||||
ENTRYPOINT ["/sbin/entrypoint.sh"]
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
# Copyright 2021 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# In this directory, run the following command to build this builder.
|
||||
# $ gcloud builds submit .
|
||||
|
||||
steps:
|
||||
- name: 'gcr.io/cloud-builders/docker'
|
||||
args:
|
||||
- build
|
||||
- --tag=gcr.io/$PROJECT_ID/squid:${_IMAGE_VERSION}
|
||||
- --tag=gcr.io/$PROJECT_ID/squid:latest
|
||||
- .
|
||||
|
||||
substitutions:
|
||||
_IMAGE_VERSION: "20210215"
|
||||
images:
|
||||
- 'gcr.io/$PROJECT_ID/squid:${_IMAGE_VERSION}'
|
||||
- 'gcr.io/$PROJECT_ID/squid:latest'
|
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright 2021 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# This container is based off Sameer Naik's existing squid container.
|
||||
# https://github.com/sameersbn/docker-squid
|
||||
|
||||
set -e
|
||||
|
||||
create_log_dir() {
|
||||
mkdir -p ${SQUID_LOG_DIR}
|
||||
chmod -R 755 ${SQUID_LOG_DIR}
|
||||
chown -R ${SQUID_USER}:${SQUID_USER} ${SQUID_LOG_DIR}
|
||||
}
|
||||
|
||||
create_cache_dir() {
|
||||
mkdir -p ${SQUID_CACHE_DIR}
|
||||
chown -R ${SQUID_USER}:${SQUID_USER} ${SQUID_CACHE_DIR}
|
||||
}
|
||||
|
||||
create_log_dir
|
||||
create_cache_dir
|
||||
|
||||
# allow arguments to be passed to squid
|
||||
if [[ ${1:0:1} = '-' ]]; then
|
||||
EXTRA_ARGS="$@"
|
||||
set --
|
||||
elif [[ ${1} == squid || ${1} == $(which squid) ]]; then
|
||||
EXTRA_ARGS="${@:2}"
|
||||
set --
|
||||
fi
|
||||
|
||||
# default behaviour is to launch squid
|
||||
if [[ -z ${1} ]]; then
|
||||
if [[ ! -d ${SQUID_CACHE_DIR}/00 ]]; then
|
||||
echo "Initializing cache..."
|
||||
$(which squid) -N -f /etc/squid/squid.conf -z
|
||||
fi
|
||||
echo "Starting squid..."
|
||||
exec $(which squid) -f /etc/squid/squid.conf -NYCd 1 ${EXTRA_ARGS}
|
||||
else
|
||||
exec "$@"
|
||||
fi
|
Loading…
Reference in New Issue