Skip to content

Commit

Permalink
Chore(build): Build Go binary inside image (#394)
Browse files Browse the repository at this point in the history
* Chore(build): Build Go binary inside image

Signed-off-by: udit <[email protected]>

* remove unused Dockerfile

Signed-off-by: udit <[email protected]>

* upadte go version to 1.16

Signed-off-by: udit <[email protected]>

* upadte go version to 1.16

Signed-off-by: udit <[email protected]>

Co-authored-by: Shubham Chaudhary <[email protected]>
  • Loading branch information
uditgaurav and Shubham Chaudhary authored Jul 9, 2021
1 parent babf0c4 commit 095e1d2
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 283 deletions.
58 changes: 26 additions & 32 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,37 @@ on:
types: [opened, synchronize, reopened]

jobs:
lint:
pre-checks:
runs-on: ubuntu-latest
steps:
# Install golang
- uses: actions/setup-go@v2
with:
go-version: '^1.13.1'
go-version: 1.16

# Setup gopath
- name: Setting up GOPATH
run: |
echo "GOPATH=${GITHUB_WORKSPACE}/go" >> $GITHUB_ENV
# Checkout to the latest commit
# On specific directory/path
- uses: actions/checkout@v2
with:
path: go/src/github.com/${{github.repository}}
ref: ${{ github.event.pull_request.head.sha }}

#TODO: Add Dockerfile linting
# Running go-lint
- name: Checking Go-Lint
run : |
sudo apt-get update && sudo apt-get install golint
cd go/src/github.com/${{github.repository}}
make gotasks
build:
needs: pre-checks
runs-on: ubuntu-latest
steps:

# Install golang
- uses: actions/setup-go@v2
with:
go-version: '^1.13.1'
go-version: 1.16

# Setup gopath
- name: Setting up GOPATH
run: |
echo "GOPATH=${GITHUB_WORKSPACE}/go" >> $GITHUB_ENV
# Checkout to the latest commit
# On specific directory/path
- uses: actions/checkout@v2
with:
path: go/src/github.com/${{github.repository}}
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
Expand All @@ -64,20 +49,29 @@ jobs:
with:
version: latest

- name: Build Docker Image
env:
DOCKER_REPO: litmuschaos
DOCKER_IMAGE: go-runner
DOCKER_TAG: ci
run: |
cd go/src/github.com/${{github.repository}}
make build
- name: Build and push
uses: docker/build-push-action@v2
with:
push: false
file: build/Dockerfile
platforms: linux/amd64,linux/arm64
tags: litmuschaos/go-runner:ci

trivy:
trivy:
needs: pre-checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Install golang
- uses: actions/setup-go@v2
with:
go-version: 1.16

- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Build image for trivy scan
run: make build-amd64

- name: setup trivy
run: |
Expand Down
72 changes: 26 additions & 46 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,33 @@ on:
- master
tags-ignore:
- '**'

jobs:
lint:
pre-checks:
runs-on: ubuntu-latest
steps:
# Install golang
- uses: actions/setup-go@v2
with:
go-version: '^1.13.1'

# Setup gopath
- name: Setting up GOPATH
run: |
echo "GOPATH=${GITHUB_WORKSPACE}/go" >> $GITHUB_ENV
# Checkout to the latest commit
# On specific directory/path
go-version: 1.16
- uses: actions/checkout@v2
with:
path: go/src/github.com/${{github.repository}}

#TODO: Add Dockerfile linting
# Running go-lint
- name: Checking Go-Lint
run : |
sudo apt-get update && sudo apt-get install golint
cd go/src/github.com/${{github.repository}}
make gotasks
push:
needs: pre-checks
runs-on: ubuntu-latest
steps:

# Install golang
- uses: actions/setup-go@v2
with:
go-version: '^1.13.1'

# Setup gopath
- name: Setting up GOPATH
run: |
echo "GOPATH=${GITHUB_WORKSPACE}/go" >> $GITHUB_ENV
# Checkout to the latest commit
# On specific directory/path
go-version: 1.16
- uses: actions/checkout@v2
with:
path: go/src/github.com/${{github.repository}}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
Expand All @@ -66,31 +45,32 @@ jobs:
with:
version: latest

- name: Build Docker Image
env:
DOCKER_REPO: litmuschaos
DOCKER_IMAGE: go-runner
DOCKER_TAG: ci
run: |
cd go/src/github.com/${{github.repository}}
make experiment-build
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DNAME }}
password: ${{ secrets.DPASS }}

