From fbc0c3724e5a55194fb24ece5cf712106b16d27a Mon Sep 17 00:00:00 2001 From: areeqakbr Date: Tue, 25 Feb 2025 10:25:30 +0700 Subject: [PATCH] testing running on dockerfile --- Dockerfile | 18 ++++++++++++++++++ Jenkinsfile | 29 ++++++----------------------- 2 files changed, 24 insertions(+), 23 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9d96277 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# Use the official Golang image +FROM golang:1.23.1 + +# Set the working directory inside the container +WORKDIR /app + +# Copy go.mod and go.sum files and download dependencies +COPY go.mod go.sum ./ +RUN go mod download + +# Copy the rest of the application source code +COPY . . + +# Expose the application's port (change if needed) +EXPOSE 5678 + +# Command to run the application +CMD ["go", "run", "main.go"] diff --git a/Jenkinsfile b/Jenkinsfile index e292158..788bf7b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ pipeline { - agent any // Runs on an Ubuntu-based Jenkins agent + agent {dockerfile true} environment { REGISTRY_URL = 'git.winteraccess.id' @@ -24,30 +24,13 @@ pipeline { } } - stage('Login to Registry') { - steps { - script { - withCredentials([usernamePassword(credentialsId: "${DOCKERUSRPASS}", usernameVariable: 'REGISTRY_USER', passwordVariable: 'REGISTRY_TOKEN')]) { - sh """ - echo "$REGISTRY_TOKEN" | docker login "$REGISTRY_URL" --username ${REGISTRY_USER} --password-stdin - """ - } - } - } - } stage('Build and Push Docker Image') { steps { - script { - def imageTag = "dev-${env.SHORT_SHA}" - sh """ - docker build -t ${REGISTRY_URL}/${IMAGE_NAME}:${imageTag} \ - -t ${REGISTRY_URL}/${IMAGE_NAME}:dev \ - -t ${REGISTRY_URL}/${IMAGE_NAME}:latest \ - -f deploy/docker/Dockerfile . - docker push ${REGISTRY_URL}/${IMAGE_NAME}:${imageTag} - docker push ${REGISTRY_URL}/${IMAGE_NAME}:dev - docker push ${REGISTRY_URL}/${IMAGE_NAME}:latest - """ + stage('testing') + { + steps{ + sh 'go --version' + } } } }