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

Release/dev #22

Closed
wants to merge 100 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
e671569
http-echo app dockerised
Mar 18, 2024
bdfee6a
Test pipeline
Mar 19, 2024
b4ef2fb
added a build stage to Jenkinfile
Mar 20, 2024
5b2603e
added a build stage to Jenkinfile
Mar 20, 2024
5c3f849
githubaction workflow integration
Mar 20, 2024
3e54df6
githubaction workflow integration
Mar 20, 2024
81fbba2
githubaction workflow integration
Mar 20, 2024
6f4cc60
githubaction workflow integration
Mar 20, 2024
1f35f79
debugging username password auth
Mar 20, 2024
33e6f4f
debugging username password auth
Mar 20, 2024
c8a5ed5
debugging username password auth
Mar 20, 2024
fa837ea
debugging username password auth
Mar 20, 2024
fb3cb02
debugging username password auth
Mar 20, 2024
8b80a28
debugging username password auth
Mar 20, 2024
a5028be
debugging username password auth
Mar 20, 2024
166e241
debugging username password auth
Mar 20, 2024
0a60579
username and password issue fix
Mar 20, 2024
abaaf6a
helm integration
Mar 21, 2024
f743a3c
Fix: config issue
Mar 21, 2024
464cbc3
Fix: config issue
Mar 21, 2024
4b4af38
Fix: config issue
Mar 21, 2024
c8df2cf
Fix: config issue
Mar 21, 2024
bac8964
Fix: config issue
Mar 21, 2024
7ab8f68
Fix: config issue
Mar 21, 2024
29a8439
Fix: config issue
Mar 21, 2024
4b0ad15
Fix: config issue
Mar 21, 2024
cd6d345
Fix: config issue
Mar 21, 2024
fa1aeba
Fix: config issue
Mar 21, 2024
7ebd4b4
Fix: config issue
Mar 21, 2024
ab580e4
Fix: config issue
Mar 21, 2024
8d58b18
fix auth isse
Mar 22, 2024
9ec771a
code modified
Mar 22, 2024
699654b
code modified
Mar 22, 2024
b185a60
code modified
Mar 22, 2024
4e66f33
code modified
Mar 22, 2024
a6812d7
code modified
Mar 22, 2024
b8a667d
code modified
Mar 22, 2024
2200992
markdown implementation
Mar 23, 2024
0d7511e
markdown implementation
Mar 23, 2024
47c7f84
code fix
Mar 25, 2024
9fcc469
Testing workflow
Mar 25, 2024
1c5e03f
Testing workflow
Mar 25, 2024
5954a32
Testing workflow
Mar 25, 2024
7c86ce7
Testing workflow
Mar 26, 2024
a8921a0
Testing workflow
Mar 26, 2024
cc39b85
Testing workflow
Mar 26, 2024
0ee6710
Testing workflow
Mar 26, 2024
8b27de2
Testing workflow
Mar 26, 2024
74aaaba
Testing workflow
Mar 26, 2024
c5163bf
Testing workflow
Mar 26, 2024
aa3de31
Testing workflow
Mar 26, 2024
9196f55
Testing workflow
Mar 26, 2024
1f87831
Testing workflow
Mar 26, 2024
8c008eb
Testing workflow
Mar 26, 2024
3286148
Testing workflow
Mar 26, 2024
fc99c55
Testing workflow
Mar 26, 2024
b7675f8
Fix: quick pipepline fix
Mar 27, 2024
3c71b8e
Fix: quick pipepline fix
Mar 27, 2024
7bbf31e
Pipeline issue fixed
Mar 28, 2024
2be4879
fix helm issues
Mar 28, 2024
aa78284
Fix kubernetes config issues
Mar 28, 2024
68f719b
Fix kubernetes config issues
Mar 28, 2024
76af06d
Fix kubernetes config issues
Mar 28, 2024
467c784
Fix kubernetes config issues
Mar 28, 2024
a192c1b
Fix kubernetes config issues
Mar 28, 2024
33052c0
Fix kubernetes config issues
Mar 28, 2024
cadd3d5
Fix kubernetes config issues
Mar 29, 2024
207e883
Fix kubernetes config issues
Mar 29, 2024
e183271
Fix kubernetes config issues
Mar 29, 2024
4967cc6
Fix kubernetes config issues
Mar 29, 2024
41c7089
Fix kubernetes config issues
Mar 29, 2024
128f8d7
Fix kubernetes config issues
Mar 29, 2024
02bc8da
Fix kubernetes config issues
Mar 29, 2024
b831c73
Fix kubernetes config issues
Mar 29, 2024
8b78da2
Fix kubernetes config issues
Mar 29, 2024
6b32d87
Fix kubernetes config issues
Mar 29, 2024
8e37266
Fix kubernetes config issues
Mar 29, 2024
74a8564
pipeline docs
Mar 31, 2024
96e50b4
pipeline docs
Mar 31, 2024
289877e
pipeline docs
Mar 31, 2024
415b8d2
pipeline docs
Mar 31, 2024
a5b5cc7
pipeline docs
Mar 31, 2024
b16fe3b
pipeline docs
Apr 1, 2024
af840e7
pipeline docs
Apr 1, 2024
b497cb7
Fix kubernetes config issues
Apr 1, 2024
e0fd2f7
Fix kubernetes config issues
Apr 1, 2024
9e4a971
Fix kubernetes config issues
Apr 1, 2024
4216b4d
Fix kubernetes config issues
Apr 2, 2024
7ca66d7
Fix kubernetes config issues
Apr 2, 2024
efa62fd
Fix kubernetes config issues
Apr 2, 2024
0f6b818
Fix kubernetes config issues
Apr 3, 2024
ec4a035
Fix kubernetes config issues
Apr 3, 2024
8d745b6
Fix kubernetes config issues
Apr 3, 2024
2093b59
Fix kubernetes config issues
Apr 3, 2024
bbb7781
Fix kubernetes config issues
Apr 3, 2024
1648075
Fix kubernetes config issues
Apr 3, 2024
b029879
Fix kubernetes config issues
Apr 3, 2024
61901b9
Fix kubernetes config issues
Apr 3, 2024
f5fece7
Fix kubernetes config issues
Apr 3, 2024
1ff4867
Fix kubernetes config issues
Apr 3, 2024
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
Empty file modified .github/CODEOWNERS
100644 → 100755
Empty file.
274 changes: 89 additions & 185 deletions .github/workflows/build.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,194 +1,98 @@
name: build

