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

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
WORKDIR /
COPY --from=builder /app/previewer .
RUN mkdir -p /assets/cache
CMD ["/previewer"]

View File

@ -1,8 +1,5 @@
docker-build:
sudo docker build -t previewer .
build:
go build -o bin ./cmd/main.go
lint: install-lint-deps
golangci-lint run ./previewer/... ./internal/...
unit-test:
go test -race ./internal/...
@ -10,8 +7,15 @@ unit-test:
integration-test:
go test -v ./cmd/...
lint: install-lint-deps
golangci-lint run ./previewer/... ./internal/...
build:
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:
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 {
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{
capacity: capacity,

View File

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

View File

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