Skip to content
Snippets Groups Projects
Commit 01b63638 authored by Andri Joos's avatar Andri Joos :blush:
Browse files

add new image

parent 3e92ef61
No related branches found
No related tags found
No related merge requests found
include:
- project: docker-images/templates
ref: master
file: images.gitlab-ci.yml
build_nfs_image:
extends: .build_image_job_template
variables:
IMAGE_BASENAME: andrijoos/nfs-alpine
IMAGE_NAME: ${IMAGE_BASENAME}:3.20.3,${IMAGE_BASENAME}:3.20,${IMAGE_BASENAME}:3,${IMAGE_BASENAME}:latest
IMAGE_SERVER: ""
DOCKER_LOGIN_CMD: docker login --username ${DOCKER_HUB_USERNAME} --password ${DOCKER_HUB_ACCESS_TOKEN}
DOCKER_LOGOUT_CMD: docker logout
#alpine:3.15 has an issue with rpc, default: alpine:3.9.2
FROM alpine:3.9.2
# COPY Dockerfile README.md /
FROM alpine:3.20.3
RUN apk add --no-cache --update --verbose nfs-utils bash iproute2 && \
rm -rf /var/cache/apk /tmp /sbin/halt /sbin/poweroff /sbin/reboot && \
mkdir -p /var/lib/nfs/rpc_pipefs /var/lib/nfs/v4recovery && \
echo "rpc_pipefs /var/lib/nfs/rpc_pipefs rpc_pipefs defaults 0 0" >> /etc/fstab && \
echo "nfsd /proc/fs/nfsd nfsd defaults 0 0" >> /etc/fstab
ADD nfsd.sh /
COPY exports /etc/
COPY nfsd.sh /usr/bin/nfsd.sh
# COPY .bashrc /root/.bashrc
RUN apk add --no-cache openrc nfs-utils bash \
&& mkdir -p /var/lib/nfs/rpc_pipefs \
&& mkdir -p /var/lib/nfs/v4recovery \
&& echo "nfsd /proc/fs/nfsd nfsd defaults 0 0" >> /etc/fstab \
&& echo "rpc_pipefs /var/lib/nfs/rpc_pipefs rpc_pipefs defaults 0 0" >> /etc/fstab \
&& chmod +x /nfsd.sh
RUN chmod +x /usr/bin/nfsd.sh
ENTRYPOINT ["/usr/bin/nfsd.sh"]
ENTRYPOINT [ "/nfsd.sh" ]
{{SHARED_DIRECTORY}} {{PERMITTED}}({{READ_ONLY}},fsid=0,{{SYNC}},no_subtree_check,no_auth_nlm,insecure,no_root_squash)
......@@ -20,6 +20,8 @@ stop()
exit
}
echo "{{SHARED_DIRECTORY}} {{PERMITTED}}(rw,fsid=0,no_subtree_check,no_auth_nlm,insecure,no_root_squash)" >> /etc/exports
# Check if the SHARED_DIRECTORY variable is empty
if [ -z "${SHARED_DIRECTORY}" ]; then
echo "The SHARED_DIRECTORY environment variable is unset or null, exiting..."
......@@ -29,18 +31,6 @@ else
/bin/sed -i "s@{{SHARED_DIRECTORY}}@${SHARED_DIRECTORY}@g" /etc/exports
fi
# This is here to demonsrate how multiple directories can be shared. You
# would need a block like this for each extra share.
# Any additional shares MUST be subdirectories of the root directory specified
# by SHARED_DIRECTORY.
# Check if the SHARED_DIRECTORY_2 variable is empty
if [ ! -z "${SHARED_DIRECTORY_2}" ]; then
echo "Writing SHARED_DIRECTORY_2 to /etc/exports file"
echo "{{SHARED_DIRECTORY_2}} {{PERMITTED}}({{READ_ONLY}},{{SYNC}},no_subtree_check,no_auth_nlm,insecure,no_root_squash)" >> /etc/exports
/bin/sed -i "s@{{SHARED_DIRECTORY_2}}@${SHARED_DIRECTORY_2}@g" /etc/exports
fi
# Check if the PERMITTED variable is empty
if [ -z "${PERMITTED}" ]; then
echo "The PERMITTED environment variable is unset or null, defaulting to '*'."
......@@ -52,28 +42,6 @@ else
/bin/sed -i "s/{{PERMITTED}}/"${PERMITTED}"/g" /etc/exports
fi
# Check if the READ_ONLY variable is set (rather than a null string) using parameter expansion
if [ -z ${READ_ONLY+y} ]; then
echo "The READ_ONLY environment variable is unset or null, defaulting to 'rw'."
echo "Clients have read/write access."
/bin/sed -i "s/{{READ_ONLY}}/rw/g" /etc/exports
else
echo "The READ_ONLY environment variable is set."
echo "Clients will have read-only access."
/bin/sed -i "s/{{READ_ONLY}}/ro/g" /etc/exports
fi
# Check if the SYNC variable is set (rather than a null string) using parameter expansion
if [ -z "${SYNC+y}" ]; then
echo "The SYNC environment variable is unset or null, defaulting to 'async' mode".
echo "Writes will not be immediately written to disk."
/bin/sed -i "s/{{SYNC}}/async/g" /etc/exports
else
echo "The SYNC environment variable is set, using 'sync' mode".
echo "Writes will be immediately written to disk."
/bin/sed -i "s/{{SYNC}}/sync/g" /etc/exports
fi
# Partially set 'unofficial Bash Strict Mode' as described here: http://redsymbol.net/articles/unofficial-bash-strict-mode/
# We don't set -e because the pidof command returns an exit code of 1 when the specified process is not found
# We expect this at times and don't want the script to be terminated when it occurs
......@@ -105,7 +73,7 @@ while true; do
# /usr/sbin/rpc.statd
echo "Starting NFS in the background..."
/usr/sbin/rpc.nfsd --debug 8 --no-udp --no-nfs-version 2 --no-nfs-version 3
/usr/sbin/rpc.nfsd --debug 8 --no-nfs-version 3
echo "Exporting File System..."
if /usr/sbin/exportfs -rv; then
/usr/sbin/exportfs
......@@ -113,9 +81,8 @@ while true; do
echo "Export validation failed, exiting..."
exit 1
fi
echo "Starting Mountd in the background..."These
/usr/sbin/rpc.mountd --debug all --no-udp --no-nfs-version 2 --no-nfs-version 3
# --exports-file /etc/exports
echo "Starting Mountd in the background..."
/usr/sbin/rpc.mountd --debug all --no-nfs-version 2 --no-nfs-version 3
# Check if NFS is now running by recording it's PID (if it's not running $pid will be null):
pid=`pidof rpc.mountd`
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment