mirror of
https://github.com/simon987/Architeuthis.git
synced 2025-04-10 13:36:41 +00:00
dockerize app
This commit is contained in:
parent
816874772e
commit
482ffe960f
31
Dockerfile
Normal file
31
Dockerfile
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
FROM golang:1.13-alpine as builder
|
||||||
|
|
||||||
|
ENV GO111MODULE=on
|
||||||
|
|
||||||
|
# Create the user and group files to run unprivileged
|
||||||
|
RUN mkdir /user && \
|
||||||
|
echo 'nobody:x:65534:65534:nobody:/:' > /user/passwd && \
|
||||||
|
echo 'nobody:x:65534:' > /user/group
|
||||||
|
|
||||||
|
RUN apk update && apk add --no-cache git ca-certificates tzdata
|
||||||
|
RUN mkdir /build
|
||||||
|
COPY . /build/
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
COPY ./ ./
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o architeuthis .
|
||||||
|
|
||||||
|
FROM scratch AS final
|
||||||
|
LABEL author="simon987 <me@simon987.net>"
|
||||||
|
|
||||||
|
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||||
|
COPY --from=builder /user/group /user/passwd /etc/
|
||||||
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
COPY --from=builder /build/architeuthis /
|
||||||
|
COPY --from=builder /build/config.json /
|
||||||
|
|
||||||
|
WORKDIR /
|
||||||
|
USER nobody:nobody
|
||||||
|
ENTRYPOINT ["/architeuthis"]
|
||||||
|
|
||||||
|
EXPOSE 5050
|
@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"addr": "localhost:5050",
|
"addr": "0.0.0.0:5050",
|
||||||
"timeout": "15s",
|
"timeout": "15s",
|
||||||
"wait": "0.5s",
|
"wait": "0.5s",
|
||||||
"multiplier": 1,
|
"multiplier": 1,
|
||||||
"retries": 3,
|
"retries": 3,
|
||||||
"influx_url": "http://localhost:8086",
|
"influx_url": "http://influxdb:8086",
|
||||||
"influx_user": "",
|
"influx_user": "",
|
||||||
"influx_pass": "",
|
"influx_pass": "",
|
||||||
"max_error": 0.4,
|
"max_error": 0.4,
|
||||||
"redis_url": "localhost:6379",
|
"redis_url": "redis:6379",
|
||||||
"hosts": [
|
"hosts": [
|
||||||
{
|
{
|
||||||
"host": "*",
|
"host": "*",
|
||||||
|
22
docker-compose.yml
Normal file
22
docker-compose.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
architeuthis:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "5050:5050"
|
||||||
|
redis:
|
||||||
|
image: "redis:alpine"
|
||||||
|
|
||||||
|
# (Optional)
|
||||||
|
influxdb:
|
||||||
|
image: "influxdb"
|
||||||
|
environment:
|
||||||
|
- INFLUXDB_DB=architeuthis
|
||||||
|
grafana:
|
||||||
|
build: ./grafana
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
environment:
|
||||||
|
- GF_SECURITY_ADMIN_PASSWORD=changeme
|
||||||
|
|
2
grafana/Dockerfile
Normal file
2
grafana/Dockerfile
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
FROM grafana/grafana
|
||||||
|
COPY ./provisioning /etc/grafana/provisioning
|
12
grafana/provisioning/dashboards/dashboard.yml
Normal file
12
grafana/provisioning/dashboards/dashboard.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
apiVersion: 1
|
||||||
|
|
||||||
|
providers:
|
||||||
|
- name: 'Architeuthis'
|
||||||
|
orgId: 1
|
||||||
|
folder: ''
|
||||||
|
type: file
|
||||||
|
disableDeletion: false
|
||||||
|
updateIntervalSeconds: 10
|
||||||
|
options:
|
||||||
|
path: /etc/grafana/provisioning/dashboards/model.json
|
||||||
|
|
@ -15,7 +15,7 @@
|
|||||||
"editable": true,
|
"editable": true,
|
||||||
"gnetId": null,
|
"gnetId": null,
|
||||||
"graphTooltip": 0,
|
"graphTooltip": 0,
|
||||||
"id": 1,
|
"id": null,
|
||||||
"links": [],
|
"links": [],
|
||||||
"panels": [
|
"panels": [
|
||||||
{
|
{
|
||||||
@ -774,5 +774,5 @@
|
|||||||
"timezone": "",
|
"timezone": "",
|
||||||
"title": "Architeuthis",
|
"title": "Architeuthis",
|
||||||
"uid": "I2xEOnbZk",
|
"uid": "I2xEOnbZk",
|
||||||
"version": 11
|
"version": 1
|
||||||
}
|
}
|
10
grafana/provisioning/datasources/datasource.yml
Normal file
10
grafana/provisioning/datasources/datasource.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
datasources:
|
||||||
|
- access: 'proxy'
|
||||||
|
editable: true
|
||||||
|
is_default: true
|
||||||
|
name: 'influx'
|
||||||
|
org_id: 1
|
||||||
|
type: 'influxdb'
|
||||||
|
url: 'http://influxdb:8086'
|
||||||
|
database: 'architeuthis'
|
||||||
|
version: 1
|
@ -1,9 +1,14 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
import sys
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from proxybroker import Broker, Checker
|
from proxybroker import Broker, Checker
|
||||||
|
|
||||||
ARCHITEUTHIS_URL = "http://localhost:5050"
|
if len(sys.argv) < 2:
|
||||||
|
print("Architeuthis url required")
|
||||||
|
quit(0)
|
||||||
|
|
||||||
|
ARCHITEUTHIS_URL = sys.argv[1]
|
||||||
|
|
||||||
|
|
||||||
def add_to_architeuthis(name, url):
|
def add_to_architeuthis(name, url):
|
||||||
|
15
main.go
15
main.go
@ -9,13 +9,13 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func New() *Architeuthis {
|
func New() *Architeuthis {
|
||||||
|
|
||||||
a := new(Architeuthis)
|
a := new(Architeuthis)
|
||||||
|
a.reloadConfig()
|
||||||
|
|
||||||
a.redis = redis.NewClient(&redis.Options{
|
a.redis = redis.NewClient(&redis.Options{
|
||||||
Addr: config.RedisUrl,
|
Addr: config.RedisUrl,
|
||||||
@ -61,7 +61,7 @@ func New() *Architeuthis {
|
|||||||
|
|
||||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
_, _ = fmt.Fprint(w, "{\"name\":\"Architeuthis\",\"version\":2.0}")
|
_, _ = fmt.Fprint(w, "{\"name\":\"Architeuthis\",\"version\":2.1}")
|
||||||
})
|
})
|
||||||
|
|
||||||
mux.HandleFunc("/add_proxy", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/add_proxy", func(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -276,20 +276,15 @@ func main() {
|
|||||||
logrus.SetLevel(logrus.TraceLevel)
|
logrus.SetLevel(logrus.TraceLevel)
|
||||||
|
|
||||||
balancer := New()
|
balancer := New()
|
||||||
balancer.reloadConfig()
|
|
||||||
|
|
||||||
var err error
|
var err error = nil
|
||||||
balancer.influxdb, err = influx.NewHTTPClient(influx.HTTPConfig{
|
balancer.influxdb, err = influx.NewHTTPClient(influx.HTTPConfig{
|
||||||
Addr: config.InfluxUrl,
|
Addr: config.InfluxUrl,
|
||||||
Username: config.InfluxUser,
|
Username: config.InfluxUser,
|
||||||
Password: config.InfluxPass,
|
Password: config.InfluxPass,
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
if config.InfluxUrl != "" {
|
panic(err)
|
||||||
_, err = http.Post(config.InfluxUrl+"/query", "application/x-www-form-urlencoded", strings.NewReader("q=CREATE DATABASE \"architeuthis\""))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
balancer.points = make(chan *influx.Point, InfluxDbBufferSize)
|
balancer.points = make(chan *influx.Point, InfluxDbBufferSize)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user