Skip to content

Commit

Permalink
chore: consumer ci and charts,deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Morozov committed Jan 21, 2024
1 parent 50b5613 commit 0c876b2
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 1 deletion.
65 changes: 65 additions & 0 deletions .github/workflows/build-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build and Push to GHCR

on:
workflow_dispatch:
push:
branches:
- main
paths:
- "**/consumer/**"
pull_request:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check Out Repo
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository }}/consumer
tags: |
type=sha,prefix=commit,length=7
- name: Build and push to GHCR
uses: docker/build-push-action@v2
with:
context: packages/consumer
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}

# - name: Build and push to GHCR
# uses: docker/build-push-action@v2
# with:
# context: packages/consumer
# file: ./Dockerfile
# push: true
# tags: ghcr.io/${{ github.repository }}/consumer:latest

# - name: Helm Deploy
# uses: deliverybot/helm@v1
# with:
# release: your-release
# namespace: your-namespace
# chart: ./helm-chart
# values: ./helm-chart/values.yaml
# token: ${{ secrets.KUBE_TOKEN }}
4 changes: 3 additions & 1 deletion packages/cloud/helmfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ releases:
service:
omitClusterIP: true
tcp:
'9092': "default/kafka:9092"
"9092": "default/kafka:9092"
- name: consumer
chart: ../consumer
5 changes: 5 additions & 0 deletions packages/consumer/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: go
description: Go Web Application
version: 1.0.0
type: application
20 changes: 20 additions & 0 deletions packages/consumer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Start from the latest golang base image
FROM golang:latest

# Set the Current Working Directory inside the container
WORKDIR /app

# Copy go mod and sum files
COPY go.mod go.sum ./

# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
RUN go mod download

# Copy the source from the current directory to the Working Directory inside the container
COPY . .

# Build the Go app
RUN go build -o main .

# Command to run the executable
CMD ["./main"]
21 changes: 21 additions & 0 deletions packages/consumer/templates/Deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{ $fullname := include "app.fullname" . }}
{{ $registry := .Values.image.registry }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $fullname }}
spec:
replicas: {{ .Values.replicaCount }}
template:
spec: {{ if and $registry.url $registry.username $registry.password }}
imagePullSecrets:
- name: {{ include "app.registry" . }} {{ else }} {{ with $imagePullSecrets := .Values.image.pullSecrets }}
imagePullSecrets: {{ range $imagePullSecrets }}
- name: {{ tpl . $ }} {{ end }} {{ end }} {{ end }}

containers:
- name: go-app
image: {{ printf "%s/%s:%s" .Values.image.registry.url .Values.image.repository .Values.image.tag | quote }}
env:
- name: XPERM
value: "1.2.3"
24 changes: 24 additions & 0 deletions packages/consumer/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- define "app.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "app.registry" -}}
{{- printf "%s-%s" .Release.Name "registry" }}
{{- end }}

{{- define "app.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{- define "app.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
14 changes: 14 additions & 0 deletions packages/consumer/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
image:
registry:
url: ghcr.io/hiperbee
username: "fromEnv"
password: "fromEnv"
repository: vortexia
tag: 1.0.0

pullSecrets: []

replicaCount: 1

nameOverride: ""
fullnameOverride: ""

0 comments on commit 0c876b2

Please sign in to comment.