Skip to content

Commit

Permalink
Refactor Makefile/Dockerfile to remove volume binding in favor of bui…
Browse files Browse the repository at this point in the history
…ld stages (#1189)
  • Loading branch information
jessesuen authored Jan 25, 2019
1 parent 8eb4c66 commit 93289b4
Show file tree
Hide file tree
Showing 14 changed files with 204 additions and 175 deletions.
12 changes: 5 additions & 7 deletions .argo-ci/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ spec:
value: "{{item}}"
withItems:
- make controller-image executor-image
- make cli-linux
- make cli-darwin
- make release-clis
- name: test
template: ci-builder
arguments:
parameters:
- name: cmd
value: "{{item}}"
withItems:
- dep ensure && make lint test verify-codegen
value: dep ensure && make lint test verify-codegen

- name: ci-builder
inputs:
Expand Down Expand Up @@ -67,10 +64,11 @@ spec:
env:
- name: DOCKER_HOST
value: 127.0.0.1
- name: DOCKER_BUILDKIT
value: "1"
sidecars:
- name: dind
image: docker:17.10-dind
image: docker:18.09-dind
securityContext:
privileged: true
mirrorVolumeMounts: true

8 changes: 4 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*
!dist
dist/pkg
!Gopkg.*
# Prevent vendor directory from being copied to ensure we are not not pulling unexpected cruft from
# a user's workspace, and are only building off of what is locked by dep.
vendor
dist
21 changes: 14 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ Go to https://github.com/argoproj/

## How to suggest a new feature

Go to https://groups.google.com/forum/#!forum/argoproj
* Create a new topic to discuss your feature.
Go to https://github.com/argoproj/
* Open an issue and discuss it.

## How to setup your dev environment

### Requirements
* Golang 1.10
* Golang 1.11
* Docker
* dep v0.5
* Mac Install: `brew install dep`
* gometalinter v2.0.5
* gometalinter v2.0.12

### Quickstart
```
Expand All @@ -36,9 +36,16 @@ $ make
```

### Build workflow-controller and executor images
The following will build the workflow-controller and executor images tagged with the `latest` tag, then push to a personal dockerhub repository:
The following will build the release versions of workflow-controller and executor images tagged
with the `latest` tag, then push to a personal dockerhub repository, `mydockerrepo`:
```
$ make controller-image executor-image IMAGE_TAG=latest IMAGE_NAMESPACE=mydockerrepo DOCKER_PUSH=true
```
Building release versions of the images will be slow during development, since the build happens
inside a docker build context, which cannot re-use the golang build cache between builds. To build
images quicker (for development purposes), images can be built by adding DEV_IMAGE=true.
```
$ make controller-image executor-image IMAGE_TAG=latest IMAGE_NAMESPACE=jessesuen DOCKER_PUSH=true
$ make controller-image executor-image IMAGE_TAG=latest IMAGE_NAMESPACE=mydockerrepo DOCKER_PUSH=true DEV_IMAGE=true
```

### Build argo cli
Expand All @@ -49,6 +56,6 @@ $ ./dist/argo version

### Deploying controller with alternative controller/executor images
```
$ helm install argo/argo --set images.namespace=jessesuen --set
$ helm install argo/argo --set images.namespace=mydockerrepo --set
images.controller workflow-controller:latest
```
87 changes: 87 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
####################################################################################################
# Builder image
# Initial stage which pulls prepares build dependencies and CLI tooling we need for our final image
# Also used as the image in CI jobs so needs all dependencies
####################################################################################################
FROM golang:1.11.4 as builder

RUN apt-get update && apt-get install -y \
git \
make \
wget \
gcc \
zip && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /tmp

# Install docker
ENV DOCKER_CHANNEL stable
ENV DOCKER_VERSION 18.09.1
RUN wget -O docker.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/x86_64/docker-${DOCKER_VERSION}.tgz" && \
tar --extract --file docker.tgz --strip-components 1 --directory /usr/local/bin/ && \
rm docker.tgz

# Install dep
ENV DEP_VERSION=0.5.0
RUN wget https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 -O /usr/local/bin/dep && \
chmod +x /usr/local/bin/dep

# Install gometalinter
ENV GOMETALINTER_VERSION=2.0.12
RUN curl -sLo- https://github.com/alecthomas/gometalinter/releases/download/v${GOMETALINTER_VERSION}/gometalinter-${GOMETALINTER_VERSION}-linux-amd64.tar.gz | \
tar -xzC "$GOPATH/bin" --exclude COPYING --exclude README.md --strip-components 1 -f- && \
ln -s $GOPATH/bin/gometalinter $GOPATH/bin/gometalinter.v2


####################################################################################################
# Argo Build stage which performs the actual build of Argo binaries
####################################################################################################
FROM builder as argo-build

# A dummy directory is created under $GOPATH/src/dummy so we are able to use dep
# to install all the packages of our dep lock file
COPY Gopkg.toml ${GOPATH}/src/dummy/Gopkg.toml
COPY Gopkg.lock ${GOPATH}/src/dummy/Gopkg.lock

RUN cd ${GOPATH}/src/dummy && \
dep ensure -vendor-only && \
mv vendor/* ${GOPATH}/src/ && \
rmdir vendor

# Perform the build
WORKDIR /go/src/github.com/argoproj/argo
COPY . .
ARG MAKE_TARGET="controller executor cli-linux-amd64"
RUN make $MAKE_TARGET


####################################################################################################
# argoexec
####################################################################################################
FROM debian:9.6-slim as argoexec
# NOTE: keep the version synced with https://storage.googleapis.com/kubernetes-release/release/stable.txt
ENV KUBECTL_VERSION=1.13.1
RUN apt-get update && \
apt-get install -y curl jq procps git tar mime-support && \
rm -rf /var/lib/apt/lists/* && \
curl -L -o /usr/local/bin/kubectl -LO https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl && \
chmod +x /usr/local/bin/kubectl
COPY --from=argo-build /go/src/github.com/argoproj/argo/dist/argoexec /usr/local/bin/


####################################################################################################
# workflow-controller
####################################################################################################
FROM scratch as workflow-controller
COPY --from=argo-build /go/src/github.com/argoproj/argo/dist/workflow-controller /bin/
ENTRYPOINT [ "workflow-controller" ]


####################################################################################################
# argocli
####################################################################################################
FROM scratch as argocli
COPY --from=argo-build /go/src/github.com/argoproj/argo/dist/argo-linux-amd64 /bin/argo
ENTRYPOINT [ "argo" ]
16 changes: 0 additions & 16 deletions Dockerfile-argoexec

This file was deleted.

32 changes: 0 additions & 32 deletions Dockerfile-builder

This file was deleted.

12 changes: 0 additions & 12 deletions Dockerfile-ci-builder

This file was deleted.

4 changes: 0 additions & 4 deletions Dockerfile-cli

This file was deleted.

5 changes: 0 additions & 5 deletions Dockerfile-workflow-controller

This file was deleted.

12 changes: 12 additions & 0 deletions Dockerfile.argoexec-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
####################################################################################################
# argoexec-dev
####################################################################################################
FROM debian:9.6-slim as argoexec-dev
# NOTE: keep the version synced with https://storage.googleapis.com/kubernetes-release/release/stable.txt
ENV KUBECTL_VERSION=1.13.1
RUN apt-get update && \
apt-get install -y curl jq procps git tar mime-support && \
rm -rf /var/lib/apt/lists/* && \
curl -L -o /usr/local/bin/kubectl -LO https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl && \
chmod +x /usr/local/bin/kubectl
COPY argoexec /usr/local/bin/
6 changes: 6 additions & 0 deletions Dockerfile.workflow-controller-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
####################################################################################################
# workflow-controller-dev
####################################################################################################
FROM scratch as workflow-controller-dev
COPY workflow-controller /bin/
ENTRYPOINT [ "workflow-controller" ]
Loading

0 comments on commit 93289b4

Please sign in to comment.