on: [workflow_dispatch, push]

env:
PKG_NAME: "http-echo"
# name: ci

# on:
# push:
# branches:
# - "release/dev"

# jobs:
# build:
# runs-on: ubuntu-latest
# steps:
# -
# name: Checkout
# uses: actions/checkout@v4
# -
# name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

# -
# name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# -
# name: Build and push
# uses: docker/build-push-action@v5
# with:
# context: .
# file: ./Dockerfile
# push: true
# tags: ${{ secrets.DOCKERHUB_USERNAME }}/img-http-echo:latest

# -
# name: Set up kubectl
# uses: azure/setup-kubectl@v1
# with:
# kubeconfig: ${{ secrets.KUBECONFIG }}

# -
# name: Set up Helm
# uses: azure/setup-helm@v1
# with:
# kubeconfig: ${{ secrets.KUBECONFIG }}

# -
# name: Deploy Helm chart
# run: |
# helm install http-echo ./helm-http-echo
# env:
# KUBECONFIG: ${{ secrets.KUBECONFIG }}



name: ci

on:
push:
branches:
- "release/dev"

jobs:
get-go-version:
name: "Determine Go toolchain version"
runs-on: ubuntu-latest
outputs:
go-version: ${{ steps.get-go-version.outputs.go-version }}
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
# This is the minimum required version. Go 1.21+ should pull in new
# toolchains as indicated in go.mod.
go-version: '1.21'
- name: Determine Go version
id: get-go-version
# With go1.21+, we can use `go version` to print out the exact toolchain that will be used
run: |
echo "Building with Go $(go version | awk '{print $3}' | sed -e 's/^go//')"
echo "go-version=$(go version | awk '{print $3}' | sed -e 's/^go//')" >> $GITHUB_OUTPUT

