Initial commit

This commit is contained in:
Logan Marchione 2022-04-02 14:32:22 -04:00
commit bfa171c844
5 changed files with 102 additions and 0 deletions

11
.dockerignore Normal file
View File

@ -0,0 +1,11 @@
*.md
*.env
.git
.gitignore
.github
.drone.yml
.travis.yml
docker-compose.yml
Dockerfile
.dockerignore
screenshots

36
Dockerfile Normal file
View File

@ -0,0 +1,36 @@
FROM ubuntu:focal
ARG BUILD_DATE
LABEL \
maintainer="Logan Marchione <logan@loganmarchione.com>" \
org.opencontainers.image.authors="Logan Marchione <logan@loganmarchione.com>" \
org.opencontainers.image.title="docker-webdav-nginx" \
org.opencontainers.image.description="Runs a Nginx WebDav server in Docker" \
org.opencontainers.image.created=$BUILD_DATE
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
apache2-utils \
netcat \
nginx-extras && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p "/var/www/webdav/restricted" && \
mkdir -p "/var/www/webdav/public" && \
chown -R www-data:www-data "/var/www" && \
rm /etc/nginx/sites-enabled/default
EXPOSE 80
VOLUME [ "/var/www/webdav" ]
COPY password.sh password.sh
COPY webdav.conf /etc/nginx/sites-enabled/webdav
ENTRYPOINT ["/password.sh"]
CMD ["nginx", "-g", "daemon off;"]
HEALTHCHECK CMD nc -z localhost 80 || exit 1

1
VERSION Normal file
View File

@ -0,0 +1 @@
0.0.1

21
password.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh -e
printf "#####\n"
printf "# Container starting up!\n"
printf "#####\n"
# Check for WebDav user/pass
printf "# STATE: Checking for WebDav user/pass\n"
if [ -n "$WEBDAV_USER" ] && [ -n "$WEBDAV_PASS" ]
then
printf "# STATE: WebDav user/pass written to /etc/nginx/webdav_credentials\n"
htpasswd -b -c /etc/nginx/webdav_credentials $WEBDAV_USER $WEBDAV_PASS > /dev/null 2>&1
else
printf "# WARN: No WebDav user/pass were set, the 'restricted' diretory has no authentication on it!\n"
sed -i 's/.*auth_basic.*//g' /etc/nginx/sites-enabled/webdav
sed -i 's/.*auth_basic_user_file.*//g' /etc/nginx/sites-enabled/webdav
fi
printf "# STATE: Nginx is starting up now, the logs you see below are error_log and access_log from Nginx\n"
exec "$@"

33
webdav.conf Normal file
View File

@ -0,0 +1,33 @@
server {
listen 80 default_server;
server_name _;
root /var/www/webdav;
autoindex on;
location /public {
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS;
dav_access user:rw group:rw;
create_full_put_path on;
error_log /dev/stdout;
access_log /dev/stdout;
}
location /restricted {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/webdav_credentials;
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS;
dav_access user:rw group:rw;
create_full_put_path on;
error_log /dev/stdout;
access_log /dev/stdout;
}
}