Compare commits

..

7 Commits

Author SHA1 Message Date
b82a2d38fa fix pipeline step name
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-25 09:38:19 -06:00
33ccf93911 hostile takeover
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-23 20:42:29 -06:00
Logan Marchione
0179b787b1 Rename entrypoint script, detect NGINX_CLIENT_MAX_BODY_SIZE 2023-06-19 15:14:22 -04:00
Logan Marchione
5f1906feb8 Add default client_max_body_size 2023-06-19 15:14:01 -04:00
Logan Marchione
f708d1f194 Add NGINX_CLIENT_MAX_BODY_SIZE to example 2023-06-19 15:13:42 -04:00
Logan Marchione
ef8106adcd Bump version 2023-06-19 15:13:10 -04:00
Logan Marchione
cc14a5e76a Rename entrypoint script 2023-06-19 15:13:01 -04:00
11 changed files with 58 additions and 185 deletions

13
.drone.yml Normal file
View File

@ -0,0 +1,13 @@
kind: pipeline
name: default
workspace:
base: /go
path: src/deadbeef.codes/steven/docker-webdav-nginx
steps:
- name: docker build
image: plugins/docker
settings:
repo: registry.deadbeef.codes/docker-webdav-nginx

21
.github/renovate.json vendored
View File

@ -1,21 +0,0 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
],
"dependencyDashboard": true,
"dependencyDashboardTitle": "Renovate Dashboard",
"labels": ["renovatebot"],
"packageRules": [
{
"managers": ["github-actions"],
"matchUpdateTypes": ["patch"],
"automerge": true,
"automergeType": "pr",
"platformAutomerge": true
}
],
"docker-compose": {
"ignorePaths": ["docker-compose-dev.yml"]
}
}

5
.github/trivy.yaml vendored
View File

@ -1,5 +0,0 @@
format: table
severity:
- CRITICAL
vulnerability:
ignore-unfixed: true

View File

@ -1,119 +0,0 @@
name: CI/CD
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
schedule:
- cron: "0 5 * * 0"
workflow_dispatch:
env:
USER: loganmarchione
REPO: docker-webdav-nginx
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out the codebase
uses: actions/checkout@v3
- name: Lint Dockerfile with Hadolint
uses: hadolint/hadolint-action@v3.1.0
with:
failure-threshold: error
ignore: DL3008,DL3018
ci:
name: Build and test
needs: lint
runs-on: ubuntu-latest
steps:
- name: Check out the codebase
uses: actions/checkout@v3
- name: Set variables
run: |
VER=$(cat VERSION)
echo "VERSION=$VER" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker Image
uses: docker/build-push-action@v4
with:
push: false
context: .
file: Dockerfile
load: true
tags: |
${{ env.USER }}/${{ env.REPO }}:${{ env.VERSION }}
${{ env.USER }}/${{ env.REPO }}:latest
- name: Test image
run: |
docker images
docker run --name test-container --detach --env WEBDAV_USER=user --env WEBDAV_PASS=password1 --volume 'webdav:/var/www/webdav' ${USER}/${REPO}:${VERSION}
docker ps -a
- name: Container scan with Dockle
uses: goodwithtech/dockle-action@0.1.0
with:
image: '${{ env.USER }}/${{ env.REPO }}:${{ env.VERSION }}'
format: 'list'
exit-code: '1'
exit-level: 'warn'
ignore: 'CIS-DI-0001'
- name: Container scan with Trivy
uses: aquasecurity/trivy-action@0.11.2
with:
scan-type: 'image'
image-ref: '${{ env.USER }}/${{ env.REPO }}:${{ env.VERSION }}'
trivy-config: ./github/trivy.yaml
cd:
name: Deploy
needs: ci
runs-on: ubuntu-latest
steps:
- name: Check out the codebase
uses: actions/checkout@v3
- name: Set variables
run: |
VER=$(cat VERSION)
echo "VERSION=$VER" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASS }}
logout: true
- name: Build Docker Image
uses: docker/build-push-action@v4
with:
push: true
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: |
${{ env.USER }}/${{ env.REPO }}:${{ env.VERSION }}
${{ env.USER }}/${{ env.REPO }}:latest

View File

