Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nfs-image
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker images
nfs-image
Commits
01b63638
Commit
01b63638
authored
6 months ago
by
Andri Joos
Browse files
Options
Downloads
Patches
Plain Diff
add new image
parent
3e92ef61
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+13
-0
13 additions, 0 deletions
.gitlab-ci.yml
Dockerfile
+9
-14
9 additions, 14 deletions
Dockerfile
exports
+0
-1
0 additions, 1 deletion
exports
nfsd.sh
+5
-38
5 additions, 38 deletions
nfsd.sh
with
27 additions
and
53 deletions
.gitlab-ci.yml
0 → 100644
+
13
−
0
View file @
01b63638
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
This diff is collapsed.
Click to expand it.
Dockerfile
+
9
−
14
View file @
01b63638
#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" ]
This diff is collapsed.
Click to expand it.
exports
deleted
100644 → 0
+
0
−
1
View file @
3e92ef61
{{SHARED_DIRECTORY}} {{PERMITTED}}({{READ_ONLY}},fsid=0,{{SYNC}},no_subtree_check,no_auth_nlm,insecure,no_root_squash)
This diff is collapsed.
Click to expand it.
nfsd.sh
+
5
−
38
View file @
01b63638
...
...
@@ -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
`
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment