Browse Source

add pipeline, use vendoring, no more latest tag

tags/0.0.6
Vladimir Smagin 7 months ago
parent
commit
b51099e718
8 changed files with 58 additions and 32 deletions
  1. +6
    -6
      Dockerfile
  2. +48
    -0
      Jenkinsfile
  3. +0
    -21
      Makefile
  4. +1
    -1
      VERSION
  5. +1
    -2
      deploy/operator.yaml
  6. +0
    -1
      go.mod
  7. +1
    -0
      go.sum
  8. +1
    -1
      version/version.go

+ 6
- 6
Dockerfile View File

@@ -3,16 +3,16 @@ FROM golang:1.13-alpine
RUN apk update
RUN apk add git mercurial

WORKDIR /app/cron-operator
WORKDIR /app/operator
COPY . .

WORKDIR /app/cron-operator/cmd/manager
WORKDIR /app/operator/cmd/manager

RUN CGO_ENABLED=0 go build
RUN go install
RUN CGO_ENABLED=0 go build -mod=vendor
RUN go install -mod=vendor

FROM alpine:3.10
FROM alpine:3.11

COPY --from=0 /go/bin/manager /usr/local/bin/cron-operator
COPY --from=0 /go/bin/manager /usr/local/bin/operator

ENTRYPOINT ["/usr/local/bin/entrypoint"]

+ 48
- 0
Jenkinsfile View File

@@ -0,0 +1,48 @@
node {
checkout scm

def branch = env.BRANCH_NAME
def build = env.BUILD_NUMBER
def image
def repository = "iam21h/cron-operator"
def image_name = "${repository}"
def commit_hash = checkout(scm).GIT_COMMIT
def version

stage("Read version from file") {
try {
version = readFile file: "VERSION"
echo "Detected version: ${version}"
image_name = "${repository}:${version}"
} catch (Exception e) {
error("Failed to read version from file")
}
}

stage("Build Image") {
try {
sh "docker build -t ${image_name} ."
image = docker.image(image_name)
} catch (Exception e) {
error("Failed to build image")
}
}

if (branch == 'master') {
stage("Push Image") {
try {

docker.withRegistry("", "dockerhub") {
image.push()
}

} catch(Exception e) {
echo "${e}"
error("Failed to push image")
} finally {
// cleanup
sh "docker rmi ${image_name} || true"
}
}
}
}

+ 0
- 21
Makefile View File

@@ -1,21 +0,0 @@
OPERATOR_IMAGE_NAME := cron-operator
VERSION=$(shell cat ./VERSION)
COMMIT=$(shell git rev-parse --short HEAD)
.PHONY: all clean build push

all: gen build

gen:
operator-sdk generate k8s

build:
operator-sdk build $(OPERATOR_IMAGE_NAME):$(VERSION)

push:
docker tag $(OPERATOR_IMAGE_NAME):$(VERSION) iam21h/cron-operator:$(VERSION)
docker tag $(OPERATOR_IMAGE_NAME):$(VERSION) iam21h/cron-operator:latest
docker push iam21h/cron-operator:$(VERSION)
docker push iam21h/cron-operator:latest

clean:
rm -rf bin/*

+ 1
- 1
VERSION View File

@@ -1 +1 @@
0.0.5
0.0.5.1

+ 1
- 2
deploy/operator.yaml View File

@@ -15,8 +15,7 @@ spec:
serviceAccountName: cron-operator
containers:
- name: cron-operator
# pin version if you want be stable
image: iam21h/cron-operator:latest
image: iam21h/cron-operator:0.0.5.1
command:
- cron-operator
imagePullPolicy: Always


+ 0
- 1
go.mod View File

@@ -1,7 +1,6 @@
module git.blindage.org/21h/cron-operator

require (
github.com/NYTimes/gziphandler v1.0.1 // indirect
github.com/certifi/gocertifi v0.0.0-20190506164543-d2eda7129713 // indirect
github.com/getsentry/raven-go v0.2.0
github.com/go-logr/logr v0.1.0


+ 1
- 0
go.sum View File

@@ -460,6 +460,7 @@ google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9Ywl
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=


+ 1
- 1
version/version.go View File

@@ -1,5 +1,5 @@
package version

var (
Version = "0.0.5"
Version = "0.0.5.1"
)

Loading…
Cancel
Save