-
Notifications
You must be signed in to change notification settings - Fork 16
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
Singularity container for a Squid proxy #36
Open
bedroge
wants to merge
15
commits into
EESSI:main
Choose a base branch
from
bedroge:cvmfs_proxy_singularity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b73689d
example for using fuse-overlayfs in singularity
bedroge 7e2bbc4
rename README
bedroge 5c4199a
add more attempts
bedroge 41b5c28
fixes
bedroge 8efc316
config repo *must* be mounted at /cvmfs/cvmfs-config.eessi-hpc.org, b…
boegel 71e1b14
Merge pull request #1 from boegel/singularity_cvmfs_overlay
bedroge 7906eec
Ignore sif files
bedroge 468f4a3
Add CVMFS config deb package
bedroge a2b5163
Modified instructions and def file, better method
bedroge e1d611d
CVMFS Squid proxy as Singularity container
bedroge ebc4090
Update README.md
bedroge b145662
Update README.md
bedroge d150755
Remove stuff that shouldn't be here...
bedroge bdbed99
Merge branch 'cvmfs_proxy_singularity' of github.com:bedroge/filesyst…
bedroge d23d031
Small fix in README
bedroge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
BootStrap: docker | ||
From: centos:7 | ||
|
||
%post | ||
yum update -y | ||
yum install -y squid which | ||
|
||
%environment | ||
export LC_ALL=C | ||
|
||
%runscript | ||
if [[ ${1:0:1} = '-' ]]; then | ||
EXTRA_ARGS="$@" | ||
set -- | ||
elif [[ ${1} == squid || ${1} == $(which squid) ]]; then | ||
EXTRA_ARGS="${@:2}" | ||
set -- | ||
fi | ||
|
||
if [[ -z ${1} ]]; then | ||
if [[ ! -d /var/spool/squid/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 | ||
|
||
%startscript | ||
if [[ ${1:0:1} = '-' ]]; then | ||
EXTRA_ARGS="$@" | ||
set -- | ||
elif [[ ${1} == squid || ${1} == $(which squid) ]]; then | ||
EXTRA_ARGS="${@:2}" | ||
set -- | ||
fi | ||
|
||
if [[ -z ${1} ]]; then | ||
if [[ ! -d /var/spool/squid/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Containers | ||
This directory contains several Dockerfiles and Singularity definition files for different components, | ||
e.g. CVMFS clients and Squid proxies. | ||
|
||
## EESSI-squid-proxy.def: Singularity definition file for Squid proxy | ||
|
||
This definition file allows you to build a Singularity container that can be used for running a Squid proxy. | ||
|
||
### Build | ||
You can build the container using: | ||
``` | ||
sudo singularity build EESSI-squid-proxy.sif EESSI-squid-proxy.def | ||
``` | ||
### Configure | ||
Make some directories on the host for storing the cache, logs, and PID file: | ||
``` | ||
mkdir -p /tmp/$USER/{var-log-squid,var-run,var-spool-squid,home} | ||
``` | ||
|
||
Prepare a Squid configuration file, for instance based on our [Ansible template file](https://github.com/EESSI/filesystem-layer/blob/master/templates/eessi_localproxy_squid.conf.j2). Make sure that the ACLs and port number are configured correctly. | ||
|
||
Set the following environment variables to the correct local directories and configuration file: | ||
``` | ||
export SINGULARITY_BIND="eessi_localproxy_squid.conf:/etc/squid/squid.conf,/tmp/$USER/var-run:/var/run,/tmp/$USER/var-log-squid:/var/log/squid,/tmp/$USER/var-spool-squid:/var/spool/squid" | ||
export SINGULARITY_HOME="/tmp/$USER/home:/home/$USER" | ||
``` | ||
|
||
### Run | ||
|
||
Now start the container as a Singularity instance (which will run it like a service in the background): | ||
``` | ||
singularity instance start EESSI-squid-proxy.sif cvmfs_proxy | ||
``` | ||
|
||
The last argument defines the name for this instance, which can be used to connect a shell (`singularity shell instance://cvmfs_proxy`) or to stop the instance: | ||
``` | ||
singularity instance stop cvmfs_proxy | ||
``` | ||
|
||
If you want to interactively start the proxy, you can still do this using: | ||
``` | ||
singularity run EESSI-squid-proxy.sif | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bedroge Wouldn't it make more sense to make this a Dockerfile, so we can build the Docker image and push it to Docker Hub (and then we can also run it via Singularity)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! I'll convert it to a Dockerfile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One disadvantage is that you can't use
singularity instance
with a Docker image, sincestartscript
is not defined in that case...