mirror of https://github.com/mitchell/selfpass.git
Refactored Docker and Make files; increased command context timeouts;
add dockerignore
This commit is contained in:
parent
db246df3d6
commit
b76d5dffa3
|
@ -0,0 +1 @@
|
||||||
|
certs
|
|
@ -1,12 +1,13 @@
|
||||||
FROM golang:1.11.5 as build
|
FROM golang:1.11.5 as build
|
||||||
WORKDIR /go/src/github.com/mitchell/selfpass
|
WORKDIR /go/src/github.com/mitchell/selfpass
|
||||||
COPY . .
|
COPY . .
|
||||||
ENV GO111MODULE=on
|
ENV GO111MODULE on
|
||||||
RUN make gen-certs-go
|
|
||||||
RUN make build
|
RUN make build
|
||||||
|
|
||||||
FROM debian:stable-20190506-slim
|
FROM debian:stable-20190506-slim
|
||||||
WORKDIR /usr/bin
|
COPY --from=build /go/src/github.com/mitchell/selfpass/bin/server /usr/bin/server
|
||||||
COPY --from=build /go/src/github.com/mitchell/selfpass/bin/server .
|
RUN groupadd -r selfpass && useradd --no-log-init -r -g selfpass selfpass
|
||||||
|
USER selfpass
|
||||||
|
WORKDIR /home/selfpass
|
||||||
ENTRYPOINT ["server"]
|
ENTRYPOINT ["server"]
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
6
Makefile
6
Makefile
|
@ -1,15 +1,15 @@
|
||||||
.PHONY: all build clean format test
|
.PHONY: all build clean format test gen-certs-go
|
||||||
|
|
||||||
build: clean format
|
build: clean format
|
||||||
env CGO_ENABLED=0 go build -o ./bin/server ./cmd/server
|
env CGO_ENABLED=0 go build -o ./bin/server ./cmd/server
|
||||||
rm ./cmd/server/certs.go
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf ./bin
|
rm -rf ./bin
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
|
||||||
docker:
|
docker: gen-certs-go
|
||||||
docker-compose build
|
docker-compose build
|
||||||
|
rm ./cmd/server/certs.go
|
||||||
|
|
||||||
local:
|
local:
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
|
|
|
@ -91,7 +91,7 @@ password.`,
|
||||||
check(survey.AskOne(prompt, &cpass, nil))
|
check(survey.AskOne(prompt, &cpass, nil))
|
||||||
|
|
||||||
if ci.Password != cpass {
|
if ci.Password != cpass {
|
||||||
fmt.Println("passwords didn't match'")
|
fmt.Println("passwords didn't match")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ password.`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
c, err := initClient(ctx).Create(ctx, ci)
|
c, err := initClient(ctx).Create(ctx, ci)
|
||||||
|
|
|
@ -21,7 +21,7 @@ func MakeDelete(initConfig CredentialClientInit) *cobra.Command {
|
||||||
check(survey.AskOne(prompt, &confirmed, nil))
|
check(survey.AskOne(prompt, &confirmed, nil))
|
||||||
|
|
||||||
if confirmed {
|
if confirmed {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
check(initConfig(ctx).Delete(ctx, args[0]))
|
check(initConfig(ctx).Delete(ctx, args[0]))
|
||||||
|
|
|
@ -25,7 +25,7 @@ decrypting password.`,
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
cred, err := initClient(ctx).Get(ctx, args[0])
|
cred, err := initClient(ctx).Get(ctx, args[0])
|
||||||
|
|
|
@ -3,9 +3,11 @@ package commands
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"gopkg.in/AlecAivazis/survey.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MakeList(initClient CredentialClientInit) *cobra.Command {
|
func MakeList(initClient CredentialClientInit) *cobra.Command {
|
||||||
|
@ -18,13 +20,14 @@ func MakeList(initClient CredentialClientInit) *cobra.Command {
|
||||||
includes almost all the information but the most sensitive.`,
|
includes almost all the information but the most sensitive.`,
|
||||||
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
mdch, errch := initClient(ctx).GetAllMetadata(ctx, sourceHost)
|
mdch, errch := initClient(ctx).GetAllMetadata(ctx, sourceHost)
|
||||||
|
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
receive:
|
receive:
|
||||||
for {
|
for count := 0; ; count++ {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
check(fmt.Errorf("context timeout"))
|
check(fmt.Errorf("context timeout"))
|
||||||
|
@ -37,6 +40,20 @@ includes almost all the information but the most sensitive.`,
|
||||||
break receive
|
break receive
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if count != 0 && count%3 == 0 {
|
||||||
|
var proceed bool
|
||||||
|
prompt := &survey.Confirm{Message: "Next page?", Default: true}
|
||||||
|
check(survey.AskOne(prompt, &proceed, nil))
|
||||||
|
|
||||||
|
if !proceed {
|
||||||
|
break receive
|
||||||
|
}
|
||||||
|
|
||||||
|
clearCmd := exec.Command("clear")
|
||||||
|
clearCmd.Stdout = os.Stdout
|
||||||
|
check(clearCmd.Run())
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println(md)
|
fmt.Println(md)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue