Skip to content

Commit

Permalink
Various changes
Browse files Browse the repository at this point in the history
Update documentation
Move mort files to pkg dir
Added new kind of transform
  • Loading branch information
aldor007 committed Dec 2, 2017
1 parent 5ea509e commit 8c8d25b
Show file tree
Hide file tree
Showing 50 changed files with 597 additions and 155 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
No release yet ;)
* 0.1.0
* Feature: New kind of transformation presets-query it combines presets and query in on kind
* Feature: Added gravity to crop transform
* Feature: Allow to configure server properties like listen addr, cache size etc
* Bugfix: Fixed position for watermark transform
* Bugfix: Change collapse key from request path to object key
* 0.0.1
* Initial release
7 changes: 6 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
So you want to contribute ? Awesome! Welcome aboard!
So you want to contribute? Awesome! Welcome aboard!

## Steps

Expand All @@ -23,3 +23,8 @@ Running the tests is as easy as:

You should see the results of running your tests after an instant.


Format code

make format

31 changes: 29 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM golang:1.9.2-stretch as bui
FROM golang:1.9.2-stretch as builder

ENV LIBVIPS_VERSION 8.5.9
ENV DEP_VERSION v0.3.2
Expand Down Expand Up @@ -50,10 +50,37 @@ ADD . /go/src/github.com/aldor007/mort

RUN cd /go/src/github.com/aldor007/mort && dep ensure -vendor-only
# RUN build
RUN cd /go/src/github.com/aldor007/mort; go build cmd/mort/mort.go; cp mort /go/mort; cp -r /go/src/github.com/aldor007/mort/configuration /go/
RUN cd /go; go build -o /go/mort src/github.com/aldor007cmd/mort/mort.go; cp -r /go/src/github.com/aldor007/mort/configuration /go/
# clean up
RUN rm -rf /go/src; rm -rf /go/pkg; rm -rf /usr/share/; rm -rf /usr/include/


#FROM golang:1.9.2-stretch

FROM debian:stretch

RUN \
# Install dependencies
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
libglib2.0 libjpeg libpng \
libwebpv libtiff5 libgifv libexifv libxml2 libpoppler-glib \
libmagickwand libpango1.0 libmatio libopenslidev libcfitsio \
libgsf-1 fftw3 liborc-0.4 librsvg2 && \
# Clean up
apt-get remove -y curl automake build-essential && \
apt-get autoremove -y && \
apt-get autoclean && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# clean up
RUN rm -rf /go/src; rm -rf /usr/share/; rm -rf /usr/include/

COPY --from=builder /usr/local/lib /usr/local/lib
RUN ldconfig
COPY --from=builder /go/mort /go/mort

