Skip to content

Commit abd198b

Browse files
committed
initial commit
0 parents  commit abd198b

File tree

5 files changed

+189
-0
lines changed

5 files changed

+189
-0
lines changed

.github/workflows/build.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Docker Build Images
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- uses: docker/setup-qemu-action@v1
15+
16+
- uses: docker/setup-buildx-action@v1
17+
18+
- uses: docker/login-action@v1
19+
with:
20+
username: ${{ secrets.DOCKER_USERNAME }}
21+
password: ${{ secrets.DOCKER_PASSWORD }}
22+
23+
- uses: docker/build-push-action@v2
24+
with:
25+
platforms: linux/amd64,linux/arm64,linux/arm/v7
26+
tags: easypi/nfs:latest
27+
push: true
28+
29+
- uses: slackapi/[email protected]
30+
with:
31+
channel-id: github
32+
slack-message: 'docker build "easypi/nfs" ok'
33+
env:
34+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# Dockerfile for nfs
3+
#
4+
5+
FROM debian:bullseye
6+
MAINTAINER EasyPi Software Foundation
7+
8+
RUN set -xe \
9+
&& apt update \
10+
&& apt install -y --no-install-recommends nfs-ganesha nfs-ganesha-vfs tini \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
COPY ./docker-entrypoint.sh /entrypoint.sh
14+
15+
EXPOSE 2049
16+
17+
ENTRYPOINT ["tini", "--"]
18+
CMD ["/entrypoint.sh"]

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
nfs
2+
===
3+
4+
[NFS-Ganesha][1] is an NFSv3,v4,v4.1 fileserver that runs in user mode on most UNIX/Linux systems.
5+
6+
> :warning: ~90 seconds to sync.
7+
8+
```bash
9+
# server
10+
$ mkdir data
11+
$ docker-compose up -d
12+
$ echo hello > data/hello.txt
13+
14+
# client
15+
$ sudo mkdir /mnt/data
16+
$ sudo mount.nfs4 -v 127.0.0.1:/mnt/data
17+
$ cat /mnt/data/hello.txt
18+
```
19+
20+
[1]: https://github.com/nfs-ganesha/nfs-ganesha

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: "3.8"
2+
services:
3+
nfs:
4+
image: easypi/nfs
5+
ports:
6+
- "2049:2049"
7+
volumes:
8+
- ./data:/data
9+
environment:
10+
- EXPORT_ID=0
11+
- EXPORT_PATH=/data
12+
- PSEUDO_PATH=/
13+
privileged: true
14+
restart: unless-stopped

docker-entrypoint.sh

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/bin/bash
2+
#
3+
# https://github.com/janeczku/docker-nfs-ganesha/blob/master/rootfs/opt/start_nfs.sh
4+
#
5+
6+
set -e
7+
8+
# environment variables
9+
10+
: ${EXPORT_PATH:="/data/nfs"}
11+
: ${PSEUDO_PATH:="/"}
12+
: ${EXPORT_ID:=0}
13+
: ${PROTOCOLS:=4}
14+
: ${TRANSPORTS:="UDP, TCP"}
15+
: ${SEC_TYPE:="sys"}
16+
: ${SQUASH_MODE:="No_Root_Squash"}
17+
: ${GRACELESS:=true}
18+
: ${VERBOSITY:="NIV_EVENT"} # NIV_DEBUG, NIV_EVENT, NIV_WARN
19+
20+
: ${GANESHA_CONFIG:="/etc/ganesha/ganesha.conf"}
21+
: ${GANESHA_LOGFILE:="/dev/stdout"}
22+
23+
init_rpc() {
24+
echo "* Starting rpcbind"
25+
if [ ! -x /run/rpcbind ] ; then
26+
install -m755 -g 32 -o 32 -d /run/rpcbind
27+
install -m755 -g 32 -o 32 -d /run/rpc_pipefs/nfs
28+
fi
29+
rpcbind || return 0
30+
rpc.statd -L || return 0
31+
rpc.idmapd || return 0
32+
sleep 1
33+
}
34+
35+
init_dbus() {
36+
echo "* Starting dbus"
37+
if [ ! -x /var/run/dbus ] ; then
38+
install -m755 -g 81 -o 81 -d /var/run/dbus
39+
fi
40+
rm -f /var/run/dbus/*
41+
rm -f /var/run/messagebus.pid
42+
dbus-uuidgen --ensure
43+
dbus-daemon --system --fork
44+
sleep 1
45+
}
46+
47+
# pNFS
48+
# Ganesha by default is configured as pNFS DS.
49+
# A full pNFS cluster consists of multiple DS
50+
# and one MDS (Meta Data server). To implement
51+
# this one needs to deploy multiple Ganesha NFS
52+
# and then configure one of them as MDS:
53+
# GLUSTER { PNFS_MDS = ${WITH_PNFS}; }
54+
55+
bootstrap_config() {
56+
echo "* Writing configuration"
57+
cat <<END >${GANESHA_CONFIG}
58+
59+
NFSV4 {
60+
Graceless = ${GRACELESS};
61+
}
62+
63+
EXPORT {
64+
Export_Id = ${EXPORT_ID};
65+
Path = "${EXPORT_PATH}";
66+
Pseudo = "${PSEUDO_PATH}";
67+
FSAL {
68+
Name = VFS;
69+
}
70+
Access_type = RW;
71+
Disable_ACL = true;
72+
Squash = ${SQUASH_MODE};
73+
Protocols = ${PROTOCOLS};
74+
}
75+
76+
EXPORT_DEFAULTS {
77+
Transports = ${TRANSPORTS};
78+
SecType = ${SEC_TYPE};
79+
}
80+
81+
END
82+
}
83+
84+
sleep 0.5
85+
86+
if [ ! -f ${EXPORT_PATH} ]; then
87+
mkdir -p "${EXPORT_PATH}"
88+
fi
89+
90+
echo "Initializing Ganesha NFS server"
91+
echo "=================================="
92+
echo "export path: ${EXPORT_PATH}"
93+
echo "=================================="
94+
95+
bootstrap_config
96+
init_rpc
97+
init_dbus
98+
99+
echo "Generated NFS-Ganesha config:"
100+
cat ${GANESHA_CONFIG}
101+
102+
echo "* Starting Ganesha-NFS"
103+
exec /usr/bin/ganesha.nfsd -F -L ${GANESHA_LOGFILE} -f ${GANESHA_CONFIG} -N ${VERBOSITY}

0 commit comments

Comments
 (0)