Compare commits

..

7 Commits

Author SHA1 Message Date
mainnika 362920bccf Disable release job trigger 2024-08-24 22:18:04 +02:00
mainnika 571b8069e2 Add QEMU setup for multi-platform support in Docker build process.
- Added step to set up QEMU for multi-platform builds
- Updated Docker build configuration to include linux/amd64 and linux/arm64 platforms
2024-08-24 22:17:39 +02:00
mainnika 55f3901e0d Add helm install flag in Jenkinsfile
Include the helm install flag in the Jenkinsfile pipeline step for deploying applications.
2024-08-24 21:50:34 +02:00
mainnika e1e852cece Update tar extraction command in Jenkinsfile
Changed the order of arguments in the tar extraction command to ensure correct file placement.
2024-08-24 21:46:39 +02:00
mainnika 3a6bc59683 Add creation of directory before extracting files in Jenkinsfile
Created a new directory before extracting files to ensure successful file extraction during the build process in Jenkins.
2024-08-24 21:30:09 +02:00
mainnika 576b795f5f Update actions versions and Docker setup in workflow
- Updated actions versions for checkout, Python setup, Docker buildx, and Docker login.
- Updated docker/build-push-action version to v6.
- Removed signing step for published Docker image.
2024-08-24 21:23:36 +02:00
mainnika a09e3e799e Update Helm version and Jenkins agent label
Changed the Helm download URL to v3.14.0 and updated the Jenkins agent label to "kube0".
2024-08-24 21:18:28 +02:00
21 changed files with 26 additions and 59 deletions
-1
View File
@@ -2,7 +2,6 @@
!cmd !cmd
!nginx !nginx
!pkg !pkg
!templates
!web !web
!go.mod !go.mod
!go.sum !go.sum
+10 -19
View File
@@ -22,26 +22,22 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v2 uses: actions/setup-python@v5
with: with:
python-version: '3.8' python-version: '3.12'
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@main
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@v3
- name: Setup Docker buildx - name: Setup Docker buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }} - name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
uses: docker/login-action@v1 uses: docker/login-action@v3
with: with:
registry: ${{ env.REGISTRY }} registry: ${{ env.REGISTRY }}
username: ${{ github.actor }} username: ${{ github.actor }}
@@ -74,24 +70,19 @@ jobs:
- name: Build and push Docker image - name: Build and push Docker image
id: build-and-push id: build-and-push
uses: docker/build-push-action@v2 uses: docker/build-push-action@v6
with: with:
platforms: linux/amd64,linux/arm64
context: . context: .
build-args: | build-args: |
APP_VERSION=${{ steps.calver.outputs.current }} APP_VERSION=${{ steps.calver.outputs.current }}
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' && !github.event.repository.private }}
env:
COSIGN_EXPERIMENTAL: "true"
run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push.outputs.digest }}
- name: Trigger release job - name: Trigger release job
if: ${{ success() && github.ref_name == 'main' && github.event_name != 'pull_request' && !github.event.repository.private }} if: false
# if: ${{ success() && github.ref_name == 'main' && github.event_name != 'pull_request' && !github.event.repository.private }}
uses: toptal/jenkins-job-trigger-action@master uses: toptal/jenkins-job-trigger-action@master
with: with:
jenkins_url: ${{ secrets.JENKINS_URL }} jenkins_url: ${{ secrets.JENKINS_URL }}
+5 -3
View File
@@ -1,10 +1,10 @@
def HELM_DOWNLOAD_URL = "https://get.helm.sh/helm-v3.7.2-linux-amd64.tar.gz" def HELM_DOWNLOAD_URL = "https://get.helm.sh/helm-v3.14.0-linux-amd64.tar.gz"
def WS_DIST = ".dist" def WS_DIST = ".dist"
def WS_BIN = ".bin" def WS_BIN = ".bin"
def WS_SCM = ".scm" def WS_SCM = ".scm"
pipeline { pipeline {
agent { label "k8s" } agent { label "kube0" }
parameters { parameters {
string( string(
@@ -40,7 +40,8 @@ pipeline {
dir("${WS_DIST}") { dir("${WS_DIST}") {
sh """ sh """
curl -fsSL -O "${HELM_DOWNLOAD_URL}"; curl -fsSL -O "${HELM_DOWNLOAD_URL}";
tar xfz -C "${env.WORKSPACE}/${WS_BIN}" *; mkdir -p "${env.WORKSPACE}/${WS_BIN}";
tar xfz * -C "${env.WORKSPACE}/${WS_BIN}";
ls -lah "${env.WORKSPACE}/${WS_BIN}/linux-amd64/helm"; ls -lah "${env.WORKSPACE}/${WS_BIN}/linux-amd64/helm";
""" """
deleteDir() deleteDir()
@@ -73,6 +74,7 @@ pipeline {
sh """ sh """
"${env.WORKSPACE}/${WS_BIN}/linux-amd64/helm" upgrade ${params.RELEASE_NAME} * \ "${env.WORKSPACE}/${WS_BIN}/linux-amd64/helm" upgrade ${params.RELEASE_NAME} * \
--namespace ${params.RELEASE_NAMESPACE} \ --namespace ${params.RELEASE_NAMESPACE} \
--install \
--create-namespace \ --create-namespace \
--dependency-update \ --dependency-update \
--reset-values \ --reset-values \
-3
View File
@@ -9,8 +9,6 @@ RUN dnf install -yq golang
COPY go.mod . COPY go.mod .
COPY go.sum . COPY go.sum .
COPY templates/go.mod templates/go.mod
COPY templates/go.sum templates/go.sum
RUN --mount=type=cache,id=gopath,target=${GOPATH} \ RUN --mount=type=cache,id=gopath,target=${GOPATH} \
go mod \ go mod \
@@ -20,7 +18,6 @@ ARG APP_VERSION=containerized
COPY cmd cmd COPY cmd cmd
COPY pkg pkg COPY pkg pkg
COPY templates templates
RUN --mount=type=cache,id=gopath,target=${GOPATH} \ RUN --mount=type=cache,id=gopath,target=${GOPATH} \
go build \ go build \
+2 -3
View File
@@ -9,11 +9,10 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/valyala/fasthttp" "github.com/valyala/fasthttp"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/templates"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/config" "code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/config"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/v4api/httpclient" "code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/v4api/httpclient"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/routes" "code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/routes"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
) )
var Version = "nightly" var Version = "nightly"
@@ -53,7 +52,7 @@ func main() {
logrus.Fatal(err) logrus.Fatal(err)
} }
templateFuncs := &templates.Funcs{Version: Version, YandexKey: config.Site.YandexKey} templateFuncs := &templates.Funcs{Version: Version, Site: config.Site}
err = templates.Load(templateFuncs) err = templates.Load(templateFuncs)
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
-3
View File
@@ -2,10 +2,7 @@ module code.tokarch.uk/mainnika/nikita-tokarch-uk
go 1.17 go 1.17
replace code.tokarch.uk/mainnika/nikita-tokarch-uk/templates => ./templates
require ( require (
code.tokarch.uk/mainnika/nikita-tokarch-uk/templates v0.0.0-00010101000000-000000000000
github.com/jackwhelpton/fasthttp-routing/v2 v2.0.0 github.com/jackwhelpton/fasthttp-routing/v2 v2.0.0
github.com/mailru/easyjson v0.7.7 github.com/mailru/easyjson v0.7.7
github.com/sirupsen/logrus v1.8.1 github.com/sirupsen/logrus v1.8.1
+1 -2
View File
@@ -6,10 +6,9 @@ import (
routing "github.com/jackwhelpton/fasthttp-routing/v2" routing "github.com/jackwhelpton/fasthttp-routing/v2"
"github.com/valyala/fasthttp" "github.com/valyala/fasthttp"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/templates"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/content" "code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/content"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/params" "code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/params"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
) )
// relativeRedirectBytes makes a relative redirect by using http Location header // relativeRedirectBytes makes a relative redirect by using http Location header
+1 -1
View File
@@ -6,7 +6,7 @@ import (
routing "github.com/jackwhelpton/fasthttp-routing/v2" routing "github.com/jackwhelpton/fasthttp-routing/v2"
"github.com/valyala/fasthttp" "github.com/valyala/fasthttp"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/templates" "code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
) )
var _ routing.DataWriter = (*TemplateWriter)(nil) var _ routing.DataWriter = (*TemplateWriter)(nil)
+1 -2
View File
@@ -6,10 +6,9 @@ import (
routing "github.com/jackwhelpton/fasthttp-routing/v2" routing "github.com/jackwhelpton/fasthttp-routing/v2"
"github.com/valyala/fasthttp" "github.com/valyala/fasthttp"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/templates"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/config" "code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/config"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost" "code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
) )
// Routes is the main handler that contains all routes handlers // Routes is the main handler that contains all routes handlers
@@ -4,12 +4,13 @@ import (
"html/template" "html/template"
"net/url" "net/url"
"sync" "sync"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/config"
) )
type Funcs struct { type Funcs struct {
Version string Version string
Site config.Site
YandexKey string
compiledJSAppURL string compiledJSAppURL string
@@ -57,7 +58,7 @@ func (f *Funcs) getBlogURL() string {
} }
func (f *Funcs) getYaKey() string { func (f *Funcs) getYaKey() string {
return f.YandexKey return f.Site.YandexKey
} }
// Use returns a func map with template helpers functions // Use returns a func map with template helpers functions
@@ -21,10 +21,10 @@ import (
//go:embed analytics.go.tmpl //go:embed analytics.go.tmpl
var content embed.FS var content embed.FS
// Templates is a container of compiled templates // List of compiled go-templates
var Templates *template.Template = template.New("") var Templates *template.Template = template.New("")
// Load embedded templates // Load embeded templates
func Load(funcs *Funcs) (err error) { func Load(funcs *Funcs) (err error) {
Templates.Funcs(funcs.Use()) Templates.Funcs(funcs.Use())
-7
View File
@@ -1,7 +0,0 @@
module code.tokarch.uk/mainnika/nikita-tokarch-uk/templates
go 1.17
require github.com/sirupsen/logrus v1.8.1
require golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
-10
View File
@@ -1,10 +0,0 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=