Skip to content

Commit

Permalink
TOUCH_PROTOS build arg for dockerfile (grafana#1479)
Browse files Browse the repository at this point in the history
* TOUCH_PROTOS build arg for dockerfile

* echos touch protos in dockerfile

* touch protos correct var

* make touch-protos options in all dockerfiles, run for amd builds
  • Loading branch information
owen-d authored and cyriltovena committed Jan 8, 2020
1 parent 9e9652a commit 29e4ad8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .drone/drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ steps:
image: plugins/docker
settings:
dockerfile: cmd/loki/Dockerfile
build_args:
- TOUCH_PROTOS=1
dry_run: true
password:
from_secret: docker_password
Expand All @@ -200,6 +202,8 @@ steps:
image: plugins/docker
settings:
dockerfile: cmd/loki-canary/Dockerfile
build_args:
- TOUCH_PROTOS=1
dry_run: true
password:
from_secret: docker_password
Expand All @@ -218,6 +222,8 @@ steps:
image: plugins/docker
settings:
dockerfile: cmd/promtail/Dockerfile
build_args:
- TOUCH_PROTOS=1
dry_run: true
password:
from_secret: docker_password
Expand All @@ -236,6 +242,8 @@ steps:
image: plugins/docker
settings:
dockerfile: cmd/loki/Dockerfile
build_args:
- TOUCH_PROTOS=1
password:
from_secret: docker_password
repo: grafana/loki
Expand All @@ -252,6 +260,8 @@ steps:
image: plugins/docker
settings:
dockerfile: cmd/loki-canary/Dockerfile
build_args:
- TOUCH_PROTOS=1
password:
from_secret: docker_password
repo: grafana/loki-canary
Expand All @@ -268,6 +278,8 @@ steps:
image: plugins/docker
settings:
dockerfile: cmd/promtail/Dockerfile
build_args:
- TOUCH_PROTOS=1
password:
from_secret: docker_password
repo: grafana/promtail
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ endif

protos: $(PROTO_GOS)

# use with care. This signals to make that the proto definitions don't need recompiling.
touch-protos:
for proto in $(PROTO_GOS); do [ -f "./$${proto}" ] && touch "$${proto}" && echo "touched $${proto}"; done

Expand Down
5 changes: 4 additions & 1 deletion cmd/loki-canary/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM golang:1.13 as build
# TOUCH_PROTOS signifies if we should touch the compiled proto files and thus not regenerate them.
# This is helpful when file system timestamps can't be trusted with make
ARG TOUCH_PROTOS
COPY . /src/loki
WORKDIR /src/loki
RUN make clean && make BUILD_IN_CONTAINER=false loki-canary
RUN make clean && (if [ "${TOUCH_PROTOS}" ]; then make touch-protos; fi) && make BUILD_IN_CONTAINER=false loki-canary

FROM alpine:3.9
RUN apk add --update --no-cache ca-certificates
Expand Down
5 changes: 4 additions & 1 deletion cmd/loki/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM golang:1.13 as build
# TOUCH_PROTOS signifies if we should touch the compiled proto files and thus not regenerate them.
# This is helpful when file system timestamps can't be trusted with make
ARG TOUCH_PROTOS
COPY . /src/loki
WORKDIR /src/loki
RUN make clean && make BUILD_IN_CONTAINER=false loki
RUN make clean && (if [ "${TOUCH_PROTOS}" ]; then make touch-protos; fi) && make BUILD_IN_CONTAINER=false loki

FROM alpine:3.9
RUN apk add --update --no-cache ca-certificates
Expand Down
5 changes: 4 additions & 1 deletion cmd/promtail/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
FROM golang:1.13 as build
# TOUCH_PROTOS signifies if we should touch the compiled proto files and thus not regenerate them.
# This is helpful when file system timestamps can't be trusted with make
ARG TOUCH_PROTOS
COPY . /src/loki
WORKDIR /src/loki
RUN apt-get update && apt-get install -qy libsystemd-dev
RUN make clean && make BUILD_IN_CONTAINER=false promtail
RUN make clean && (if [ "${TOUCH_PROTOS}" ]; then make touch-protos; fi) && make BUILD_IN_CONTAINER=false promtail

# Promtail requires debian as the base image to support systemd journal reading
FROM debian:stretch-slim
Expand Down

0 comments on commit 29e4ad8

Please sign in to comment.