@ -1,19 +1,14 @@
FROM debian:12-slim FROM debian:12-slim
ARG BUILD_DATE # Originally
# LABEL maintainer="Logan Marchione <logan@loganmarchione.com>" \
LABEL \ LABEL maintainer="himself@stevenpolley.net"
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 ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get -y install --no-install-recommends \ RUN apt-get update && apt-get -y install --no-install-recommends \
apache2-utils \ apache2-utils \
netcat-openbsd \ netcat-openbsd \
nginx-extras && \ nginx-extras && \
rm -rf /var/lib/apt/lists/* && \ rm -rf /var/lib/apt/lists/* && \
mkdir -p "/var/www/webdav/restricted" && \ mkdir -p "/var/www/webdav/restricted" && \
@ -25,13 +20,13 @@ EXPOSE 80
VOLUME [ "/var/www/webdav" ] VOLUME [ "/var/www/webdav" ]
COPY password.sh / COPY entrypoint.sh /
COPY VERSION / COPY VERSION /
COPY webdav.conf /etc/nginx/sites-enabled/webdav COPY webdav.conf /etc/nginx/sites-enabled/webdav
ENTRYPOINT ["/password.sh"] ENTRYPOINT ["/entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,7 +1,6 @@
# docker-webdav-nginx [![Build Status](https://drone.deadbeef.codes/api/badges/steven/docker-webdav-nginx/status.svg)](https://drone.deadbeef.codes/steven/docker-webdav-nginx)
[![CI/CD](https://github.com/loganmarchione/docker-webdav-nginx/actions/workflows/main.yml/badge.svg)](https://github.com/loganmarchione/docker-webdav-nginx/actions/workflows/main.yml) # docker-webdav-nginx
[![Docker Image Size (latest semver)](https://img.shields.io/docker/image-size/loganmarchione/docker-webdav-nginx)](https://hub.docker.com/r/loganmarchione/docker-webdav-nginx)
Runs a Nginx WebDav server in Docker Runs a Nginx WebDav server in Docker
- Source code: [GitHub](https://github.com/loganmarchione/docker-webdav-nginx) - Source code: [GitHub](https://github.com/loganmarchione/docker-webdav-nginx)
@ -30,10 +29,11 @@ Runs a Nginx WebDav server in Docker
- `X.X.X`: [Semantic version](https://semver.org/) (use if you want to stick on a specific version) - `X.X.X`: [Semantic version](https://semver.org/) (use if you want to stick on a specific version)
### Environment variables ### Environment variables
| Variable | Required? | Definition | Example | Comments | | Variable | Required? | Definition | Example | Comments |
|-------------|-----------|----------------------------------|----------------------------|--------------------------------------------------------------| |----------------------------|--------------------|----------------------------------------------------------------------------------------------------------------|----------------------------|--------------------------------------------------------------|
| WEBDAV_USER | No | WebDav username | user | user AND pass need to be set for authentication to work | | WEBDAV_USER | No | WebDav username | user | user AND pass need to be set for authentication to work |
| WEBDAV_PASS | No | WebDav password | password1 | user AND pass need to be set for authentication to work | | WEBDAV_PASS | No | WebDav password | password1 | user AND pass need to be set for authentication to work |
| NGINX_CLIENT_MAX_BODY_SIZE | No (default: 250M) | Nginx's [client_max_body_size](https://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size) | 500M | Be sure to include the units. Set to `0` to disable. |
### Ports ### Ports
| Port on host | Port in container | Comments | | Port on host | Port in container | Comments |
@ -56,6 +56,7 @@ services:
environment: environment:
- WEBDAV_USER=user - WEBDAV_USER=user
- WEBDAV_PASS=password1 - WEBDAV_PASS=password1
- NGINX_CLIENT_MAX_BODY_SIZE=500M
networks: networks:
- webdav - webdav
ports: ports:

View File

@ -1 +1 @@
0.3.0 0.3.1

View File

@ -9,6 +9,7 @@ services:
environment: environment:
- WEBDAV_USER=user - WEBDAV_USER=user
- WEBDAV_PASS=password1 - WEBDAV_PASS=password1
- NGINX_CLIENT_MAX_BODY_SIZE=500M
networks: networks:
- webdav - webdav
ports: ports:

27
entrypoint.sh Executable file
View File

@ -0,0 +1,27 @@
#!/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" directory 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
# Check for client_max_body_size setting
if [ -n "$NGINX_CLIENT_MAX_BODY_SIZE" ]
then
printf "# STATE: Setting client_max_body_size to $NGINX_CLIENT_MAX_BODY_SIZE\n"
sed -i "s/client_max_body_size 250M;/client_max_body_size $NGINX_CLIENT_MAX_BODY_SIZE;/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 "$@"

View File

@ -1,21 +0,0 @@
#!/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 "$@"

View File

@ -5,6 +5,8 @@ server {
root /var/www/webdav; root /var/www/webdav;
autoindex on; autoindex on;
client_max_body_size 250M;
location /public { location /public {
dav_methods PUT DELETE MKCOL COPY MOVE; dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS; dav_ext_methods PROPFIND OPTIONS;