Skip to content

Commit

Permalink
add docker setup for S3 to WebDav proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
saw-jan committed Jan 10, 2024
1 parent be22e54 commit 071be5e
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea
bin
contrib
rclone
graphics
42 changes: 33 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,49 @@
FROM golang:alpine AS builder

COPY . /go/src/github.com/rclone/rclone/
WORKDIR /go/src/github.com/rclone/rclone/
WORKDIR /rclone/
COPY go.mod /rclone/
RUN go mod download

COPY . /rclone/

RUN apk add --no-cache make bash gawk git
RUN \
CGO_ENABLED=0 \
make
RUN ./rclone version
make && \
./rclone version


# Begin final image
FROM alpine:latest

RUN apk --no-cache add ca-certificates fuse3 tzdata && \
echo "user_allow_other" >> /etc/fuse.conf
COPY --from=builder /rclone/rclone /usr/local/bin/

COPY --from=builder /go/src/github.com/rclone/rclone/rclone /usr/local/bin/
COPY ["./docker/startup", "/startup"]

RUN addgroup -g 1009 rclone && adduser -u 1009 -Ds /bin/sh -G rclone rclone
RUN apk --no-cache add \
ca-certificates \
fuse3 \
tzdata \
&& apk cache clean

ENTRYPOINT [ "rclone" ]
RUN echo "user_allow_other" >> /etc/fuse.conf && \
addgroup -g 1009 rclone && \
adduser -u 1009 -Ds /bin/sh -G rclone rclone && \
chmod +x /startup

WORKDIR /data

ENV XDG_CONFIG_HOME=/config

# remote configs
ENV REMOTE_NAME=""
ENV REMOTE_URL=""
ENV REMOTE_VENDOR=""

# s3 proxy configs
# a space separated list of options
ENV PROXY_ARGS=""

ENTRYPOINT [ "/startup" ]

EXPOSE 8080
40 changes: 40 additions & 0 deletions docker/startup
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

RCLONE_CONFIG=/config/rclone/rclone.conf

if [ -z "$REMOTE_NAME" ]; then
echo "REMOTE_NAME is not set"
exit 1
fi
if [ -z "$REMOTE_URL" ]; then
echo "REMOTE_URL is not set"
exit 1
fi
if [ -z "$REMOTE_VENDOR" ]; then
echo "REMOTE_VENDOR is not set"
exit 1
fi

mkdir -p "$(dirname "$RCLONE_CONFIG")"

cat <<EOF >"$RCLONE_CONFIG"
[$REMOTE_NAME]
type = webdav
url = $REMOTE_URL
vendor = $REMOTE_VENDOR
nextcloud_chunk_size = 0
EOF

# parse args
ifsBak=$IFS
IFS=' '

ARGS="$REMOTE_NAME:"
for arg in $PROXY_ARGS; do
ARGS="$ARGS $arg"
done

IFS=$ifsBak

# DO NOT QUOTE ARGS
rclone serve s3 ${ARGS}

0 comments on commit 071be5e

Please sign in to comment.