Skip to content

Commit 0c876b2

Browse files
author
Roman Morozov
committed
chore: consumer ci and charts,deployments
1 parent 50b5613 commit 0c876b2

7 files changed

Lines changed: 152 additions & 1 deletion

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build and Push to GHCR
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- "**/consumer/**"
10+
pull_request:
11+
branches:
12+
- main
13+
14+
jobs:
15+
build-and-push:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
steps:
21+
- name: Check Out Repo
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v1
26+
27+
- name: Login to GitHub Container Registry
28+
uses: docker/login-action@v1
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.repository_owner }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Extract metadata (tags, labels) for Docker
35+
id: meta
36+
uses: docker/metadata-action@v3
37+
with:
38+
images: ghcr.io/${{ github.repository }}/consumer
39+
tags: |
40+
type=sha,prefix=commit,length=7
41+
42+
- name: Build and push to GHCR
43+
uses: docker/build-push-action@v2
44+
with:
45+
context: packages/consumer
46+
file: ./Dockerfile
47+
push: true
48+
tags: ${{ steps.meta.outputs.tags }}
49+
50+
# - name: Build and push to GHCR
51+
# uses: docker/build-push-action@v2
52+
# with:
53+
# context: packages/consumer
54+
# file: ./Dockerfile
55+
# push: true
56+
# tags: ghcr.io/${{ github.repository }}/consumer:latest
57+
58+
# - name: Helm Deploy
59+
# uses: deliverybot/helm@v1
60+
# with:
61+
# release: your-release
62+
# namespace: your-namespace
63+
# chart: ./helm-chart
64+
# values: ./helm-chart/values.yaml
65+
# token: ${{ secrets.KUBE_TOKEN }}

packages/cloud/helmfile.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ releases:
4747
service:
4848
omitClusterIP: true
4949
tcp:
50-
'9092': "default/kafka:9092"
50+
"9092": "default/kafka:9092"
51+
- name: consumer
52+
chart: ../consumer

packages/consumer/Chart.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v2
2+
name: go
3+
description: Go Web Application
4+
version: 1.0.0
5+
type: application

packages/consumer/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Start from the latest golang base image
2+
FROM golang:latest
3+
4+
# Set the Current Working Directory inside the container
5+
WORKDIR /app
6+
7+
# Copy go mod and sum files
8+
COPY go.mod go.sum ./
9+
10+
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
11+
RUN go mod download
12+
13+
# Copy the source from the current directory to the Working Directory inside the container
14+
COPY . .
15+
16+
# Build the Go app
17+
RUN go build -o main .
18+
19+
# Command to run the executable
20+
CMD ["./main"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{ $fullname := include "app.fullname" . }}
2+
{{ $registry := .Values.image.registry }}
3+
apiVersion: apps/v1
4+
kind: Deployment
5+
metadata:
6+
name: {{ $fullname }}
7+
spec:
8+
replicas: {{ .Values.replicaCount }}
9+
template:
10+
spec: {{ if and $registry.url $registry.username $registry.password }}
11+
imagePullSecrets:
12+
- name: {{ include "app.registry" . }} {{ else }} {{ with $imagePullSecrets := .Values.image.pullSecrets }}
13+
imagePullSecrets: {{ range $imagePullSecrets }}
14+
- name: {{ tpl . $ }} {{ end }} {{ end }} {{ end }}
15+
16+
containers:
17+
- name: go-app
18+
image: {{ printf "%s/%s:%s" .Values.image.registry.url .Values.image.repository .Values.image.tag | quote }}
19+
env:
20+
- name: XPERM
21+
value: "1.2.3"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- define "app.name" -}}
2+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
3+
{{- end }}
4+
5+
{{- define "app.registry" -}}
6+
{{- printf "%s-%s" .Release.Name "registry" }}
7+
{{- end }}
8+
9+
{{- define "app.fullname" -}}
10+
{{- if .Values.fullnameOverride }}
11+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
12+
{{- else }}
13+
{{- $name := default .Chart.Name .Values.nameOverride }}
14+
{{- if contains $name .Release.Name }}
15+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
18+
{{- end }}
19+
{{- end }}
20+
{{- end }}
21+
22+
{{- define "app.chart" -}}
23+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
24+
{{- end }}

packages/consumer/values.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
image:
2+
registry:
3+
url: ghcr.io/hiperbee
4+
username: "fromEnv"
5+
password: "fromEnv"
6+
repository: vortexia
7+
tag: 1.0.0
8+
9+
pullSecrets: []
10+
11+
replicaCount: 1
12+
13+
nameOverride: ""
14+
fullnameOverride: ""

0 commit comments

Comments
 (0)