set-product-version:
runs-on: ubuntu-latest
outputs:
product-version: ${{ steps.set-product-version.outputs.product-version }}
product-base-version: ${{ steps.set-product-version.outputs.base-product-version }}
product-prerelease-version: ${{ steps.set-product-version.outputs.prerelease-product-version }}
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Set Product version
id: set-product-version
uses: hashicorp/actions-set-product-version@v1

generate-metadata-file:
needs: set-product-version
build:
runs-on: ubuntu-latest
outputs:
filepath: ${{ steps.generate-metadata-file.outputs.filepath }}
steps:
- name: "Checkout directory"
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Generate metadata file
id: generate-metadata-file
uses: hashicorp/actions-generate-metadata@v1
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
version: ${{ needs.set-product-version.outputs.product-version }}
product: ${{ env.PKG_NAME }}
repositoryOwner: "hashicorp"
repository: "http-echo"
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: metadata.json
path: ${{ steps.generate-metadata-file.outputs.filepath }}

build-other:
needs:
- get-go-version
- set-product-version
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
goos: [windows]
goarch: ["386", "amd64"]

name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build

steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- uses: hashicorp/[email protected]
env:
BASE_VERSION: ${{ needs.set-product-version.outputs.product-base-version }}
PRERELEASE_VERSION: ${{ needs.set-product-version.outputs.product-prerelease-version}}
METADATA_VERSION: ${{ env.METADATA }}
with:
product_name: ${{ env.PKG_NAME }}
product_version: ${{ needs.set-product-version.outputs.product-version }}
go_version: ${{ needs.get-go-version.outputs.go-version }}
os: ${{ matrix.goos }}
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |
make build

build-linux:
needs:
- get-go-version
- set-product-version
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux]
goarch: ["arm", "arm64", "386", "amd64"]

fail-fast: true

name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build

steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- uses: hashicorp/[email protected]
env:
BASE_VERSION: ${{ needs.set-product-version.outputs.product-base-version }}
PRERELEASE_VERSION: ${{ needs.set-product-version.outputs.product-prerelease-version}}
METADATA_VERSION: ${{ env.METADATA }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and push
uses: docker/build-push-action@v5
with:
product_name: ${{ env.PKG_NAME }}
product_version: ${{ needs.set-product-version.outputs.product-version }}
go_version: ${{ needs.get-go-version.outputs.go-version }}
os: ${{ matrix.goos }}
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |
make build

build-darwin:
needs:
- get-go-version
- set-product-version
runs-on: macos-latest
strategy:
matrix:
goos: [darwin]
goarch: ["amd64", "arm64"]
fail-fast: true

name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build

env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/img-http-echo:latest

steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Set up Kubeconfig
run: |
echo "${{ secrets.KUBECONFIG }}" | base64 --decode > $HOME/.kube/config

- uses: hashicorp/[email protected]
- name: Deploy with Helm
run: |
helm upgrade --install http-echo-release ./helm-http-echo \
--set image.repository=awodi2525/img-http-echo \
--set image.tag=latest
env:
BASE_VERSION: ${{ needs.set-product-version.outputs.product-base-version }}
PRERELEASE_VERSION: ${{ needs.set-product-version.outputs.product-prerelease-version}}
METADATA_VERSION: ${{ env.METADATA }}
with:
product_name: ${{ env.PKG_NAME }}
product_version: ${{ needs.set-product-version.outputs.product-version }}
go_version: ${{ needs.get-go-version.outputs.go-version }}
os: ${{ matrix.goos }}
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |
make build

build-docker-default:
name: Docker ${{ matrix.arch }} default release build
needs:
- set-product-version
- build-linux
runs-on: ubuntu-latest
strategy:
matrix:
arch: ["arm64", "amd64"]
env:
repo: ${{ github.event.repository.name }}
version: ${{ needs.set-product-version.outputs.product-version }}

steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Docker Build (Action)
uses: hashicorp/actions-docker-build@v1
with:
smoke_test: |
TEST_VERSION="$(docker run "${IMAGE_NAME}" -version | awk '/http-echo/{print $2}' | sed s/v//)"
if [ "${TEST_VERSION}" != "${version}" ]; then
echo "Test FAILED"
echo "Test Version: ${TEST_VERSION}"
echo "Version: ${version}"
exit 1
fi
echo "Test PASSED"
version: ${{ env.version }}
target: default
arch: ${{ matrix.arch }}
tags: |
docker.io/hashicorp/${{env.repo}}:${{env.version}}
dev_tags: |
docker.io/hashicorppreview/${{ env.repo }}:${{ env.version }}-dev
docker.io/hashicorppreview/${{ env.repo }}:${{ env.version }}-${{ github.sha }}

KUBECONFIG: $HOME/.kube/config
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .release/ci.hcl
100644 → 100755
Empty file.
Empty file modified .release/release.metadata.hcl
100644 → 100755
Empty file.
Empty file modified .release/security-scan.hcl
100644 → 100755
Empty file.
28 changes: 11 additions & 17 deletions Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
# Use a minimal Go base image
FROM golang:alpine AS builder

FROM gcr.io/distroless/static-debian12:nonroot as default
WORKDIR /app

# TARGETOS and TARGETARCH are set automatically when --platform is provided.
ARG TARGETOS
ARG TARGETARCH
ARG PRODUCT_VERSION
ARG BIN_NAME
COPY . .

LABEL name="http-echo" \
maintainer="HashiCorp Consul Team <[email protected]>" \
vendor="HashiCorp" \
version=$PRODUCT_VERSION \
release=$PRODUCT_VERSION \
summary="A test webserver that echos a response. You know, for kids."
RUN go build -o http-echo .

COPY dist/$TARGETOS/$TARGETARCH/$BIN_NAME /
FROM alpine

WORKDIR /app

COPY --from=builder /app/http-echo .
EXPOSE 5678/tcp

ENV ECHO_TEXT="hello-world"
ENV ECHO_TEXT="hello-world"
ENTRYPOINT ["./http-echo"]

ENTRYPOINT ["/http-echo"]
55 changes: 55 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
pipeline {
agent any

// Ensure the desired Go version is installed for all stages,
// using the name defined in the Global Tool Configuration
tools { go 'go1.22' }

environment {
registry = "awodi2525/img-http-echo"
registryCredential = 'dockerhub'
}

stages {
stage('BUILD') {
steps {
// Output will be something like "go version go1.19 darwin/arm64"
sh 'go version'
}
}


stage('Build App Image') {
steps {
script {
dockerImage = docker.build(registry + ":V$BUILD_NUMBER")
}
}
}

stage('Upload Image') {
steps {
script {
docker.withRegistry('', registryCredential) {
dockerImage.push("V$BUILD_NUMBER")
dockerImage.push("latest")
}
}
}
}

stage('Remove Unused docker image') {
steps {
sh "docker rmi $registry:V$BUILD_NUMBER"
}
}

stage('Kubernetes Deploy') {
steps {
sh "helm upgrade --install http-echo-release ./helm-http-echo --set image.repository=awodi2525/img-http-echo --set image.tag=latest"
}
}
}
}

//
Empty file modified LICENSE
100644 → 100755
Empty file.
Loading