Совсем все починил.

master
Andrey Ivanov 2020-11-08 16:51:13 +03:00 committed by tiburon
parent 8777f33c6e
commit 3a93bd85a1
5 changed files with 19 additions and 10 deletions

View File

@ -8,4 +8,5 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o prev
FROM alpine:latest FROM alpine:latest
WORKDIR / WORKDIR /
COPY --from=builder /app/previewer . COPY --from=builder /app/previewer .
RUN mkdir -p /assets/cache
CMD ["/previewer"] CMD ["/previewer"]

View File

@ -1,8 +1,5 @@
docker-build: lint: install-lint-deps
sudo docker build -t previewer . golangci-lint run ./previewer/... ./internal/...
build:
go build -o bin ./cmd/main.go
unit-test: unit-test:
go test -race ./internal/... go test -race ./internal/...
@ -10,8 +7,15 @@ unit-test:
integration-test: integration-test:
go test -v ./cmd/... go test -v ./cmd/...
lint: install-lint-deps build:
golangci-lint run ./previewer/... ./internal/... go build -o bin ./cmd/main.go
docker-build:
sudo docker build -t previewer .
docker-run:
sudo docker run -p 8080:8080 previewer
install-lint-deps: install-lint-deps:
rm -rf $(shell go env GOPATH)/bin/golangci-lint rm -rf $(shell go env GOPATH)/bin/golangci-lint

View File

@ -32,7 +32,11 @@ type Item struct {
func NewCache(capacity int, path string) Cache { func NewCache(capacity int, path string) Cache {
if _, err := ioutil.ReadDir(path); err != nil { if _, err := ioutil.ReadDir(path); err != nil {
log.Fatalf("cache directory %s not exists: %s", path, err.Error()) log.Printf("cache directory %s not exists. Try to create.\n", path)
err = os.MkdirAll(path, 0777)
if err != nil {
log.Fatalf("can't create cache directory %s: %s", path, err.Error())
}
} }
return &lruCache{ return &lruCache{
capacity: capacity, capacity: capacity,

View File

@ -49,7 +49,7 @@ func (c *Config) SetDefault() {
c.Cache = struct { c.Cache = struct {
Capacity int Capacity int
StoragePath string StoragePath string
}{Capacity: 20, StoragePath: "../assets/cache"} }{Capacity: 20, StoragePath: "./assets/cache"}
c.Query = struct{ Timeout int }{Timeout: 15} c.Query = struct{ Timeout int }{Timeout: 15}
c.Log = struct { c.Log = struct {
File string File string

View File

@ -38,7 +38,7 @@ func New(conf Config) (Interface, error) {
c := amitralog.Configuration{ c := amitralog.Configuration{
EnableConsole: !conf.MuteStdout, EnableConsole: !conf.MuteStdout,
ConsoleLevel: amitralog.Fatal, ConsoleLevel: amitralog.Debug,
ConsoleJSONFormat: false, ConsoleJSONFormat: false,
EnableFile: true, EnableFile: true,
FileLevel: strings.ToLower(conf.Level), FileLevel: strings.ToLower(conf.Level),