diff --git a/cve-alert-fetcher/Dockerfile b/cve-alert-fetcher/Dockerfile new file mode 100644 index 0000000..c6c1256 --- /dev/null +++ b/cve-alert-fetcher/Dockerfile @@ -0,0 +1,25 @@ +FROM golang:1.13.7-alpine3.10 AS builder + +WORKDIR /build + +# enables caching of modules as a Docker layer +COPY go.mod . +COPY go.sum . +RUN set -eu -o pipefail +RUN go mod download + +# copy the rest of the directory to +COPY . . + +# build the program +RUN GO111MODULE=on CGO_ENABLED=0 go build -a -o ./out/app ./cve-alert-fetcher + +################ +# run program +################ + +FROM alpine:3.10 + +COPY --from=builder /build/out/app . + +ENTRYPOINT ["./app", "--init-db"] diff --git a/cve-alert-restapi/Dockerfile b/cve-alert-restapi/Dockerfile new file mode 100644 index 0000000..7ae80b1 --- /dev/null +++ b/cve-alert-restapi/Dockerfile @@ -0,0 +1,25 @@ +FROM golang:1.13.7-alpine3.10 AS builder + +WORKDIR /build + +# enables caching of modules as a Docker layer +COPY go.mod . +COPY go.sum . +RUN set -eu -o pipefail +RUN go mod download + +# copy the rest of the directory to +COPY . . + +# build the program +RUN GO111MODULE=on CGO_ENABLED=0 go build -a -o ./out/app ./cve-alert-restapi + +################ +# run program +################ + +FROM alpine:3.10 + +COPY --from=builder /build/out/app . + +ENTRYPOINT ["./app"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..597aced --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,42 @@ +version: '3.1' + +services: + db: + image: mysql + command: --default-authentication-plugin=mysql_native_password + restart: always + environment: + MYSQL_ROOT_PASSWORD: example + MYSQL_USER: user + MYSQL_PASSWORD: password + MYSQL_DATABASE: cve_alert_db + ports: + - 3306:3306 + volumes: + - data:/var/lib/mysql + fetcher: + image: cve-alert-manager/fetcher + build: + context: . + dockerfile: ./cve-alert-fetcher/Dockerfile + environment: + CVE_ALERT_MANAGER_CVEDATABASE_DATASOURCENAME: "user:password@tcp(db)/cve_alert_db" + volumes: + - ./config:/var/opt/cve-alert-manager + depends_on: + - db + api: + image: cve-alert-manager/api + build: + context: . + dockerfile: ./cve-alert-restapi/ + restart: always + environment: + CVE_ALERT_MANAGER_CVEDATABASE_DATASOURCENAME: "user:password@tcp(db)/cve_alert_db" + volumes: + - ./config:/var/opt/cve-alert-manager + depends_on: + - db + +volumes: + data: \ No newline at end of file