Skip to content

Commit

Permalink
modified dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
maitegm committed Oct 1, 2020
1 parent 3fa6b5e commit 87c0735
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dontprobe_list.txt
config.yml
license_key_geoip.txt

55 changes: 38 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,51 @@
# Start from the latest golang base image
FROM golang:latest

ENV GOOS=linux\
GOARCH=amd64
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64

WORKDIR /github.com/niclabs/Observatorio
#WORKDIR /github.com/niclabs/Observatorio/

COPY . .
#ADD . /github.com/niclabs/Observatorio/

# Postgres
#EXPOSE 5432
# Download all the dependencies
#RUN go get github.com/miekg/dns
#RUN go get github.com/oschwald/geoip2-golang
#RUN go get github.com/lib/pq
#RUN go get gopkg.in/yaml.v2

# Build the dns package
#RUN go build github.com/miekg/dns

# Get dependencies
RUN apt update
#CMD ["go", "run", "main/main.go"]

RUN apt install -y libgeoip-dev
#libgeoip1 geoip-bin

# Create database
RUN apt-get install -y postgresql
USER postgres
RUN /etc/init.d/postgresql start &&\
psql --command "CREATE USER obslac WITH SUPERUSER PASSWORD 'password';" &&\
createdb -O obslac observatorio
WORKDIR $GOPATH/src/github.com/niclabs/Observatorio

# Copy and download dependency using go mod
COPY go.mod .
COPY go.sum .
RUN go mod download

# Copy the code into the container
COPY . .

USER root
# Build the application
#RUN go build -o main .

RUN go build -o main ./src/main
# Move to /dist directory as the place for resulting binary folder
#WORKDIR /dist

CMD ["./main"]
# Copy binary from build to main folder
#RUN cp $GOPATH/src/github.com/niclabs/Observatorio/main .

# Export necessary port
EXPOSE 5432

# Command to run when starting the container
##CMD ["/dist/main"]
CMD ["go", "run", "main/main.go"]
6 changes: 1 addition & 5 deletions dataAnalyzer/dataAnalyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@ package main
import (
"database/sql"
_ "github.com/lib/pq"
"github.com/niclabs/Observatorio/src/dbController"
//"github.com/miekg/dns"
"github.com/niclabs/Observatorio/dbController"
"fmt"
"log"
"sync"
"time"
// "github.com/maitegm/dnsUtils"
"encoding/csv"
"os"
"strconv"
//"flag"
//"github.com/howeyc/gopass"
"gopkg.in/yaml.v2"
)

Expand Down
8 changes: 4 additions & 4 deletions dataCollector/dataCollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"fmt"
_ "github.com/lib/pq"
"github.com/miekg/dns"
"github.com/niclabs/Observatorio/src/dbController"
"github.com/niclabs/Observatorio/src/dnsUtils"
"github.com/niclabs/Observatorio/src/geoIPUtils"
"github.com/niclabs/Observatorio/src/utils"
"github.com/niclabs/Observatorio/dbController"
"github.com/niclabs/Observatorio/dnsUtils"
"github.com/niclabs/Observatorio/geoIPUtils"
"github.com/niclabs/Observatorio/utils"
"github.com/oschwald/geoip2-golang"
"net"
"runtime"
Expand Down
12 changes: 12 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Observatorio

go 1.15

require (
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c
github.com/korylprince/ipnetgen v0.0.0-20160712025547-34a2abb431f4
github.com/lib/pq v1.8.0
github.com/miekg/dns v1.1.31
github.com/oschwald/geoip2-golang v1.4.0
gopkg.in/yaml.v2 v2.3.0
)
42 changes: 42 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c h1:aY2hhxLhjEAbfXOx2nRJxCXezC6CO2V/yN+OCr1srtk=
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs=
github.com/korylprince/ipnetgen v0.0.0-20160712025547-34a2abb431f4 h1:yMBxUzMGyS40obSiIkcj6d8HllfujIcwftQDPDK64Hg=
github.com/korylprince/ipnetgen v0.0.0-20160712025547-34a2abb431f4/go.mod h1:WUy1jS5kZzPfL2gWyJq3LAV5XzK71v9G/NMcT0TAYVo=
github.com/lib/pq v1.8.0 h1:9xohqzkUwzR4Ga4ivdTcawVS89YSDVxXMa3xJX3cGzg=
github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/miekg/dns v1.1.31 h1:sJFOl9BgwbYAWOGEwr61FU28pqsBNdpRBnhGXtO06Oo=
github.com/miekg/dns v1.1.31/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
github.com/oschwald/geoip2-golang v1.4.0 h1:5RlrjCgRyIGDz/mBmPfnAF4h8k0IAcRv9PvrpOfz+Ug=
github.com/oschwald/geoip2-golang v1.4.0/go.mod h1:8QwxJvRImBH+Zl6Aa6MaIcs5YdlZSTKtzmPGzQqi9ng=
github.com/oschwald/maxminddb-golang v1.6.0 h1:KAJSjdHQ8Kv45nFIbtoLGrGWqHFajOIm7skTyz/+Dls=
github.com/oschwald/maxminddb-golang v1.6.0/go.mod h1:DUJFucBg2cvqx42YmDa/+xHvb0elJtOm3o4aFQ/nb/w=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191224085550-c709ea063b76 h1:Dho5nD6R3PcW2SH1or8vS0dszDaXRxIw55lBX7XiE5g=
golang.org/x/sys v0.0.0-20191224085550-c709ea063b76/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
4 changes: 2 additions & 2 deletions main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"fmt"
"github.com/niclabs/Observatorio/src/dataCollector"
"github.com/niclabs/Observatorio/src/geoIPUtils"
"github.com/niclabs/Observatorio/dataCollector"
"github.com/niclabs/Observatorio/geoIPUtils"
"gopkg.in/yaml.v2"
"os"
)
Expand Down

0 comments on commit 87c0735

Please sign in to comment.