Skip to content

Commit fd54dfb

Browse files
committed
adding nginx-webdav image
1 parent 69fdc75 commit fd54dfb

File tree

5 files changed

+130
-0
lines changed

5 files changed

+130
-0
lines changed

.github/workflows/nginx-webdav.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: WebDAV
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
paths:
8+
- 'nginx-webdav/**'
9+
10+
jobs:
11+
12+
nginx-webdav:
13+
name: Deploy WebDAV Image
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Publish Docker Image
18+
uses: openzim/docker-publish-action@v10
19+
with:
20+
image-name: kiwix/nginx-webdav
21+
on-master: latest
22+
restrict-to: kiwix/container-images
23+
context: nginx-webdav
24+
registries: ghcr.io
25+
credentials:
26+
GHCRIO_USERNAME=${{ secrets.GHCR_USERNAME }}
27+
GHCRIO_TOKEN=${{ secrets.GHCR_TOKEN }}

nginx-webdav/Dockerfile

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM debian:bookworm-slim
2+
3+
COPY webdav.conf /etc/nginx/conf.d/default.conf
4+
COPY entrypoint.sh /usr/local/bin/entrypoint
5+
6+
RUN \
7+
apt-get update \
8+
&& apt-get upgrade -y \
9+
&& apt-get install -y dumb-init curl \
10+
# nginx and its plugins for webdav and fancyindex
11+
nginx nginx-extras libnginx-mod-http-dav-ext libnginx-mod-http-auth-pam libnginx-mod-http-fancyindex \
12+
# apache2-utils to create htpasswd from ENVIRON in entrypoint
13+
apache2-utils \
14+
&& rm /etc/nginx/sites-enabled/* \
15+
&& mkdir -p /var/www/fancyindex-themes \
16+
# fancyindex them
17+
&& curl -L -o /tmp/theme.tar.gz https://github.com/alehaa/nginx-fancyindex-flat-theme/releases/download/v1.2/nginx-fancyindex-flat-theme-1.2.tar.gz \
18+
&& tar -C /var/www/fancyindex-themes/ --strip-components 1 -x -f /tmp/theme.tar.gz \
19+
# another theme
20+
# && curl -L -o /tmp/theme.tar.gz https://github.com/fraoustin/Nginx-Fancyindex-Theme/archive/refs/tags/0.1.7.tar.gz \
21+
# && tar -C /var/www/fancyindex-themes/ --strip-components 1 -x -f /tmp/theme.tar.gz \
22+
&& mkdir -p "/data" \
23+
&& chown -R www-data:www-data /data \
24+
&& chmod +x /usr/local/bin/entrypoint
25+
26+
WORKDIR /data
27+
VOLUME /data
28+
EXPOSE 80
29+
ENV USERNAME ""
30+
ENV PASSWORD ""
31+
ENV NAME ""
32+
33+
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
34+
CMD ["/usr/local/bin/entrypoint" , "nginx", "-g", "daemon off;"]

nginx-webdav/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# nginx-webdav
2+
3+
Simple nginx image for serving static files over HTTP and managing them using WebDAV using `USERNAME` and `PASSWORD` environ variables. `NAME` variable allows customizing the displayed name/title.

nginx-webdav/entrypoint.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
if [[ -n "$USERNAME_FILE" ]] && [[ -n "$PASSWORD_FILE" ]]
4+
then
5+
USERNAME=$(cat "$USERNAME_FILE")
6+
PASSWORD=$(cat "$PASSWORD_FILE")
7+
fi
8+
9+
if [[ -n "$USERNAME" ]] && [[ -n "$PASSWORD" ]]
10+
then
11+
htpasswd -bc /etc/nginx/htpasswd "$USERNAME" "$PASSWORD"
12+
echo Done.
13+
else
14+
echo Using no auth.
15+
sed -i 's%auth_basic "Restricted";% %g' /etc/nginx/conf.d/default.conf
16+
sed -i 's%auth_basic_user_file /etc/nginx/htpasswd;% %g' /etc/nginx/conf.d/default.conf
17+
fi
18+
19+
if [[ -n "NAME" ]]
20+
then
21+
sed -i "s/ File Browser/${NAME}/g" /var/www/fancyindex-themes/header.html
22+
sed -i "s/ FancyIndex/${NAME}/g" /var/www/fancyindex-themes/header.html
23+
fi
24+
25+
exec "$@"

nginx-webdav/webdav.conf

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
server {
2+
listen 80;
3+
4+
access_log /dev/stdout;
5+
error_log /dev/stdout info;
6+
7+
client_max_body_size 0;
8+
9+
location / {
10+
charset utf-8;
11+
12+
#autoindex on;
13+
#autoindex_exact_size off;
14+
#autoindex_localtime on;
15+
16+
fancyindex on;
17+
fancyindex_exact_size off;
18+
fancyindex_show_path on;
19+
fancyindex_name_length 255;
20+
fancyindex_header "/fancyindex/header.html";
21+
fancyindex_footer "/fancyindex/footer.html";
22+
# fancyindex_css_href /fancyindex/theme.css;
23+
fancyindex_time_format "%B %e, %Y";
24+
25+
location /fancyindex {
26+
alias /var/www/fancyindex-themes;
27+
}
28+
29+
create_full_put_path on;
30+
dav_methods PUT DELETE MKCOL COPY MOVE;
31+
dav_ext_methods PROPFIND OPTIONS;
32+
dav_access user:rw group:rw all:r;
33+
34+
limit_except GET PROPFIND OPTIONS HEAD {
35+
auth_basic "Restricted";
36+
auth_basic_user_file /etc/nginx/htpasswd;
37+
}
38+
39+
root /data/;
40+
}
41+
}

0 commit comments

Comments
 (0)