- name: Push Docker Image
env:
DOCKER_REPO: litmuschaos
DOCKER_IMAGE: go-runner
DOCKER_TAG: ci
DNAME: ${{ secrets.DNAME }}
DPASS: ${{ secrets.DPASS }}
run: |
cd go/src/github.com/${{github.repository}}
make push
- name: Build and push
uses: docker/build-push-action@v2
with:
push: true
file: build/Dockerfile
platforms: linux/amd64,linux/arm64
tags: litmuschaos/go-runner:ci

trivy:
trivy:
needs: pre-checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Install golang
- uses: actions/setup-go@v2
with:
go-version: 1.16
- uses: actions/checkout@v2

- name: Build image for trivy scan
run: make build-amd64

- name: setup trivy
run: |
Expand Down
77 changes: 28 additions & 49 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,30 @@ on:
- '**'

jobs:
lint:
pre-checks:
runs-on: ubuntu-latest
steps:
# Install golang
- uses: actions/setup-go@v2
with:
go-version: '^1.13.1'

# Setup gopath
- name: Setting up GOPATH
run: |
echo "GOPATH=${GITHUB_WORKSPACE}/go" >> $GITHUB_ENV
# Checkout to the latest commit
# On specific directory/path
go-version: 1.16
- uses: actions/checkout@v2
with:
path: go/src/github.com/${{github.repository}}

#TODO: Add Dockerfile linting
# Running go-lint
- name: Checking Go-Lint
run : |
sudo apt-get update && sudo apt-get install golint
cd go/src/github.com/${{github.repository}}
make gotasks
push:
needs: pre-checks
runs-on: ubuntu-latest
steps:

# Install golang
- uses: actions/setup-go@v2
with:
go-version: '^1.13.1'

# Setup gopath
- name: Setting up GOPATH
run: |
echo "GOPATH=${GITHUB_WORKSPACE}/go" >> $GITHUB_ENV
# Checkout to the latest commit
# On specific directory/path
go-version: 1.16
- uses: actions/checkout@v2
with:
path: go/src/github.com/${{github.repository}}

- name: Set Tag
run: |
Expand All @@ -75,33 +53,34 @@ jobs:
with:
version: latest

- name: Build Docker Image
env:
DOCKER_REPO: litmuschaos
DOCKER_IMAGE: go-runner
DOCKER_TAG: ${RELEASE_TAG}
DNAME: ${{ secrets.DNAME }}
DPASS: ${{ secrets.DPASS }}
run: |
cd go/src/github.com/${{github.repository}}
make experiment-build
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DNAME }}
password: ${{ secrets.DPASS }}

- name: Push Docker Image
env:
DOCKER_REPO: litmuschaos
DOCKER_IMAGE: go-runner
DOCKER_TAG: ${RELEASE_TAG}
DNAME: ${{ secrets.DNAME }}
DPASS: ${{ secrets.DPASS }}
run: |
cd go/src/github.com/${{github.repository}}
make push
- name: Build and push
uses: docker/build-push-action@v2
env:
RELEASE_TAG: ${{ env.RELEASE_TAG }}
with:
push: true
file: build/Dockerfile
platforms: linux/amd64,linux/arm64
tags: litmuschaos/go-runner:${{ env.RELEASE_TAG }},litmuschaos/go-runner:latest

trivy:
trivy:
needs: pre-checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Install golang
- uses: actions/setup-go@v2
with:
go-version: 1.16
- uses: actions/checkout@v2

- name: Build image for trivy scan
run: make build-amd64

- name: setup trivy
run: |
Expand Down
Loading

0 comments on commit 095e1d2

Please sign in to comment.