Skip to content

Commit

Permalink
chore: Combine Dockerfiles (argoproj#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
whynowy authored Aug 3, 2020
1 parent ded50d6 commit 0f1fb73
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 55 deletions.
57 changes: 57 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
####################################################################################################
# base
####################################################################################################
FROM golang:alpine as base
RUN apk --update add ca-certificates
RUN apk --no-cache add tzdata

####################################################################################################
# eventbus-controller
####################################################################################################
FROM scratch as eventbus-controller
COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY dist/eventbus-controller /bin/eventbus-controller
ENTRYPOINT [ "/bin/eventbus-controller" ]

####################################################################################################
# eventsource-controller
####################################################################################################
FROM scratch as eventsource-controller
COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY dist/eventsource-controller /bin/eventsource-controller
ENTRYPOINT [ "/bin/eventsource-controller" ]

####################################################################################################
# sensor-controller
####################################################################################################
FROM scratch as sensor-controller
COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY dist/sensor-controller /bin/sensor-controller
ENTRYPOINT [ "/bin/sensor-controller" ]

####################################################################################################
# eventsource
####################################################################################################
FROM scratch as eventsource
COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY dist/eventsource /bin/eventsource
ENTRYPOINT [ "/bin/eventsource" ]

####################################################################################################
# sensor
####################################################################################################
FROM centos:8 as sensor
RUN yum -y update && yum -y install ca-certificates openssh openssh-server openssh-clients openssl-libs curl git

# Argo Workflow CLI
COPY assets/argo-linux-amd64 /usr/local/bin/argo
RUN argo version || true

COPY dist/sensor /bin/sensor

ENTRYPOINT [ "/bin/sensor" ]

27 changes: 14 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ PACKAGE=github.com/argoproj/argo-events
CURRENT_DIR=$(shell pwd)
DIST_DIR=${CURRENT_DIR}/dist

DOCKERFILE:=Dockerfile

VERSION=$(shell cat ${CURRENT_DIR}/VERSION)
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_COMMIT=$(shell git rev-parse HEAD)
Expand All @@ -15,10 +17,9 @@ override LDFLAGS += \
-X ${PACKAGE}.gitTreeState=${GIT_TREE_STATE}

# docker image publishing options
DOCKER_PUSH?=true
DOCKER_PUSH?=false
IMAGE_NAMESPACE?=argoproj
IMAGE_TAG?=v0.17.0
BUILD_BINARY?=true

ifeq (${DOCKER_PUSH},true)
ifndef IMAGE_NAMESPACE
Expand Down Expand Up @@ -52,8 +53,8 @@ eventsource-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make eventsource

eventsource-image:
@if [ "$(BUILD_BINARY)" = "true" ]; then make eventsource-linux; fi
docker build -t $(IMAGE_PREFIX)eventsource:$(IMAGE_TAG) -f ./eventsources/Dockerfile .
make eventsource-linux
DOCKER_BUILDKIT=1 docker build -t $(IMAGE_PREFIX)eventsource:$(IMAGE_TAG) --target eventsource -f $(DOCKERFILE) .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)eventsource:$(IMAGE_TAG) ; fi

# EventSource controller
Expand All @@ -64,8 +65,8 @@ eventsource-controller-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make eventsource-controller

eventsource-controller-image:
@if [ "$(BUILD_BINARY)" = "true" ]; then make eventsource-controller-linux; fi
docker build -t $(IMAGE_PREFIX)eventsource-controller:$(IMAGE_TAG) -f ./controllers/eventsource/Dockerfile .
make eventsource-controller-linux
DOCKER_BUILDKIT=1 docker build -t $(IMAGE_PREFIX)eventsource-controller:$(IMAGE_TAG) --target eventsource-controller -f $(DOCKERFILE) .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)eventsource-controller:$(IMAGE_TAG) ; fi

# Sensor
Expand All @@ -76,8 +77,8 @@ sensor-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make sensor

sensor-image:
@if [ "$(BUILD_BINARY)" = "true" ]; then make sensor-linux; fi
docker build -t $(IMAGE_PREFIX)sensor:$(IMAGE_TAG) -f ./sensors/cmd/Dockerfile .
make sensor-linux
DOCKER_BUILDKIT=1 docker build -t $(IMAGE_PREFIX)sensor:$(IMAGE_TAG) --target sensor -f $(DOCKERFILE) .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)sensor:$(IMAGE_TAG) ; fi

# Sensor controller
Expand All @@ -88,8 +89,8 @@ sensor-controller-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make sensor-controller

sensor-controller-image:
@if [ "$(BUILD_BINARY)" = "true" ]; then make sensor-controller-linux; fi
docker build -t $(IMAGE_PREFIX)sensor-controller:$(IMAGE_TAG) -f ./controllers/sensor/Dockerfile .
make sensor-controller-linux
DOCKER_BUILDKIT=1 docker build -t $(IMAGE_PREFIX)sensor-controller:$(IMAGE_TAG) --target sensor-controller -f $(DOCKERFILE) .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)sensor-controller:$(IMAGE_TAG) ; fi

# Gateway controller
Expand All @@ -100,7 +101,7 @@ gateway-controller-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make gateway-controller

gateway-controller-image:
@if [ "$(BUILD_BINARY)" = "true" ]; then make gateway-controller-linux; fi
make gateway-controller-linux
docker build -t $(IMAGE_PREFIX)gateway-controller:$(IMAGE_TAG) -f ./controllers/gateway/Dockerfile .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)gateway-controller:$(IMAGE_TAG) ; fi

Expand All @@ -112,8 +113,8 @@ eventbus-controller-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make eventbus-controller

eventbus-controller-image:
@if [ "$(BUILD_BINARY)" = "true" ]; then make eventbus-controller-linux; fi
docker build -t $(IMAGE_PREFIX)eventbus-controller:$(IMAGE_TAG) -f ./controllers/eventbus/Dockerfile .
make eventbus-controller-linux
DOCKER_BUILDKIT=1 docker build -t $(IMAGE_PREFIX)eventbus-controller:$(IMAGE_TAG) --target eventbus-controller -f $(DOCKERFILE) .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)eventbus-controller:$(IMAGE_TAG) ; fi

test:
Expand Down
Binary file modified assets/argo-linux-amd64
Binary file not shown.
7 changes: 0 additions & 7 deletions controllers/eventbus/Dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions controllers/eventsource/Dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions controllers/sensor/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions docs/triggers/kafka-trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ The Kafka trigger specification is available [here](https://github.com/argoproj/
metadata:
name: minio-sensor
spec:
template:
serviceAccountName: argo-events-sa
dependencies:
- name: test-dep
eventSourceName: minio
Expand Down
2 changes: 0 additions & 2 deletions docs/triggers/nats-trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ The NATS trigger specification is available [here](https://github.com/argoproj/a
metadata:
name: minio-sensor
spec:
template:
serviceAccountName: argo-events-sa
dependencies:
- name: test-dep
eventSourceName: minio
Expand Down
7 changes: 0 additions & 7 deletions eventsources/Dockerfile

This file was deleted.

10 changes: 0 additions & 10 deletions sensors/cmd/Dockerfile

This file was deleted.

0 comments on commit 0f1fb73

Please sign in to comment.