pull/470/merge
RJ Seibert 7 years ago committed by GitHub
commit 27ff88bd58

5
.gitignore vendored

@ -0,0 +1,5 @@
#Eclipse
.project
#OSX
.DS_Store

@ -14,12 +14,16 @@
FROM golang:1.8-alpine
ENV POSTGRESQL_SERVICE_HOST localhost
VOLUME /config
EXPOSE 6060 6061
ADD . /go/src/github.com/coreos/clair/
WORKDIR /go/src/github.com/coreos/clair/
COPY /config.yaml /etc/clair/config.yaml
RUN apk add --no-cache git bzr rpm xz && \
go install -v github.com/coreos/clair/cmd/clair && \
mv /go/bin/clair /clair && \

@ -20,7 +20,7 @@ clair:
options:
# PostgreSQL Connection string
# https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING
source: host=localhost port=5432 user=postgres sslmode=disable statement_timeout=60000
source: host=$POSTGRESQL_SERVICE_HOST port=5432 user=postgres sslmode=disable statement_timeout=60000
# Number of elements kept in the cache
# Values unlikely to change (e.g. namespaces) are cached in order to save prevent needless roundtrips to the database.

@ -22,6 +22,7 @@ import (
"net/url"
"strings"
"time"
"os"
"gopkg.in/yaml.v2"
@ -202,7 +203,12 @@ func openDatabase(registrableComponentConfig database.RegistrableComponentConfig
}
// Open database.
pg.DB, err = sql.Open("postgres", pg.config.Source)
host := os.Getenv("POSTGRESQL_SERVICE_HOST")
modifiedSource := strings.Replace(pg.config.Source, "$POSTGRESQL_SERVICE_HOST", host, -1)
fmt.Println("postgresql hostname replaced: ", modifiedSource)
pg.DB, err = sql.Open("postgres", modifiedSource)
if err != nil {
pg.Close()
return nil, fmt.Errorf("pgsql: could not open database: %v", err)

Loading…
Cancel
Save