fix docker, move to go modules

This commit is contained in:
Bora M. Alper 2019-05-19 01:27:10 +01:00
parent 1fdfa131aa
commit 5507ca371a
No known key found for this signature in database
GPG Key ID: 8F1A9504E1BD114D
8 changed files with 65 additions and 106 deletions

1
.gitignore vendored
View File

@ -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

View File

@ -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"]

View File

@ -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
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
# 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
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.

View File

@ -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"

View File

@ -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/...

View File

@ -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

View File

@ -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"

21
go.mod Normal file
View File

@ -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
)