mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 07:33:21 +00:00
add docker image
This commit is contained in:
parent
6b821132ec
commit
07b6d5facf
6 changed files with 112 additions and 0 deletions
48
README.md
48
README.md
|
@ -22,6 +22,8 @@ performance [improvements](https://github.com/restic/restic/commit/04b262d8f10ba
|
|||
|
||||
## Installation
|
||||
|
||||
### From source
|
||||
|
||||
Run ```go run build.go```, afterwards you'll find the binary in the current directory. You can move it anywhere you
|
||||
want. There's also an [example systemd service
|
||||
file](https://github.com/restic/rest-server/blob/master/etc/rest-server.service) included, so you can get it up &
|
||||
|
@ -49,8 +51,20 @@ Flags:
|
|||
Alternatively, you can compile and install it in your $GOBIN with a standard `go install`. But, beware, you won't have
|
||||
version info built into binary, when compiled that way.
|
||||
|
||||
#### Build Docker Image
|
||||
|
||||
Run `docker/build.sh`, image name is `restic/rest-server:latest`.
|
||||
|
||||
### From Docker image
|
||||
|
||||
```
|
||||
docker pull restic/rest-server:latest
|
||||
```
|
||||
|
||||
## Getting started
|
||||
|
||||
### Using binary
|
||||
|
||||
By default the server persists backup data in `/tmp/restic`. Start the server with a custom persistence directory:
|
||||
|
||||
```
|
||||
|
@ -82,6 +96,40 @@ and via HTTP, even simultaneously.
|
|||
To learn how to use restic backup client with REST backend, please consult [restic
|
||||
manual](https://restic.readthedocs.io/en/latest/manual.html#rest-server).
|
||||
|
||||
### Using Docker image
|
||||
|
||||
By default, image use authentication. To turn it off, set environment variable `DISABLE_AUTHENTICATION` to any value.
|
||||
|
||||
Persistent data volume is located to `/data`
|
||||
|
||||
#### Start server
|
||||
|
||||
```
|
||||
docker run --name myserver -v /my/data:/data restic/rest-server
|
||||
```
|
||||
|
||||
It's suggested to set a name to more easily manage users (see next section).
|
||||
|
||||
#### Manager users
|
||||
|
||||
##### Add user
|
||||
|
||||
```
|
||||
docker exec -ti myserver create_user myuser
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
docker exec -ti myserver create_user myuser mypassword
|
||||
```
|
||||
|
||||
##### Delete user
|
||||
|
||||
```
|
||||
docker exec myserver delete_user myuser
|
||||
```
|
||||
|
||||
## Why use Rest Server?
|
||||
|
||||
Compared to the SFTP backend, the REST backend has better performance, especially so if you can skip additional crypto
|
||||
|
|
14
docker/Dockerfile
Normal file
14
docker/Dockerfile
Normal file
|
@ -0,0 +1,14 @@
|
|||
FROM alpine:3.6
|
||||
|
||||
RUN apk add --no-cache --update apache2-utils
|
||||
COPY docker/*_user rest-server /usr/bin/
|
||||
COPY docker/entry.sh /
|
||||
|
||||
ENV DATA_DIRECTORY=/data
|
||||
ENV PASSWORD_FILE=/data/.htpasswd
|
||||
|
||||
VOLUME /data
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
ENTRYPOINT ["/entry.sh"]
|
11
docker/build.sh
Executable file
11
docker/build.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
echo "Build binary using golang docker image"
|
||||
docker run --rm -ti \
|
||||
-v `pwd`:/go/src/github.com/restic/rest-server \
|
||||
-w /go/src/github.com/restic/rest-server golang:1.8.3-alpine go run build.go
|
||||
|
||||
echo "Build docker image restic/rest-server:latest"
|
||||
docker build --rm -t restic/rest-server:latest -f docker/Dockerfile .
|
10
docker/create_user
Executable file
10
docker/create_user
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "create_user [username]"
|
||||
echo "or"
|
||||
echo "create_user [username] [password]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
htpasswd -s $PASSWORD_FILE $1 $2
|
8
docker/delete_user
Executable file
8
docker/delete_user
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "delete_user [username]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
htpasswd -D $PASSWORD_FILE $1
|
21
docker/entry.sh
Executable file
21
docker/entry.sh
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
mkdir -p $DATA_DIRECTORY
|
||||
|
||||
if [ -z "$DISABLE_AUTHENTICATION" ]; then
|
||||
if [ ! -f $PASSWORD_FILE ]; then
|
||||
touch $PASSWORD_FILE
|
||||
fi
|
||||
|
||||
if [ ! -s $PASSWORD_FILE ]; then
|
||||
echo
|
||||
echo "**WARNING** No user exists, please 'docker exec -ti \$CONTAINER_ID create_user'"
|
||||
echo
|
||||
fi
|
||||
else
|
||||
rm -f $PASSWORD_FILE
|
||||
fi
|
||||
|
||||
rest-server --listen ":80" --path $DATA_DIRECTORY
|
Loading…
Add table
Add a link
Reference in a new issue