From 367a816cade114e7c7dea85520f84d444f4ed7d6 Mon Sep 17 00:00:00 2001 From: Saya Andy Date: Mon, 22 Jun 2026 19:56:35 +0700 Subject: feat: jenkinsfile for local jenkins server --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Dockerfile') diff --git a/Dockerfile b/Dockerfile index 44d1ea2..58ba7f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.26-alpine3.23 AS build-stage +FROM golang:1.26.4-alpine3.24 AS build-stage RUN apk add --no-cache sqlite-dev musl-dev gcc @@ -7,7 +7,7 @@ COPY . . RUN go mod download RUN CGO_ENABLED=1 go build -o sayana-web . -FROM alpine:3.23 AS runtime-stage +FROM alpine:3.24 AS runtime-stage ENV ENVIRONMENT="" ENV AUTH_SALT="" -- cgit v1.3.1+13 From 1ce3d644faf8e0372cc63f7fb3b15a33a94cd7f4 Mon Sep 17 00:00:00 2001 From: Saya Andy Date: Mon, 22 Jun 2026 21:30:55 +0700 Subject: feat: build image both for amd64 and arm64 --- Dockerfile | 3 ++ Jenkinsfile | 98 +++++++++++++++++++++++++++++++++++-------------------------- 2 files changed, 60 insertions(+), 41 deletions(-) (limited to 'Dockerfile') diff --git a/Dockerfile b/Dockerfile index 58ba7f4..37fe431 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ FROM golang:1.26.4-alpine3.24 AS build-stage +ENV GOOS=linux +ENV GOARCH=amd64 + RUN apk add --no-cache sqlite-dev musl-dev gcc WORKDIR /builddir diff --git a/Jenkinsfile b/Jenkinsfile index f565210..3bafa38 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,50 +18,66 @@ pipeline { stash name: 'tailwindcss-output', includes: 'static/output.css' } } - + stage('Build') { - agent { - kubernetes { - defaultContainer 'kaniko' - yaml """ -apiVersion: v1 -kind: Pod -metadata: - name: kaniko-sayauz-web - namespace: jenkins -spec: - containers: - - name: kaniko - image: gcr.io/kaniko-project/executor:v1.24.0-debug - imagePullPolicy: Always - command: [ /busybox/cat ] - tty: true -""" + matrix { + axes { + axis { + name 'GOOS' + values 'linux' + } + axis { + name 'GOARCH' + values 'arm64', 'amd64' + } } } - environment { - IMAGE_PUSH_DESTINATION="registry.sayag.it/sayauz/web" - } - steps { - checkout scm - unstash 'tailwindcss-output' - container(name: 'kaniko', shell: '/busybox/sh') { - withCredentials([file(credentialsId: 'registry-sayagit-jenkins-password', variable: 'REGISTRY_SAYAGIT_JENKINS_PASSWORD')]) { - withEnv(['PATH+EXTRA=/busybox']) { - try { - sh '''#!/busybox/sh - mkdir -p /kaniko/.docker - echo "{\"auths\":{\"https://registry.sayag.it\":{\"username\":\"jenkins\",\"password\":\"$REGISTRY_SAYAGIT_JENKINS_PASSWORD\"}}}" > /kaniko/.docker/config.json - pushToTags="$IMAGE_PUSH_DESTINATION:latest $IMAGE_PUSH_DESTINATION:commit-`git rev-parse --short HEAD`" - if [ "$TAG_NAME" != "" ]; then - pushToTags="$pushToTags $IMAGE_PUSH_DESTINATION:stable $IMAGE_PUSH_DESTINATION:$TAG_NAME" - fi - /kaniko/executor --context `pwd` --destination $pushToTags - ''' - } catch (Exception e) { - echo "Caught exception: ${e.getMessage()}" - currentBuild.result = 'FAILURE' - throw e + stages { + stage('Build') { + agent { + kubernetes { + defaultContainer 'kaniko' + yaml """ + apiVersion: v1 + kind: Pod + metadata: + name: kaniko-sayauz-web + namespace: jenkins + spec: + containers: + - name: kaniko + image: gcr.io/kaniko-project/executor:v1.24.0-debug + imagePullPolicy: Always + command: [ /busybox/cat ] + tty: true + """ + } + } + environment { + IMAGE_PUSH_DESTINATION="registry.sayag.it/sayauz/web" + } + steps { + checkout scm + unstash 'tailwindcss-output' + container(name: 'kaniko', shell: '/busybox/sh') { + withCredentials([file(credentialsId: 'registry-sayagit-jenkins-password', variable: 'REGISTRY_SAYAGIT_JENKINS_PASSWORD')]) { + withEnv(['PATH+EXTRA=/busybox']) { + try { + sh '''#!/busybox/sh + mkdir -p /kaniko/.docker + echo "{\"auths\":{\"https://registry.sayag.it\":{\"username\":\"jenkins\",\"password\":\"$REGISTRY_SAYAGIT_JENKINS_PASSWORD\"}}}" > /kaniko/.docker/config.json + pushToTags="$IMAGE_PUSH_DESTINATION:latest $IMAGE_PUSH_DESTINATION:commit-`git rev-parse --short HEAD`" + if [ "$TAG_NAME" != "" ]; then + pushToTags="$pushToTags $IMAGE_PUSH_DESTINATION:stable $IMAGE_PUSH_DESTINATION:$TAG_NAME" + fi + /kaniko/executor --context `pwd` --custom-platform=${GOOS}/${GOARCH} --destination $pushToTags + ''' + } catch (Exception e) { + echo "Caught exception: ${e.getMessage()}" + currentBuild.result = 'FAILURE' + throw e + } + } } } } -- cgit v1.3.1+13 From 9f40b572cd96e44aa08814628b06f446fcf559ce Mon Sep 17 00:00:00 2001 From: Saya Andy Date: Mon, 22 Jun 2026 21:55:11 +0700 Subject: fix: specify resource constraints for kaniko container fix: explicitly set goos/goarch for dockerfile --- Dockerfile | 6 ++++-- Jenkinsfile | 14 +++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'Dockerfile') diff --git a/Dockerfile b/Dockerfile index 37fe431..d0b6621 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,9 @@ FROM golang:1.26.4-alpine3.24 AS build-stage -ENV GOOS=linux -ENV GOARCH=amd64 +ARG TARGETOS=linux +ARG TARGETARCH=amd64 +ENV GOOS=${TARGETOS} +ENV GOARCH=${TARGETARCH} RUN apk add --no-cache sqlite-dev musl-dev gcc diff --git a/Jenkinsfile b/Jenkinsfile index 2eb561b..c9103e8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -48,6 +48,14 @@ spec: imagePullPolicy: Always command: [ /busybox/cat ] tty: true + resources: + requests: + cpu: "1" + memory: 2Gi + ephemeral-storage: 4Gi + limits: + memory: 4Gi + ephemeral-storage: 8Gi """ } } @@ -69,7 +77,11 @@ spec: if [ "$TAG_NAME" != "" ]; then pushToTags="$pushToTags $IMAGE_PUSH_DESTINATION:stable $IMAGE_PUSH_DESTINATION:$TAG_NAME" fi - /kaniko/executor --context `pwd` --custom-platform=${GOOS}/${GOARCH} --destination $pushToTags + /kaniko/executor --context `pwd` \ + --custom-platform=${GOOS}/${GOARCH} \ + --build-arg TARGETOS=${GOOS} + --build-arg TARGETARCH=${GOARCH} + --destination $pushToTags ''' } catch (Exception e) { echo "Caught exception: ${e.getMessage()}" -- cgit v1.3.1+13