testing running on dockerfile

This commit is contained in:
areeqakbr 2025-02-25 10:25:30 +07:00
parent 39dce782c9
commit fbc0c3724e
2 changed files with 24 additions and 23 deletions

18
Dockerfile Normal file
View File

@ -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"]

29
Jenkinsfile vendored
View File

@ -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'
}
}
}
}