operator: Use docker build context for root make targets (#6601)

pull/6381/head
Periklis Tsirakidis 4 years ago committed by GitHub
parent 1b8f609b86
commit ebac1f1618
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .drone/drone.jsonnet
  2. 8
      .drone/drone.yml
  3. 4
      Makefile
  4. 12
      operator/Dockerfile
  5. 12
      operator/Dockerfile.cross

@ -87,6 +87,7 @@ local docker_operator(arch, operator) = {
image: 'plugins/docker', image: 'plugins/docker',
settings: { settings: {
repo: 'grafana/%s' % operator, repo: 'grafana/%s' % operator,
context: 'operator',
dockerfile: 'operator/Dockerfile', dockerfile: 'operator/Dockerfile',
username: { from_secret: docker_username_secret.name }, username: { from_secret: docker_username_secret.name },
password: { from_secret: docker_password_secret.name }, password: { from_secret: docker_password_secret.name },

@ -707,6 +707,7 @@ steps:
image: plugins/docker image: plugins/docker
name: build-loki-operator-image name: build-loki-operator-image
settings: settings:
context: operator
dockerfile: operator/Dockerfile dockerfile: operator/Dockerfile
dry_run: true dry_run: true
password: password:
@ -722,6 +723,7 @@ steps:
image: plugins/docker image: plugins/docker
name: publish-loki-operator-image name: publish-loki-operator-image
settings: settings:
context: operator
dockerfile: operator/Dockerfile dockerfile: operator/Dockerfile
dry_run: false dry_run: false
password: password:
@ -759,6 +761,7 @@ steps:
image: plugins/docker image: plugins/docker
name: build-loki-operator-image name: build-loki-operator-image
settings: settings:
context: operator
dockerfile: operator/Dockerfile dockerfile: operator/Dockerfile
dry_run: true dry_run: true
password: password:
@ -774,6 +777,7 @@ steps:
image: plugins/docker image: plugins/docker
name: publish-loki-operator-image name: publish-loki-operator-image
settings: settings:
context: operator
dockerfile: operator/Dockerfile dockerfile: operator/Dockerfile
dry_run: false dry_run: false
password: password:
@ -811,6 +815,7 @@ steps:
image: plugins/docker image: plugins/docker
name: build-loki-operator-image name: build-loki-operator-image
settings: settings:
context: operator
dockerfile: operator/Dockerfile dockerfile: operator/Dockerfile
dry_run: true dry_run: true
password: password:
@ -826,6 +831,7 @@ steps:
image: plugins/docker image: plugins/docker
name: publish-loki-operator-image name: publish-loki-operator-image
settings: settings:
context: operator
dockerfile: operator/Dockerfile dockerfile: operator/Dockerfile
dry_run: false dry_run: false
password: password:
@ -1411,6 +1417,6 @@ kind: secret
name: deploy_config name: deploy_config
--- ---
kind: signature kind: signature
hmac: 2082d23dcc8f69038e55b027f55a8b1fe8bc52b27f07d785db781fc935a434ad hmac: b99e5220d2f2fc15a0bca24bfd3ead78bb6b1ac276fc01ea76a06705fc920190
... ...

@ -581,9 +581,9 @@ endif
# loki-operator # loki-operator
loki-operator-image: loki-operator-image:
$(SUDO) docker build -t $(IMAGE_PREFIX)/loki-operator:$(IMAGE_TAG) -f operator/Dockerfile . $(SUDO) docker build -t $(IMAGE_PREFIX)/loki-operator:$(IMAGE_TAG) -f operator/Dockerfile operator/
loki-operator-image-cross: loki-operator-image-cross:
$(SUDO) $(BUILD_OCI) -t $(IMAGE_PREFIX)/loki-operator:$(IMAGE_TAG) -f operator/Dockerfile.cross . $(SUDO) $(BUILD_OCI) -t $(IMAGE_PREFIX)/loki-operator:$(IMAGE_TAG) -f operator/Dockerfile.cross operator/
loki-operator-push: loki-operator-image-cross loki-operator-push: loki-operator-image-cross
$(SUDO) $(PUSH_OCI) $(IMAGE_PREFIX)/loki-operator:$(IMAGE_TAG) $(SUDO) $(PUSH_OCI) $(IMAGE_PREFIX)/loki-operator:$(IMAGE_TAG)

@ -3,17 +3,17 @@ FROM golang:1.17.9 as builder
WORKDIR /workspace WORKDIR /workspace
# Copy the Go Modules manifests # Copy the Go Modules manifests
COPY operator/go.mod go.mod COPY go.mod go.mod
COPY operator/go.sum go.sum COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much # cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer # and so that source changes don't invalidate our downloaded layer
RUN go mod download RUN go mod download
# Copy the go source # Copy the go source
COPY operator/main.go main.go COPY main.go main.go
COPY operator/apis/ apis/ COPY apis/ apis/
COPY operator/controllers/ controllers/ COPY controllers/ controllers/
COPY operator/internal/ internal/ COPY internal/ internal/
# Build # Build
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o manager main.go RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o manager main.go

@ -8,17 +8,17 @@ FROM --platform=linux/amd64 $BUILD_IMAGE as builder
COPY --from=goenv /goarch /goarm / COPY --from=goenv /goarch /goarm /
WORKDIR /workspace WORKDIR /workspace
# Copy the Go Modules manifests # Copy the Go Modules manifests
COPY operator/go.mod go.mod COPY go.mod go.mod
COPY operator/go.sum go.sum COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much # cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer # and so that source changes don't invalidate our downloaded layer
RUN go mod download RUN go mod download
# Copy the go source # Copy the go source
COPY operator/main.go main.go COPY main.go main.go
COPY operator/apis/ apis/ COPY apis/ apis/
COPY operator/controllers/ controllers/ COPY controllers/ controllers/
COPY operator/internal/ internal/ COPY internal/ internal/
# Build # Build
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on GOARCH=$(cat /goarch) GOARM=$(cat /goarm) go build -a -o manager main.go RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on GOARCH=$(cat /goarch) GOARM=$(cat /goarm) go build -a -o manager main.go

Loading…
Cancel
Save