fix Docker setup

This commit is contained in:
Bora M. Alper 2019-09-18 01:21:30 +01:00
parent 93d424344a
commit 0e9dcba5b6
9 changed files with 44 additions and 48 deletions

View File

@ -16,7 +16,6 @@ before_install:
install:
- "go get -u -v github.com/kevinburke/go-bindata/..."
- "go get -u -v honnef.co/go/tools/cmd/staticcheck"
before_script:
- "make magneticod"

View File

@ -1,6 +1,7 @@
# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM golang:1.12-alpine AS build
FROM golang:1.13-alpine AS build
WORKDIR /magnetico
RUN apk add --no-cache build-base curl git
@ -10,15 +11,14 @@ ADD ./pkg /magnetico/pkg
ADD ./go.mod /magnetico/go.mod
ADD ./cmd/magneticod /magnetico/cmd/magneticod
WORKDIR /magnetico/
RUN make magneticod
FROM alpine:latest
LABEL maintainer="bora@boramalper.org"
WORKDIR /
VOLUME /root/.local/share/magneticod
VOLUME /root/.config/magneticod
COPY --from=build /go/bin/magneticod /magneticod
RUN adduser -D -S magnetico
USER magnetico
ENTRYPOINT ["/magneticod"]

View File

@ -1,10 +1,11 @@
# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM golang:1.12-alpine AS build
FROM golang:1.13-alpine AS build
WORKDIR /magnetico
RUN export PATH=$PATH:/go/bin
RUN apk add --no-cache build-base curl git
RUN go get -u github.com/kevinburke/go-bindata/...
# Copy the local package files to the container's workspace.
ADD ./Makefile /magnetico/
@ -12,24 +13,18 @@ ADD ./pkg /magnetico/pkg
ADD ./go.mod /magnetico/go.mod
ADD ./cmd/magneticow /magnetico/cmd/magneticow
WORKDIR /magnetico
RUN go get -u github.com/kevinburke/go-bindata/...
RUN echo $PATH
RUN ls /go/bin
RUN make magneticow
FROM alpine:latest
LABEL maintainer="bora@boramalper.org"
# the service listens on port 8080
EXPOSE 8080
WORKDIR /
VOLUME /root/.local/share/magneticod
RUN mkdir -p "/root/.config/magneticow/"
RUN echo 'magnetico:$2y$06$8VzJvXegA2X/tfmTXN7NM.FH5HRh8fbvXUmrtW52xLH5JNDhldexG' > "/root/.config/magneticow/credentials"
COPY --from=build /go/bin/magneticow /magneticow
RUN adduser -D -S magnetico
USER magnetico
ENTRYPOINT ["/magneticow"]
# Document that the service listens on port 8080.
EXPOSE 8080

View File

@ -54,15 +54,12 @@ You need to mount
hence run:
```bash
docker run \
docker run -it --rm \
-v ~/.local/share/magneticod:/root/.local/share/magneticod/ \
-v ~/.config/magneticod/configuration.toml:/root/.config/magneticod/configuration.toml \
magneticod
boramalper/magneticod
```
__Tip:__ Containers that you terminate won't be removed; run
`docker rm $(docker ps -q -f status=exited)` to remove exited containers.
### Remark About the Network Usage
**magneticod** does *not* have any built-in rate limiter *yet*, and it will literally suck the hell out of your
bandwidth. Unless you are running **magneticod** on a separate machine dedicated for it, you might want to consider

View File

@ -56,7 +56,7 @@ func main() {
return
}
zap.L().Info("magneticod v0.8.0 has been started.")
zap.L().Info("magneticod v0.8.2 has been started.")
zap.L().Info("Copyright (C) 2017-2019 Mert Bora ALPER <bora@boramalper.org>.")
zap.L().Info("Dedicated to Cemile Binay, in whose hands I thrived.")
zap.S().Infof("Compiled on %s", compiledOn)

View File

@ -80,12 +80,14 @@ You need to mount
hence run:
```bash
docker run \
docker run -it --rm \
-v ~/.local/share/magneticod:/root/.local/share/magneticod/ \
-v ~/.config/magneticow/configuration.toml:/root/.config/magneticow/configuration.toml \
magneticow
boramalper/magneticow
```
Using Docker, the default username & password is `magnetico` and `magnetico`.
### Searching
* Only the **titles** of the torrents are being searched.
* Search is case-insensitive.

View File

@ -5,7 +5,6 @@ import (
"bytes"
"encoding/hex"
"fmt"
"github.com/pkg/errors"
"html/template"
"io"
"net/http"
@ -17,6 +16,8 @@ import (
"syscall"
"time"
"github.com/pkg/errors"
"github.com/Wessie/appdirs"
"github.com/dustin/go-humanize"
"github.com/gorilla/mux"
@ -60,7 +61,7 @@ func main() {
defer logger.Sync()
zap.ReplaceGlobals(logger)
zap.L().Info("magneticow v0.8 has been started.")
zap.L().Info("magneticow v0.8.2 has been started.")
zap.L().Info("Copyright (C) 2017-2019 Mert Bora ALPER <bora@boramalper.org>.")
zap.L().Info("Dedicated to Cemile Binay, in whose hands I thrived.")
zap.S().Infof("Compiled on %s", compiledOn)
@ -287,7 +288,7 @@ func loadCred(cred string) error {
*/
re := regexp.MustCompile(`^[a-z](?:_?[a-z0-9])*:\$2[aby]?\$\d{1,2}\$[./A-Za-z0-9]{53}$`)
if !re.Match(line) {
return fmt.Errorf("on line %d: format should be: <USERNAME>:<BCRYPT HASH>", lineno)
return fmt.Errorf("on line %d: format should be: <USERNAME>:<BCRYPT HASH>, instead got: %s", lineno, line)
}
tokens := bytes.Split(line, []byte(":"))

View File

@ -1,7 +1,4 @@
version: "3"
volumes:
home:
version: "2"
services:
magneticod:
@ -9,17 +6,22 @@ services:
context: .
dockerfile: Dockerfile.magneticod
volumes:
- home:/home/magnetico
- magneticod-data:/root/.local/share/magneticod
- magneticod-config:/root/.config/magneticod
magneticow:
build:
context: .
dockerfile: Dockerfile.magneticow
volumes:
- home:/home/magnetico
- magneticod-data:/root/.local/share/magneticod
depends_on:
# It doesn't necessarily "depend" on magneticod, but you would probably like to start them at the same time.
- magneticod
ports:
- "8080:8080"
volumes:
magneticod-config:
magneticod-data: