Skip to content
This repository has been archived by the owner on Oct 14, 2019. It is now read-only.

Commit

Permalink
Merge pull request #382 from thecsw/http_logs
Browse files Browse the repository at this point in the history
Adding goaccess support to the system.
  • Loading branch information
thecsw committed May 16, 2019
2 parents 92ed379 + a8b50c4 commit b41af28
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 70 deletions.
7 changes: 5 additions & 2 deletions .goaccess.caddy.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
log-format %h - - [%d:%t] "%r" %s %b
time-format %T %z
time-format %H:%M:%S
date-format %d/%b/%Y
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
log-file /srv/logs/access.log
output /srv/report/index.html
real-time-html true
13 changes: 7 additions & 6 deletions api/api.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package main

import (
"fmt"
"log"
"net/http"
"os"
"os/signal"
"time"

"./coins"
"./firm"
"./firms"
"./investments"
"./investor"
"./investors"
"./summary"
"fmt"
"github.com/gorilla/mux"
"log"
"net/http"
"os"
"os/signal"
"time"
)

func HelloThere() func(w http.ResponseWriter, r *http.Request) {
Expand Down
5 changes: 3 additions & 2 deletions api/coins/coins.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package coins

import (
"../utils"
"database/sql"
"encoding/json"
"fmt"
_ "github.com/go-sql-driver/mysql"
"log"
"net/http"

"../utils"
_ "github.com/go-sql-driver/mysql"
)

// Coins invested
Expand Down
7 changes: 4 additions & 3 deletions api/firm/firm.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package firm

import (
"../utils"
"database/sql"
"encoding/json"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/gorilla/mux"
"log"
"net/http"
"regexp"

"../utils"
_ "github.com/go-sql-driver/mysql"
"github.com/gorilla/mux"
)

type firm struct {
Expand Down
5 changes: 3 additions & 2 deletions api/firms/firms.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package firms

import (
"../utils"
"database/sql"
"encoding/json"
"fmt"
_ "github.com/go-sql-driver/mysql"
"log"
"net/http"

"../utils"
_ "github.com/go-sql-driver/mysql"
)

type firm struct {
Expand Down
7 changes: 4 additions & 3 deletions api/investments/investments.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package investments

import (
"../utils"
"database/sql"
"encoding/json"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/gorilla/mux"
"log"
"net/http"
"regexp"

"../utils"
_ "github.com/go-sql-driver/mysql"
"github.com/gorilla/mux"
)

type investment struct {
Expand Down
7 changes: 4 additions & 3 deletions api/investor/investor.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package investor

import (
"../utils"
"database/sql"
"encoding/json"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/gorilla/mux"
"log"
"net/http"
"regexp"

"../utils"
_ "github.com/go-sql-driver/mysql"
"github.com/gorilla/mux"
)

type investor struct {
Expand Down
5 changes: 3 additions & 2 deletions api/investors/investors.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package investors

import (
"../utils"
"database/sql"
"encoding/json"
"fmt"
_ "github.com/go-sql-driver/mysql"
"log"
"net/http"
"time"

"../utils"
_ "github.com/go-sql-driver/mysql"
)

type investor struct {
Expand Down
7 changes: 4 additions & 3 deletions api/summary/summary.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package summary

import (
"encoding/json"
"fmt"
"net/http"

"../coins"
"../investments"
"../investors"
"../utils"
"encoding/json"
"fmt"
_ "github.com/go-sql-driver/mysql"
"net/http"
)

func Summary() func(w http.ResponseWriter, r *http.Request) {
Expand Down
23 changes: 0 additions & 23 deletions docker-compose.override.yml.prod

This file was deleted.

19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,30 @@ services:
restart: unless-stopped
ports:
- 2015:2015
- 80:80
- 443:443
volumes:
- "/data/memeinvestor/caddy/data:/root/.caddy"
- "/data/memeinvestor/caddy/logs:/var/log"
- "/data/memeinvestor/goaccess/html:/site/goaccess"

mysql:
image: mariadb:10.2.15
env_file: .env
restart: unless-stopped
ports:
- 127.0.0.1:3306:3306
volumes:
- "/data/memeinvestor/mysql:/var/lib/mysql"

goaccess:
build:
context: .
dockerfile: docker/Dockerfile-goaccess
entrypoint: goaccess --config-file=/etc/.goaccess.caddy.conf
volumes:
- "/data/memeinvestor/caddy/logs:/srv/logs"
- "/data/memeinvestor/goaccess/data:/srv/data"
- "/data/memeinvestor/goaccess/html:/srv/report"
depends_on:
- http
15 changes: 9 additions & 6 deletions docker/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
memes.market {
redir https://meme.market
}

{$CADDY_WEB_ADDRESS} {
cors
root /static
root /srv
gzip
proxy /api/ api:5000 {
without /api/
transparent
}

log / stdout
log / /var/log/access.log "{combined}"
errors stdout
}

{$CADDY_WEB_ADDRESS}/go {
basicauth / admin password
root /site/goaccess
gzip
}
18 changes: 3 additions & 15 deletions docker/Dockerfile-caddy
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
FROM alpine
FROM abiosoft/caddy

RUN apk add --update --no-cache \
bash \
curl

RUN curl https://getcaddy.com | bash -s personal http.cors

WORKDIR /caddy

COPY ./docker/Caddyfile /caddy
COPY ./docs /static

EXPOSE 80 443 2015

CMD [ "caddy" ]
COPY ./docker/Caddyfile /etc
COPY ./docs /srv
4 changes: 4 additions & 0 deletions docker/Dockerfile-goaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM allinurl/goaccess

COPY ./.goaccess.caddy.conf /etc
RUN touch /srv/logs/caddy.log

0 comments on commit b41af28

Please sign in to comment.