Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerimage for each component and docker-compose for local development #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions cve-alert-fetcher/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
25 changes: 25 additions & 0 deletions cve-alert-restapi/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
42 changes: 42 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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: