Docker image (#22)
- Config file now is inside a config folder by default, to make easier docker integration. - File not found errors now are debug log outputs. - Added dependabot integration for github action versions. Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
This commit is contained in:
parent
8882d80232
commit
0a4438b1ad
7 changed files with 126 additions and 5 deletions
7
.github/dependabot.yml
vendored
Normal file
7
.github/dependabot.yml
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
# Maintain dependencies for GitHub Actions
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
42
.github/workflows/docker.yaml
vendored
Normal file
42
.github/workflows/docker.yaml
vendored
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
main:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: docker_meta
|
||||||
|
uses: crazy-max/ghaction-docker-meta@v1
|
||||||
|
with:
|
||||||
|
images: distribyted/distribyted
|
||||||
|
tag-sha: true
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
33
Dockerfile
Normal file
33
Dockerfile
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#===============
|
||||||
|
# Stage 1: Build
|
||||||
|
#===============
|
||||||
|
|
||||||
|
FROM golang:1.15-alpine as builder
|
||||||
|
|
||||||
|
ENV BIN_REPO=github.com/distribyted/distribyted
|
||||||
|
ENV BIN_PATH=$GOPATH/src/$BIN_REPO
|
||||||
|
|
||||||
|
COPY . $BIN_PATH
|
||||||
|
WORKDIR $BIN_PATH
|
||||||
|
|
||||||
|
RUN apk add fuse-dev git gcc libc-dev g++ make
|
||||||
|
|
||||||
|
RUN BIN_OUTPUT=/bin/distribyted make build
|
||||||
|
|
||||||
|
#===============
|
||||||
|
# Stage 2: Run
|
||||||
|
#===============
|
||||||
|
|
||||||
|
FROM alpine:3
|
||||||
|
|
||||||
|
RUN apk add gcc libc-dev fuse-dev
|
||||||
|
|
||||||
|
COPY --from=builder /bin/distribyted /bin/distribyted
|
||||||
|
RUN chmod +x /bin/distribyted
|
||||||
|
|
||||||
|
RUN mkdir /distribyted-data
|
||||||
|
|
||||||
|
RUN echo "user_allow_other" >> /etc/fuse.conf
|
||||||
|
ENV DISTRIBYTED_FUSE_ALLOW_OTHER=true
|
||||||
|
|
||||||
|
ENTRYPOINT ["./bin/distribyted"]
|
5
Makefile
5
Makefile
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
VERSION := $(shell git describe --tags)
|
VERSION := $(shell git describe --tags)
|
||||||
BUILD := $(shell git rev-parse --short HEAD)
|
BUILD := $(shell git rev-parse --short HEAD)
|
||||||
|
BIN_OUTPUT ?= bin/distribyted-$(VERSION)-`go env GOOS`-`go env GOARCH``go env GOEXE`
|
||||||
PROJECTNAME := $(shell basename "$(PWD)")
|
PROJECTNAME := $(shell basename "$(PWD)")
|
||||||
|
|
||||||
go-cross-compile: GOPATH=~/go
|
go-cross-compile: GOPATH=~/go
|
||||||
|
@ -29,8 +30,8 @@ test:
|
||||||
cross-compile: go-generate go-cross-compile
|
cross-compile: go-generate go-cross-compile
|
||||||
|
|
||||||
go-build:
|
go-build:
|
||||||
@echo " > Building binary..."
|
@echo " > Building binary on $(BIN_OUTPUT)..."
|
||||||
go build -o bin/distribyted-$(VERSION)-`go env GOOS`-`go env GOARCH``go env GOEXE` -tags "release" -ldflags='$(LDFLAGS)' cmd/distribyted/main.go
|
go build -o $(BIN_OUTPUT) -tags "release" -ldflags='$(LDFLAGS)' cmd/distribyted/main.go
|
||||||
|
|
||||||
go-generate:
|
go-generate:
|
||||||
@echo " > Generating code files..."
|
@echo " > Generating code files..."
|
||||||
|
|
38
README.md
38
README.md
|
@ -37,6 +37,7 @@
|
||||||
- [Getting Started](#getting-started)
|
- [Getting Started](#getting-started)
|
||||||
- [Prerequisites on windows](#prerequisites-on-windows)
|
- [Prerequisites on windows](#prerequisites-on-windows)
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
|
- [Docker](#docker)
|
||||||
- [Configuration File](#configuration-file)
|
- [Configuration File](#configuration-file)
|
||||||
- [root](#root)
|
- [root](#root)
|
||||||
- [mountpoints](#mountpoints)
|
- [mountpoints](#mountpoints)
|
||||||
|
@ -109,6 +110,43 @@ It contains information about the mounted routes and torrent files like download
|
||||||
|
|
||||||
You can also modify the configuration file and reload the server from here: `http://localhost:4444/config` .
|
You can also modify the configuration file and reload the server from here: `http://localhost:4444/config` .
|
||||||
|
|
||||||
|
### Docker
|
||||||
|
|
||||||
|
Docker run example:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker run \
|
||||||
|
--rm -p 4444:4444 \
|
||||||
|
--cap-add SYS_ADMIN \
|
||||||
|
--device /dev/fuse \
|
||||||
|
--security-opt apparmor:unconfined \
|
||||||
|
-v /tmp/mountpoints:/distribyted-data/mountpoints:shared \
|
||||||
|
-v /tmp/metadata:/distribyted-data/metadata \
|
||||||
|
-v /tmp/config:/distribyted-data/config \
|
||||||
|
distribyted/distribyted:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
Docker compose example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
distribyted:
|
||||||
|
container_name: distribyted
|
||||||
|
image: distribyted/distribyted:latest
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- "4444:4444/tcp"
|
||||||
|
volumes:
|
||||||
|
- /home/user/mountpoints:/distribyted-data/mountpoints:shared
|
||||||
|
- /home/user/metadata:/distribyted-data/metadata
|
||||||
|
- /home/user/config:/distribyted-data/config
|
||||||
|
security_opt:
|
||||||
|
- apparmor:unconfined
|
||||||
|
devices:
|
||||||
|
- /dev/fuse
|
||||||
|
cap_add:
|
||||||
|
- SYS_ADMIN
|
||||||
|
```
|
||||||
|
|
||||||
### Configuration File
|
### Configuration File
|
||||||
|
|
||||||
#### root
|
#### root
|
||||||
|
|
|
@ -31,7 +31,7 @@ func main() {
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: configFlag,
|
Name: configFlag,
|
||||||
Value: "./distribyted-data/config.yaml",
|
Value: "./distribyted-data/config/config.yaml",
|
||||||
EnvVars: []string{"DISTRIBYTED_CONFIG"},
|
EnvVars: []string{"DISTRIBYTED_CONFIG"},
|
||||||
Usage: "YAML file containing distribyted configuration.",
|
Usage: "YAML file containing distribyted configuration.",
|
||||||
},
|
},
|
||||||
|
|
|
@ -26,7 +26,7 @@ func NewFS(fss []fs.Filesystem) fuse.FileSystemInterface {
|
||||||
func (fs *FS) Open(path string, flags int) (errc int, fh uint64) {
|
func (fs *FS) Open(path string, flags int) (errc int, fh uint64) {
|
||||||
fh, err := fs.fh.OpenHolder(path)
|
fh, err := fs.fh.OpenHolder(path)
|
||||||
if err == os.ErrNotExist {
|
if err == os.ErrNotExist {
|
||||||
logrus.WithField("path", path).Warn("file does not exists")
|
logrus.WithField("path", path).Debug("file does not exists")
|
||||||
return -fuse.ENOENT, fhNone
|
return -fuse.ENOENT, fhNone
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ func (cfs *FS) Getattr(path string, stat *fuse.Stat_t, fh uint64) (errc int) {
|
||||||
|
|
||||||
file, err := cfs.fh.GetFile(path, fh)
|
file, err := cfs.fh.GetFile(path, fh)
|
||||||
if err == os.ErrNotExist {
|
if err == os.ErrNotExist {
|
||||||
logrus.WithField("path", path).Warn("file does not exists")
|
logrus.WithField("path", path).Debug("file does not exists")
|
||||||
return -fuse.ENOENT
|
return -fuse.ENOENT
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue