add docker image

This commit is contained in:
Bruno Clermont
2017-06-22 20:56:17 +02:00
committed by Zlatko Čalušić
parent 6b821132ec
commit 07b6d5facf
6 changed files with 112 additions and 0 deletions

14
docker/Dockerfile Normal file
View 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
View 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
View 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
View 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
View 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