diff --git a/.gitignore b/.gitignore index 52b37032b..1589a7fd2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ vendor/ .idea/ Gopkg.lock cmd/magneticow/bindata.go +go.sum # Created by https://www.gitignore.io/api/go,linux,macos,windows diff --git a/Dockerfile.magneticod b/Dockerfile.magneticod index 3820cde81..d1b0af017 100644 --- a/Dockerfile.magneticod +++ b/Dockerfile.magneticod @@ -1,28 +1,24 @@ -# Source: https://blog.golang.org/docker - # Start from a Debian image with the latest version of Go installed # and a workspace (GOPATH) configured at /go. -FROM golang:1.11-alpine AS build +FROM golang:1.12-alpine AS build RUN apk add --no-cache build-base curl git # Copy the local package files to the container's workspace. -ADD ./Gopkg.toml /go/src/github.com/boramalper/magnetico/ -ADD ./Makefile /go/src/github.com/boramalper/magnetico/ -ADD ./pkg /go/src/github.com/boramalper/magnetico/pkg -ADD ./cmd/magneticod /go/src/github.com/boramalper/magnetico/cmd/magneticod +ADD ./Makefile /magnetico/ +ADD ./pkg /magnetico/pkg +ADD ./go.mod /magnetico/go.mod +ADD ./cmd/magneticod /magnetico/cmd/magneticod -# Build the outyet command inside the container. -# (You may fetch or manage dependencies here, -# either manually or with a tool like "godep".) -RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh -WORKDIR /go/src/github.com/boramalper/magnetico/ -RUN make ensure +WORKDIR /magnetico/ RUN make magneticod FROM alpine:latest +LABEL maintainer="bora@boramalper.org" WORKDIR / COPY --from=build /go/bin/magneticod /magneticod -# Run the outyet command by default when the container starts. +RUN adduser -D -S magnetico +USER magnetico + ENTRYPOINT ["/magneticod"] diff --git a/Dockerfile.magneticow b/Dockerfile.magneticow index 2c6d3fd9d..2971b7567 100644 --- a/Dockerfile.magneticow +++ b/Dockerfile.magneticow @@ -1,30 +1,34 @@ -# Source: https://blog.golang.org/docker - # Start from a Debian image with the latest version of Go installed # and a workspace (GOPATH) configured at /go. -FROM golang:1.11-alpine AS build +FROM golang:1.12-alpine AS build + +RUN export PATH=$PATH:/go/bin RUN apk add --no-cache build-base curl git # Copy the local package files to the container's workspace. -ADD ./Gopkg.toml /go/src/github.com/boramalper/magnetico/ -ADD ./Makefile /go/src/github.com/boramalper/magnetico/ -ADD ./pkg /go/src/github.com/boramalper/magnetico/pkg -ADD ./cmd/magneticow /go/src/github.com/boramalper/magnetico/cmd/magneticow - -# Build the outyet command inside the container. -# (You may fetch or manage dependencies here, -# either manually or with a tool like "godep".) -RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh -WORKDIR /go/src/github.com/boramalper/magnetico/ -RUN make ensure +ADD ./Makefile /magnetico/ +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" WORKDIR / COPY --from=build /go/bin/magneticow /magneticow -# Run the outyet command by default when the container starts. +RUN adduser -D -S magnetico +USER magnetico + ENTRYPOINT ["/magneticow"] # Document that the service listens on port 8080. diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index 2a98fca29..000000000 --- a/Gopkg.toml +++ /dev/null @@ -1,62 +0,0 @@ - -# Gopkg.toml example -# -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" - - -[[constraint]] - branch = "master" - name = "github.com/Wessie/appdirs" - -[[constraint]] - branch = "master" - name = "github.com/anacrolix/missinggo" - -[[constraint]] - branch = "master" - name = "github.com/anacrolix/torrent" - -[[constraint]] - branch = "master" - name = "github.com/dustin/go-humanize" - -[[constraint]] - name = "github.com/gorilla/mux" - version = "1.5.0" - -[[constraint]] - name = "github.com/jessevdk/go-flags" - version = "1.3.0" - -[[constraint]] - name = "github.com/mattn/go-sqlite3" - version = "1.3.0" - -[[constraint]] - name = "github.com/willf/bloom" - version = "2.0.3" - -[[constraint]] - name = "go.uber.org/zap" - version = "1.7.1" - -[[constraint]] - name = "github.com/libp2p/go-sockaddr" - version = "1.0.3" diff --git a/Makefile b/Makefile index 7b926b454..a66e8f600 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: test format vet staticcheck magneticod magneticow ensure image image-magneticow image-magneticod +.PHONY: test format vet staticcheck magneticod magneticow image image-magneticow image-magneticod all: test magneticod magneticow @@ -19,11 +19,6 @@ image-magneticow: image: image-magneticod image-magneticow -# Download dependencies -ensure: - dep ensure -v - go get -u github.com/kevinburke/go-bindata/... - vet: go vet github.com/boramalper/magnetico/... diff --git a/cmd/magneticow/README.md b/cmd/magneticow/README.md index 7939f4051..4ab17377e 100644 --- a/cmd/magneticow/README.md +++ b/cmd/magneticow/README.md @@ -8,14 +8,13 @@ See the list of [alternative front-ends](https://github.com/boramalper/magnetico developed by the community if you need something more advanced or different. ## Installation - ### Installing the Pre-Compiled Static Binary You can find the latest pre-compiled static binaries on [GitHub](https://github.com/boramalper/magnetico/releases) for versions from v0.7.0 onwards. ### Installing the Docker Image -Docker images are provided on [Docker Hub](https://hub.docker.com/r/boramalper/magnetico/tags/) at -the repository `boramalper/magnetico`. Images are tagged as `w-vMAJOR.MINOR.PATCH`. +Docker images are provided on [Docker Hub](https://hub.docker.com/u/boramalper) at +the repositories `boramalper/magneticod` and `boramalper/magneticow`. ## Setup ### Configuration diff --git a/docker-compose.yml b/docker-compose.yml index 2e52ae5b9..db22b0749 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,20 +1,25 @@ -version: "2" +version: "3" volumes: - shared_db: + home: services: magneticod: build: - context: magneticod + context: . + dockerfile: Dockerfile.magneticod volumes: - - shared_db:/root/.local/share + - home:/home/magnetico magneticow: build: - context: magneticow + context: . + dockerfile: Dockerfile.magneticow volumes: - - shared_db:/root/.local/share + - home:/home/magnetico + depends_on: + # It doesn't necessarily "depend" on magneticod, but you would probably like to start them at the same time. + - magneticod ports: - - "12345:8080" + - "8080:8080" diff --git a/go.mod b/go.mod new file mode 100644 index 000000000..980b21006 --- /dev/null +++ b/go.mod @@ -0,0 +1,21 @@ +module github.com/boramalper/magnetico + +require ( + github.com/Wessie/appdirs v0.0.0-20141031215813-6573e894f8e2 + github.com/anacrolix/missinggo v1.1.0 + github.com/anacrolix/torrent v1.1.4 + github.com/dustin/go-humanize v1.0.0 + github.com/gorilla/mux v1.7.2 + github.com/gorilla/schema v1.1.0 + github.com/jessevdk/go-flags v1.4.0 + github.com/kevinburke/go-bindata v3.13.0+incompatible // indirect + github.com/libp2p/go-sockaddr v0.0.1 + github.com/mattn/go-sqlite3 v1.10.0 + github.com/pkg/errors v0.8.1 + github.com/willf/bloom v2.0.3+incompatible + go.uber.org/atomic v1.4.0 // indirect + go.uber.org/multierr v1.1.0 // indirect + go.uber.org/zap v1.10.0 + golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f + golang.org/x/sys v0.0.0-20190516110030-61b9204099cb +)