Skip to content

Commit

Permalink
Add docker image for ipfix-collector
Browse files Browse the repository at this point in the history
Also add github workflow to push to harbor registry.
  • Loading branch information
srikartati committed Nov 9, 2020
1 parent 5232302 commit 0552af4
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build and push the latest image if needed

on:
pull_request:
branches:
- master
- release-*
push:
branches:
- master
- release-*

jobs:
build:
if: ${{ github.event_name == 'push' }}
runs-on: [ubuntu-18.04]
steps:
- uses: actions/checkout@v2
- name: Build ipfix-collector Docker image
run: |
make collector
make docker-collector
- name: Push ipfix-collector Docker image to harbor registry
if: ${{ github.repository == 'vmware/go-ipfix' && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
env:
HARBOR_REGISTRY: ${{ secrets.HARBOR_REGISTRY }}
HARBOR_USERNAME: ${{ secrets.HARBOR_USERNAME }}
HARBOR_PASSWORD: ${{ secrets.HARBOR_PASSWORD }}
run: |
echo "$HARBOR_PASSWORD" | docker login -u "$HARBOR_USERNAME" --password-stdin $HARBOR_REGISTRY
docker push goipfix/ipfix-collector:latest
24 changes: 24 additions & 0 deletions .github/workflows/build_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Build and push a release image

on:
push:
tags:
- v*

jobs:
build:
runs-on: [ubuntu-18.04]
steps:
- uses: actions/checkout@v2
- name: Build go-ipfix Docker images and push to harbor registry
env:
HARBOR_REGISTRY: ${{ secrets.HARBOR_REGISTRY }}
HARBOR_USERNAME: ${{ secrets.HARBOR_USERNAME }}
HARBOR_PASSWORD: ${{ secrets.HARBOR_PASSWORD }}
TAG: ${{ github.ref }}
run: |
make collector
make docker-collector
echo "$HARBOR_PASSWORD" | docker login -u "$HARBOR_USERNAME" --password-stdin $HARBOR_REGISTRY
docker tag goipfix/ipfix-collector goipfix/ipfix-collector:"${TAG:10}"
docker push goipfix/ipfix-collector:"${TAG:10}"
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ golangci:
collector:
@mkdir -p $(BINDIR)
GOOS=linux $(GO) build -o $(BINDIR) github.com/vmware/go-ipfix/cmd/collector/

### Docker images ###

docker-collector:
@echo "===> Building goipfix/ipfix-collector Docker image <==="
docker build --pull -t goipfix/ipfix-collector -f build/images/Dockerfile.build.collector .
21 changes: 21 additions & 0 deletions build/images/Dockerfile.build.collector
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.15 as go-ipfix-build

WORKDIR /go-ipfix

COPY go.mod /go-ipfix/go.mod

RUN go mod download

COPY . /go-ipfix

RUN make collector


FROM antrea/base-ubuntu:2.14.0

FROM ubuntu:18.04

LABEL maintainer="go-ipfix"
LABEL description="A Docker image based on Ubuntu 18.04 which contains a IPFIX collector"

COPY --from=go-ipfix-build /go-ipfix/bin/collector /usr/local/bin/

0 comments on commit 0552af4

Please sign in to comment.