# Run the outyet command by default when the container starts.
ENTRYPOINT ["/go/mort"]

Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Mort
[![Build Status](https://travis-ci.org/Aldor007/mort.png)](https://travis-ci.org/aldor007/mort) [![Docker](https://img.shields.io/badge/docker-aldor007/mort-blue.svg)](https://hub.docker.com/r/aldor007/mort/) [![Docker Registry](https://img.shields.io/docker/pulls/aldor007/mort.svg)](https://hub.docker.com/r/aldor007/mort/) [![Go Report Card](http://goreportcard.com/badge/aldor007/mort)](http://goreportcard.com/report/aldor007/mort) [![Godoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://godoc.org/github.com/aldor007/mort) [![Releases](https://img.shields.io/github/release/aldor007/mort/all.svg?style=flat-square)](https://github.com/aldor007/mort/releases) [![LICENSE](https://img.shields.io/github/license/aldor007/mort.svg?style=flat-square)](https://github.com/aldor007/mort/blob/master/LICENSE.md)
[![Build Status](https://travis-ci.org/Aldor007/mort.png)](https://travis-ci.org/aldor007/mort) [![Docker](https://img.shields.io/badge/docker-aldor007/mort-blue.svg)](https://hub.docker.com/r/aldor007/mort/pkg/) [![Docker Registry](https://img.shields.io/docker/pulls/aldor007/mort.svg)](https://hub.docker.com/r/aldor007/mort/pkg/) [![Go Report Card](http://goreportcard.com/badge/aldor007/mort)](http://goreportcard.com/report/aldor007/mort) [![Godoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://godoc.org/github.com/aldor007/mort) [![Releases](https://img.shields.io/github/release/aldor007/mort/all.svg?style=flat-square)](https://github.com/aldor007/mort/releases) [![LICENSE](https://img.shields.io/github/license/aldor007/mort.svg?style=flat-square)](https://github.com/aldor007/mort/blob/master/LICENSE.md)

<img src="https://mort.mkaciuba.com/demo/medium/gopher.png" width="500px"/>

Expand Down Expand Up @@ -114,7 +114,7 @@ Usage of mort
Example configuration used for providing demo images:

```yaml
headers: # overwritten all response headers of given status. This field is optional
headers: # add or overwrite all response headers of given status. This field is optional
- statusCodes: [200]
values:
"cache-control": "max-age=84000, public"
Expand Down Expand Up @@ -175,8 +175,9 @@ buckets: # list of available buckets

```
List of all image operations can be found in [Image-Operations.md](doc/Image-Operations.md)
More examples of configuration and use case can be found in TODO

More details about configuration can be found in [Configuration.md](doc/Configuration.md)

## Debian and Ubuntu

I will provide Debian package when we will be completely stable ;)
Expand Down
43 changes: 23 additions & 20 deletions cmd/mort/mort.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ import (
"github.com/go-chi/chi/middleware"
"go.uber.org/zap"

"github.com/aldor007/mort/config"
"github.com/aldor007/mort/lock"
"github.com/aldor007/mort/log"
mortMiddleware "github.com/aldor007/mort/middleware"
"github.com/aldor007/mort/object"
"github.com/aldor007/mort/processor"
"github.com/aldor007/mort/response"
"github.com/aldor007/mort/throttler"
"github.com/aldor007/mort/pkg/config"
"github.com/aldor007/mort/pkg/lock"
"github.com/aldor007/mort/pkg/log"
mortMiddleware "github.com/aldor007/mort/pkg/middleware"
"github.com/aldor007/mort/pkg/object"
"github.com/aldor007/mort/pkg/processor"
"github.com/aldor007/mort/pkg/response"
"github.com/aldor007/mort/pkg/throttler"
"os"
"os/signal"
"syscall"
)

const (
// Version of mort
Version = "0.0.1"
Version = "0.1.0"
// BANNER just fancy command line banner
BANNER = `
/\/\ ___ _ __| |_
Expand All @@ -38,7 +38,7 @@ const (

var debugServer *http.Server

func debugListener() {
func debugListener(mortConfig *config.Config) {
if debugServer != nil {
debugServer.Close()
return
Expand All @@ -47,7 +47,7 @@ func debugListener() {
router := chi.NewRouter()
router.Mount("/", middleware.Profiler())
s := &http.Server{
Addr: "localhost:8081",
Addr: mortConfig.Server.DebugListen,
ReadTimeout: 2 * time.Minute,
WriteTimeout: 2 * time.Minute,
Handler: router,
Expand All @@ -59,23 +59,26 @@ func debugListener() {

func main() {
configPath := flag.String("config", "configuration/config.yml", "Path to configuration")
listenAddr := flag.String("listen", ":8080", "Listen addr")
debug := flag.Bool("debug", false, "enable debug mode")
flag.Parse()

fmt.Printf(BANNER, "v"+Version)
fmt.Printf("Config file %s listen addr %s debug: %t pid: %d \n", *configPath, *listenAddr, *debug, os.Getpid())

logger, _ := zap.NewProduction()
//logger, _ := zap.NewDevelopment()
zap.ReplaceGlobals(logger)
log.RegisterLogger(logger)
router := chi.NewRouter()
rp := processor.NewRequestProcessor(5, lock.NewMemoryLock(), throttler.NewBucketThrottler(10))

imgConfig := config.GetInstance()
imgConfig.Load(*configPath)
err := imgConfig.Load(*configPath)

if err != nil {
panic(err)
}

fmt.Printf(BANNER, "v"+Version)
fmt.Printf("Config file %s listen addr %s debug: %t pid: %d \n", *configPath, imgConfig.Server.Listen, *debug, os.Getpid())

rp := processor.NewRequestProcessor(imgConfig.Server, lock.NewMemoryLock(), throttler.NewBucketThrottler(10))
s3Auth := mortMiddleware.NewS3AuthMiddleware(imgConfig)

router.Use(s3Auth.Handler)
Expand Down Expand Up @@ -111,14 +114,14 @@ func main() {
}))

s := &http.Server{
Addr: *listenAddr,
Addr: imgConfig.Server.Listen,
ReadTimeout: 2 * time.Minute,
WriteTimeout: 2 * time.Minute,
Handler: router,
}

if debug != nil && *debug {
go debugListener()
go debugListener(imgConfig)
}

signal_chan := make(chan os.Signal, 1)
Expand All @@ -135,7 +138,7 @@ func main() {
} else {
log.Log().Info("Start debug server on port 8081")
}
go debugListener()
go debugListener(imgConfig)
default:
}
}
Expand Down
Loading

0 comments on commit 8c8d25b

Please sign in to comment.