forked from rclone/rclone
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add docker setup for S3 to WebDav proxy
- Loading branch information
Showing
3 changed files
with
78 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.idea | ||
bin | ||
contrib | ||
rclone | ||
graphics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |