diff --git a/.circleci/config.yml b/.circleci/config.yml index a35601fd14e61b45f1a23a14eaca1b80a403363e..5f113ea99e2f21f228aa3564da0187ede4fa3cce 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,28 +23,8 @@ workflows: - lint: {filters: {<<: *tags}} - test: {filters: {<<: *tags}} - - build/loki: - requires: [ lint, test ] - filters: {<<: *no-master} - - publish/loki: - requires: [ lint, test ] - filters: { <<: *tag-or-master } - - - build/canary: - requires: [ lint, test ] - filters: {<<: *no-master} - - publish/canary: - requires: [ lint, test ] - filters: { <<: *tag-or-master } - - - build/promtail: - requires: [ lint, test ] - filters: {<<: *no-master} - build/promtail-windows: requires: [ lint, test ] - - publish/promtail: - requires: [ lint, test ] - filters: { <<: *tag-or-master } - build/docker-driver: requires: [ lint, test ] @@ -58,11 +38,6 @@ workflows: filters: { <<: *only-tags } - deploy: - requires: - - publish/loki - - publish/promtail - - publish/canary - - publish/docker-driver filters: {<<: *tag-or-master} - test-helm: @@ -79,56 +54,6 @@ workflows: - image: grafana/loki-build-image:0.5.0 working_directory: /go/src/github.com/grafana/loki -.machine: &machine - machine: - image: ubuntu-1604:201903-01 - working_directory: ~/go/src/github.com/grafana/loki - environment: - APP: to-be-set - GOPATH: /home/circleci/go - -.rootless: &rootless - run: - name: rootless - command: | - sudo apt-get update && \ - sudo apt-get install -qy uidmap libseccomp-dev binfmt-support go-bindata - sudo docker run --privileged linuxkit/binfmt:v0.6 - -.img: &img - run: - name: img - # TODO: switch to https://github.com/genuinetools/img once 5a8119fb4ce7d712ca2ed589a345213fdf576268 is released - command: | - sudo curl -fSL "https://github.com/sh0rez/img/releases/download/v0.5.8/img-linux-amd64" -o "/usr/local/bin/img" - sudo chmod a+x "/usr/local/bin/img" - -# builds a container -.container: &container - <<: *machine - steps: - - checkout - - <<: *rootless - - <<: *img - - run: - name: container - command: | - make $APP-image-cross - -# builds and pushes a container -.publish: &publish - <<: *machine - steps: - - checkout - - <<: *rootless - - <<: *img - - run: - name: login - command: img login -u "$DOCKER_USER" -p "$DOCKER_PASS" - - run: - name: push image - command: make $APP-push - jobs: test: <<: *defaults @@ -149,34 +74,7 @@ jobs: name: Check Generated Files command: make BUILD_IN_CONTAINER=false check-generated-files - # Loki - build/loki: - <<: *container - environment: - APP: loki - - publish/loki: - <<: *publish - environment: - APP: loki - - # Loki - build/canary: - <<: *container - environment: - APP: loki-canary - - publish/canary: - <<: *publish - environment: - APP: loki-canary - # Promtail - build/promtail: - <<: *container - environment: - APP: promtail - build/promtail-windows: <<: *defaults steps: @@ -185,11 +83,6 @@ jobs: name: build command: make GOOS=windows promtail - publish/promtail: - <<: *publish - environment: - APP: promtail - # Docker driver build/docker-driver: <<: *defaults diff --git a/.drone/docker-manifest.tmpl b/.drone/docker-manifest.tmpl index 7ebb8c942407a0d254dbea6be8e6258deb5d3e26..54f26489e1a7e7e1adc70a40ad9907a6511a9d70 100644 --- a/.drone/docker-manifest.tmpl +++ b/.drone/docker-manifest.tmpl @@ -1,4 +1,4 @@ -image: grafanasaur/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}} +image: grafana/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}} {{#if build.tags}} tags: {{#each build.tags}} @@ -6,16 +6,16 @@ tags: {{/each}} {{/if}} manifests: - - image: grafanasaur/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}-amd64 + - image: grafana/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}-amd64 platform: architecture: amd64 os: linux - - image: grafanasaur/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}-arm64 + - image: grafana/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}-arm64 platform: architecture: arm64 os: linux variant: v8 - - image: grafanasaur/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}-arm + - image: grafana/{{config.target}}:{{#if build.tag}}{{build.tag}}{{else}}{{build.branch}}-{{substr 0 7 build.commit}}{{/if}}-arm platform: architecture: arm os: linux diff --git a/.drone/drone.jsonnet b/.drone/drone.jsonnet index a54cad6ec2fccf890ac7da947e4d9ebd92a0614e..2422acd76db330e88d7993ea1cc1f3799f7b1d1f 100644 --- a/.drone/drone.jsonnet +++ b/.drone/drone.jsonnet @@ -1,6 +1,8 @@ local apps = ['loki', 'loki-canary', 'promtail']; local archs = ['amd64', 'arm64', 'arm']; +local build_image_version = std.extVar('__build-image-version'); + local condition(verb) = { tagMaster: { ref: { @@ -19,14 +21,24 @@ local pipeline(name) = { steps: [], }; +local run(name, commands) = { + name: name, + image: 'grafana/loki-build-image:%s' % build_image_version, + commands: commands, +}; + +local make(target, container=true) = run(target, [ + 'make ' + (if !container then 'BUILD_IN_CONTAINER=false ' else '') + target, +]); + local docker(arch, app) = { name: '%s-image' % if $.settings.dry_run then 'build-' + app else 'publish-' + app, image: 'plugins/docker', settings: { - repo: 'grafanasaur/%s' % app, + repo: 'grafana/%s' % app, dockerfile: 'cmd/%s/Dockerfile' % app, - username: { from_secret: 'saur_username' }, - password: { from_secret: 'saur_password' }, + username: { from_secret: 'docker_username' }, + password: { from_secret: 'docker_password' }, dry_run: false, }, }; @@ -60,6 +72,7 @@ local multiarch_image(arch) = pipeline('docker-' + arch) { } for app in apps ], + depends_on: ['check'], }; local manifest(apps) = pipeline('manifest') { @@ -73,21 +86,32 @@ local manifest(apps) = pipeline('manifest') { target: app, spec: '.drone/docker-manifest.tmpl', ignore_missing: true, - username: { from_secret: 'saur_username' }, - password: { from_secret: 'saur_password' }, + username: { from_secret: 'docker_username' }, + password: { from_secret: 'docker_password' }, }, depends_on: ['clone'], } for app in apps ], -} + { depends_on: [ 'docker-%s' % arch for arch in archs - ], + ] + ['check'], }; local drone = [ + pipeline('check') { + workspace: { + base: "/go", + path: "src/github.com/grafana/loki" + }, + steps: [ + make('test', container=false) { depends_on: ['clone'] }, + make('lint', container=false) { depends_on: ['clone'] }, + make('check-generated-files', container=false) { depends_on: ['clone'] }, + ], + }, +] + [ multiarch_image(arch) for arch in archs ] + [ diff --git a/.drone/drone.yml b/.drone/drone.yml index 05290af9fb847f0f91b4bf3fc97eceeecd78cc46..f273596ba91dcf9ed92107a0a349d791f474246e 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -1,4 +1,31 @@ kind: pipeline +name: check +steps: +- commands: + - make BUILD_IN_CONTAINER=false test + depends_on: + - clone + image: grafana/loki-build-image:0.5.0 + name: test +- commands: + - make BUILD_IN_CONTAINER=false lint + depends_on: + - clone + image: grafana/loki-build-image:0.5.0 + name: lint +- commands: + - make BUILD_IN_CONTAINER=false check-generated-files + depends_on: + - clone + image: grafana/loki-build-image:0.5.0 + name: check-generated-files +workspace: + base: /go + path: src/github.com/grafana/loki +--- +depends_on: +- check +kind: pipeline name: docker-amd64 platform: arch: amd64 @@ -18,10 +45,10 @@ steps: dockerfile: cmd/loki/Dockerfile dry_run: true password: - from_secret: saur_password - repo: grafanasaur/loki + from_secret: docker_password + repo: grafana/loki username: - from_secret: saur_username + from_secret: docker_username when: ref: exclude: @@ -35,10 +62,10 @@ steps: dockerfile: cmd/loki-canary/Dockerfile dry_run: true password: - from_secret: saur_password - repo: grafanasaur/loki-canary + from_secret: docker_password + repo: grafana/loki-canary username: - from_secret: saur_username + from_secret: docker_username when: ref: exclude: @@ -52,10 +79,10 @@ steps: dockerfile: cmd/promtail/Dockerfile dry_run: true password: - from_secret: saur_password - repo: grafanasaur/promtail + from_secret: docker_password + repo: grafana/promtail username: - from_secret: saur_username + from_secret: docker_username when: ref: exclude: @@ -69,10 +96,10 @@ steps: dockerfile: cmd/loki/Dockerfile dry_run: false password: - from_secret: saur_password - repo: grafanasaur/loki + from_secret: docker_password + repo: grafana/loki username: - from_secret: saur_username + from_secret: docker_username when: ref: include: @@ -86,10 +113,10 @@ steps: dockerfile: cmd/loki-canary/Dockerfile dry_run: false password: - from_secret: saur_password - repo: grafanasaur/loki-canary + from_secret: docker_password + repo: grafana/loki-canary username: - from_secret: saur_username + from_secret: docker_username when: ref: include: @@ -103,16 +130,18 @@ steps: dockerfile: cmd/promtail/Dockerfile dry_run: false password: - from_secret: saur_password - repo: grafanasaur/promtail + from_secret: docker_password + repo: grafana/promtail username: - from_secret: saur_username + from_secret: docker_username when: ref: include: - refs/heads/master - refs/tags/v* --- +depends_on: +- check kind: pipeline name: docker-arm64 platform: @@ -133,10 +162,10 @@ steps: dockerfile: cmd/loki/Dockerfile dry_run: true password: - from_secret: saur_password - repo: grafanasaur/loki + from_secret: docker_password + repo: grafana/loki username: - from_secret: saur_username + from_secret: docker_username when: ref: exclude: @@ -150,10 +179,10 @@ steps: dockerfile: cmd/loki-canary/Dockerfile dry_run: true password: - from_secret: saur_password - repo: grafanasaur/loki-canary + from_secret: docker_password + repo: grafana/loki-canary username: - from_secret: saur_username + from_secret: docker_username when: ref: exclude: @@ -167,10 +196,10 @@ steps: dockerfile: cmd/promtail/Dockerfile dry_run: true password: - from_secret: saur_password - repo: grafanasaur/promtail + from_secret: docker_password + repo: grafana/promtail username: - from_secret: saur_username + from_secret: docker_username when: ref: exclude: @@ -184,10 +213,10 @@ steps: dockerfile: cmd/loki/Dockerfile dry_run: false password: - from_secret: saur_password - repo: grafanasaur/loki + from_secret: docker_password + repo: grafana/loki username: - from_secret: saur_username + from_secret: docker_username when: ref: include: @@ -201,10 +230,10 @@ steps: dockerfile: cmd/loki-canary/Dockerfile dry_run: false password: - from_secret: saur_password - repo: grafanasaur/loki-canary + from_secret: docker_password + repo: grafana/loki-canary username: - from_secret: saur_username + from_secret: docker_username when: ref: include: @@ -218,16 +247,18 @@ steps: dockerfile: cmd/promtail/Dockerfile dry_run: false password: - from_secret: saur_password - repo: grafanasaur/promtail + from_secret: docker_password + repo: grafana/promtail username: - from_secret: saur_username + from_secret: docker_username when: ref: include: - refs/heads/master - refs/tags/v* --- +depends_on: +- check kind: pipeline name: docker-arm platform: @@ -248,10 +279,10 @@ steps: dockerfile: cmd/loki/Dockerfile dry_run: true password: - from_secret: saur_password - repo: grafanasaur/loki + from_secret: docker_password + repo: grafana/loki username: - from_secret: saur_username + from_secret: docker_username when: ref: exclude: @@ -265,10 +296,10 @@ steps: dockerfile: cmd/loki-canary/Dockerfile dry_run: true password: - from_secret: saur_password - repo: grafanasaur/loki-canary + from_secret: docker_password + repo: grafana/loki-canary username: - from_secret: saur_username + from_secret: docker_username when: ref: exclude: @@ -282,10 +313,10 @@ steps: dockerfile: cmd/promtail/Dockerfile dry_run: true password: - from_secret: saur_password - repo: grafanasaur/promtail + from_secret: docker_password + repo: grafana/promtail username: - from_secret: saur_username + from_secret: docker_username when: ref: exclude: @@ -299,10 +330,10 @@ steps: dockerfile: cmd/loki/Dockerfile dry_run: false password: - from_secret: saur_password - repo: grafanasaur/loki + from_secret: docker_password + repo: grafana/loki username: - from_secret: saur_username + from_secret: docker_username when: ref: include: @@ -316,10 +347,10 @@ steps: dockerfile: cmd/loki-canary/Dockerfile dry_run: false password: - from_secret: saur_password - repo: grafanasaur/loki-canary + from_secret: docker_password + repo: grafana/loki-canary username: - from_secret: saur_username + from_secret: docker_username when: ref: include: @@ -333,10 +364,10 @@ steps: dockerfile: cmd/promtail/Dockerfile dry_run: false password: - from_secret: saur_password - repo: grafanasaur/promtail + from_secret: docker_password + repo: grafana/promtail username: - from_secret: saur_username + from_secret: docker_username when: ref: include: @@ -347,6 +378,7 @@ depends_on: - docker-amd64 - docker-arm64 - docker-arm +- check kind: pipeline name: manifest steps: @@ -357,11 +389,11 @@ steps: settings: ignore_missing: true password: - from_secret: saur_password + from_secret: docker_password spec: .drone/docker-manifest.tmpl target: promtail username: - from_secret: saur_username + from_secret: docker_username - depends_on: - clone image: plugins/manifest @@ -369,11 +401,11 @@ steps: settings: ignore_missing: true password: - from_secret: saur_password + from_secret: docker_password spec: .drone/docker-manifest.tmpl target: loki username: - from_secret: saur_username + from_secret: docker_username - depends_on: - clone image: plugins/manifest @@ -381,11 +413,11 @@ steps: settings: ignore_missing: true password: - from_secret: saur_password + from_secret: docker_password spec: .drone/docker-manifest.tmpl target: loki-canary username: - from_secret: saur_username + from_secret: docker_username trigger: ref: include: diff --git a/Makefile b/Makefile index 53a244b8adea9830169a8a159efbc65e70822777..d20a244929c45c4d750312f621334b34466401ef 100644 --- a/Makefile +++ b/Makefile @@ -446,4 +446,4 @@ benchmark-store: # regenerate drone yaml drone: - jsonnet .drone/drone.jsonnet | jq .drone -r | yq -y . > .drone/drone.yml + jsonnet -V __build-image-version=$(BUILD_IMAGE_VERSION) .drone/drone.jsonnet | jq .drone -r | yq -y . > .drone/drone.yml