From d7e663fef62c155c4310b80182a5cfa62a34742c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Mon, 11 Jan 2021 23:39:00 +0100 Subject: [PATCH] Add back continuous delivery --- .gitignore | 3 +- .goreleaser.yaml | 51 +++++++++++++++++++++++++++++ README.md | 4 +-- build/docker/Dockerfile.blacklister | 23 ++----------- build/docker/Dockerfile.configapi | 23 ++----------- build/docker/Dockerfile.crawler | 23 ++----------- build/docker/Dockerfile.indexer | 23 ++----------- build/docker/Dockerfile.scheduler | 23 ++----------- scripts/build.sh | 13 -------- scripts/push.sh | 13 -------- scripts/release.sh | 33 ------------------- 11 files changed, 65 insertions(+), 167 deletions(-) delete mode 100755 scripts/build.sh delete mode 100755 scripts/push.sh delete mode 100755 scripts/release.sh diff --git a/.gitignore b/.gitignore index 1767320..e066b5d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea/ -**/**_mock.go \ No newline at end of file +**/**_mock.go +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 02825ca..29b5d4c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -37,6 +37,57 @@ builds: - linux goarch: - amd64 +dockers: + - goos: linux + goarch: amd64 + binaries: + - bs-blacklister + image_templates: + - "creekorful/bs-blacklister:latest" + - "creekorful/bs-blacklister:{{ replace .Tag \"v\" \"\" }}" + - "creekorful/bs-blacklister:{{ .Major }}" + skip_push: false + dockerfile: build/docker/Dockerfile.blacklister + - goos: linux + goarch: amd64 + binaries: + - bs-configapi + image_templates: + - "creekorful/bs-configapi:latest" + - "creekorful/bs-configapi:{{ replace .Tag \"v\" \"\" }}" + - "creekorful/bs-configapi:{{ .Major }}" + skip_push: false + dockerfile: build/docker/Dockerfile.configapi + - goos: linux + goarch: amd64 + binaries: + - bs-crawler + image_templates: + - "creekorful/bs-crawler:latest" + - "creekorful/bs-crawler:{{ replace .Tag \"v\" \"\" }}" + - "creekorful/bs-crawler:{{ .Major }}" + skip_push: false + dockerfile: build/docker/Dockerfile.crawler + - goos: linux + goarch: amd64 + binaries: + - bs-indexer + image_templates: + - "creekorful/bs-indexer:latest" + - "creekorful/bs-indexer:{{ replace .Tag \"v\" \"\" }}" + - "creekorful/bs-indexer:{{ .Major }}" + skip_push: false + dockerfile: build/docker/Dockerfile.indexer + - goos: linux + goarch: amd64 + binaries: + - bs-scheduler + image_templates: + - "creekorful/bs-scheduler:latest" + - "creekorful/bs-scheduler:{{ replace .Tag \"v\" \"\" }}" + - "creekorful/bs-scheduler:{{ .Major }}" + skip_push: false + dockerfile: build/docker/Dockerfile.scheduler checksum: name_template: 'checksums.txt' snapshot: diff --git a/README.md b/README.md index 9319433..76a70c2 100644 --- a/README.md +++ b/README.md @@ -54,10 +54,10 @@ If you've made a change to one of the crawler component and wish to use the upda just need to issue the following command: ```sh -$ ./script/build.sh +$ goreleaser --snapshot --skip-publish --rm-dist ``` -this will rebuild all crawler images using local changes. After that just run start.sh again to have the updated version +this will rebuild all images using local changes. After that just run start.sh again to have the updated version running. # Architecture diff --git a/build/docker/Dockerfile.blacklister b/build/docker/Dockerfile.blacklister index 725f355..4360b34 100644 --- a/build/docker/Dockerfile.blacklister +++ b/build/docker/Dockerfile.blacklister @@ -1,24 +1,5 @@ -# build image -FROM golang:1.15.0-alpine as builder - -RUN apk update && apk upgrade && \ - apk add --no-cache bash git openssh - -WORKDIR /app - -# Copy and download dependencies to cache them and faster build time -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -# Test then build app -RUN go build -v github.com/creekorful/bathyscaphe/cmd/bs-blacklister - -# runtime image FROM alpine:latest -COPY --from=builder /app/bs-blacklister /app/ -WORKDIR /app/ +ADD bs-blacklister /usr/bin/bs-blacklister -ENTRYPOINT ["./bs-blacklister"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/bs-blacklister"] \ No newline at end of file diff --git a/build/docker/Dockerfile.configapi b/build/docker/Dockerfile.configapi index aff0f35..d352209 100644 --- a/build/docker/Dockerfile.configapi +++ b/build/docker/Dockerfile.configapi @@ -1,24 +1,5 @@ -# build image -FROM golang:1.15.0-alpine as builder - -RUN apk update && apk upgrade && \ - apk add --no-cache bash git openssh - -WORKDIR /app - -# Copy and download dependencies to cache them and faster build time -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -# Test then build app -RUN go build -v github.com/creekorful/bathyscaphe/cmd/bs-configapi - -# runtime image FROM alpine:latest -COPY --from=builder /app/bs-configapi /app/ -WORKDIR /app/ +ADD bs-configapi /usr/bin/bs-configapi -ENTRYPOINT ["./bs-configapi"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/bs-configapi"] \ No newline at end of file diff --git a/build/docker/Dockerfile.crawler b/build/docker/Dockerfile.crawler index 9df78eb..48de039 100644 --- a/build/docker/Dockerfile.crawler +++ b/build/docker/Dockerfile.crawler @@ -1,24 +1,5 @@ -# build image -FROM golang:1.15.0-alpine as builder - -RUN apk update && apk upgrade && \ - apk add --no-cache bash git openssh - -WORKDIR /app - -# Copy and download dependencies to cache them and faster build time -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -# Test then build app -RUN go build -v github.com/creekorful/bathyscaphe/cmd/bs-crawler - -# runtime image FROM alpine:latest -COPY --from=builder /app/bs-crawler /app/ -WORKDIR /app/ +ADD bs-crawler /usr/bin/bs-crawler -ENTRYPOINT ["./bs-crawler"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/bs-crawler"] \ No newline at end of file diff --git a/build/docker/Dockerfile.indexer b/build/docker/Dockerfile.indexer index 17d5975..b107672 100644 --- a/build/docker/Dockerfile.indexer +++ b/build/docker/Dockerfile.indexer @@ -1,24 +1,5 @@ -# build image -FROM golang:1.15.0-alpine as builder - -RUN apk update && apk upgrade && \ - apk add --no-cache bash git openssh - -WORKDIR /app - -# Copy and download dependencies to cache them and faster build time -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -# Test then build app -RUN go build -v github.com/creekorful/bathyscaphe/cmd/bs-indexer - -# runtime image FROM alpine:latest -COPY --from=builder /app/bs-indexer /app/ -WORKDIR /app/ +ADD bs-indexer /usr/bin/bs-indexer -ENTRYPOINT ["./bs-indexer"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/bs-indexer"] \ No newline at end of file diff --git a/build/docker/Dockerfile.scheduler b/build/docker/Dockerfile.scheduler index cb372ce..e7e1a86 100644 --- a/build/docker/Dockerfile.scheduler +++ b/build/docker/Dockerfile.scheduler @@ -1,24 +1,5 @@ -# build image -FROM golang:1.15.0-alpine as builder - -RUN apk update && apk upgrade && \ - apk add --no-cache bash git openssh - -WORKDIR /app - -# Copy and download dependencies to cache them and faster build time -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -# Test then build app -RUN go build -v github.com/creekorful/bathyscaphe/cmd/bs-scheduler - -# runtime image FROM alpine:latest -COPY --from=builder /app/bs-scheduler /app/ -WORKDIR /app/ +ADD bs-scheduler /usr/bin/bs-scheduler -ENTRYPOINT ["./bs-scheduler"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/bs-scheduler"] \ No newline at end of file diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100755 index d55189c..0000000 --- a/scripts/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# set image tag if provided -tag="latest" -if [ "$1" ]; then - tag="$1" -fi - -# build docker images -for path in build/docker/Dockerfile.*; do - name=$(echo "$path" | cut -d'.' -f2) - docker build . -f "$path" -t "creekorful/bs-$name:$tag" -done diff --git a/scripts/push.sh b/scripts/push.sh deleted file mode 100755 index 2352073..0000000 --- a/scripts/push.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# set image tag if provided -tag="latest" -if [ "$1" ]; then - tag="$1" -fi - -# push docker images -for path in build/docker/Dockerfile.*; do - name=$(echo "$path" | cut -d'.' -f2) - docker push "creekorful/$name:$tag" -done diff --git a/scripts/release.sh b/scripts/release.sh deleted file mode 100755 index 3214b04..0000000 --- a/scripts/release.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# make sure we have passed a tag as version -if [ "$1" ]; then - tag="$1" -else - echo "correct usage ./release.sh " - exit 1 -fi - -# create signed tag -git tag -s "v$tag" -m "Release $tag" - -# build the docker images -./scripts/build.sh "$tag" # create version tag -./scripts/build.sh # create latest tag - -echo "" -echo "" -echo "Release $tag is ready!" -echo "Please validate the changes, and once everything is confirmed, run the following:" -echo "" -echo "Update the git repository:" -echo "" -echo "$ git push && git push --tags" -echo "" -echo "Update the docker images:" -echo "" -echo "$ ./scripts/push.sh $tag" -echo "$ ./scripts/push.sh" -echo "" -echo "" -echo "Happy hacking ;D"