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 ++-- Jenkinsfile | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 Jenkinsfile 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="" diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..3153b53 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,64 @@ +pipeline { + agent none + + stages { + stage('Compile Tailwind CSS') { + agent { + docker { + image 'node:26.3.1-alpine3.24' + args '-v /tmp:/tmp' + } + } + steps { + checkout scm + sh ''' + npm install tailwindcss @tailwindcss/cli + npx tailwindcss -i static/input.css -o static/output.css --watch + ''' + stash name: 'tailwindcss-output', includes: 'static/output.css' + } + } + + stage('Build') { + agent { + kubernetes { + defaultContainer 'kaniko' + yaml """ +apiVersion: v1 +kind: Pod +metadata: + name: kaniko +spec: + containers: + - name: kaniko + image: gcr.io/kaniko-project/executor:debug-v1.24.0 + 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']) { + sh '''#!/busybox/sh + docker login registry.sayag.it -u jenkins -p "$REGISTRY_SAYAGIT_JENKINS_PASSWORD" + 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 + ''' + } + } + } + } + } + } +} -- cgit v1.3.1+13