Skip to content

Commit

Permalink
Skaffold for Fission (fission#1172)
Browse files Browse the repository at this point in the history
Skaffold for development of Fission and switching to multi-stage Dockerfile for all components.
  • Loading branch information
vishal-biyani committed May 27, 2019
1 parent c3177f9 commit 49f9944
Show file tree
Hide file tree
Showing 21 changed files with 215 additions and 123 deletions.
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.md
*.sh
Documentation
charts
examples
environments/*
!environments/fetcher
demos
test
Makefile
LICENSE
glide.*
.travis.yml
.gitignore
.git
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ before_script:
- hack/verify-govet.sh
- helm lint charts/fission-all/ charts/fission-core/
- go mod download
- go mod vendor
- go build -o fission/fission fission/*.go
- ./fission-bundle/build.sh
- hack/runtests.sh

script:
Expand Down
9 changes: 0 additions & 9 deletions builder/cmd/Dockerfile

This file was deleted.

26 changes: 26 additions & 0 deletions builder/cmd/Dockerfile.fission-builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM golang:1.11-alpine as fission-builder
RUN apk add bash ca-certificates git gcc g++ libc-dev

ARG GITCOMMIT=unknown
# E.g. GITCOMMIT=$(git rev-parse HEAD)

ARG BUILDVERSION=unknown
# E.g. BUILDVERSION=$(git rev-parse HEAD)

ARG BUILDDATE=unknown
# E.g. BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')

ARG GOPKG=github.com/fission/fission
COPY . /go/src/${GOPKG}
WORKDIR /go/src/${GOPKG}/builder/cmd
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-o /go/bin/builder \
-gcflags=-trimpath=$GOPATH \
-asmflags=-trimpath=$GOPATH \
-ldflags "-X github.com/fission/fission.GitCommit=${GITCOMMIT} -X github.com/fission/fission.BuildDate=${BUILDDATE} -X github.com/fission/fission.Version=${BUILDVERSION}"

FROM alpine:3.5
COPY --from=fission-builder /go/bin/builder /
EXPOSE 8001

ENTRYPOINT ["/builder"]
18 changes: 0 additions & 18 deletions builder/cmd/build.sh

This file was deleted.

5 changes: 0 additions & 5 deletions environments/fetcher/cmd/Dockerfile

This file was deleted.

26 changes: 26 additions & 0 deletions environments/fetcher/cmd/Dockerfile.fission-fetcher
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM golang:1.11-alpine as builder
RUN apk add bash ca-certificates git gcc g++ libc-dev

ARG GITCOMMIT=unknown
# E.g. GITCOMMIT=$(git rev-parse HEAD)

ARG BUILDVERSION=unknown
# E.g. BUILDVERSION=$(git rev-parse HEAD)

ARG BUILDDATE=unknown
# E.g. BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')

ARG GOPKG=github.com/fission/fission
COPY . /go/src/${GOPKG}
WORKDIR /go/src/${GOPKG}/environments/fetcher/cmd
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-o /go/bin/fetcher \
-gcflags=-trimpath=$GOPATH \
-asmflags=-trimpath=$GOPATH \
-ldflags "-X github.com/fission/fission.GitCommit=${GITCOMMIT} -X github.com/fission/fission.BuildDate=${BUILDDATE} -X github.com/fission/fission.Version=${BUILDVERSION}"

FROM alpine:3.4
COPY --from=builder /go/bin/fetcher /
EXPOSE 8000

ENTRYPOINT ["/fetcher"]
17 changes: 0 additions & 17 deletions environments/fetcher/cmd/build.sh

This file was deleted.

2 changes: 1 addition & 1 deletion executor/newdeploy/newdeploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (deploy *NewDeploy) getDeploymentSpec(fn *crd.Function, env *crd.Environmen
PreStop: &apiv1.Handler{
Exec: &apiv1.ExecAction{
Command: []string{
"sleep",
"/bin/sleep",
fmt.Sprintf("%v", gracePeriodSeconds),
},
},
Expand Down
2 changes: 1 addition & 1 deletion executor/poolmgr/gp.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func (gp *GenericPool) createPool() error {
PreStop: &apiv1.Handler{
Exec: &apiv1.ExecAction{
Command: []string{
"sleep",
"/bin/sleep",
fmt.Sprintf("%v", gracePeriodSeconds),
},
},
Expand Down
3 changes: 0 additions & 3 deletions fission-bundle/Dockerfile

This file was deleted.

28 changes: 28 additions & 0 deletions fission-bundle/Dockerfile.fission-bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM golang:1.11-alpine as builder
RUN apk add bash ca-certificates git gcc g++ libc-dev

ARG GITCOMMIT=unknown
# E.g. GITCOMMIT=$(git rev-parse HEAD)

ARG BUILDVERSION=unknown
# E.g. BUILDVERSION=$(git rev-parse HEAD)

ARG BUILDDATE=unknown
# E.g. BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')

ARG GOPKG=github.com/fission/fission
COPY . /go/src/${GOPKG}
RUN rm -f /go/src/${GOPKG}/Dockerfile*
WORKDIR /go/src/${GOPKG}/fission-bundle
ENV GO111MODULE=on
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -mod vendor \
-o /go/bin/fission-bundle \
-gcflags=-trimpath=$GOPATH \
-asmflags=-trimpath=$GOPATH \
-ldflags "-X github.com/fission/fission.GitCommit=${GITCOMMIT} -X github.com/fission/fission.BuildDate=${BUILDDATE} -X github.com/fission/fission.Version=${BUILDVERSION}"

FROM alpine:3.4
RUN apk add --update ca-certificates
COPY --from=builder /go/bin/fission-bundle /

ENTRYPOINT ["/fission-bundle"]
17 changes: 0 additions & 17 deletions fission-bundle/build.sh

This file was deleted.

8 changes: 8 additions & 0 deletions fission-bundle/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"flag"
"fmt"
"log"
"os"
Expand Down Expand Up @@ -150,6 +151,13 @@ func registerTraceExporter(logger *zap.Logger, arguments map[string]interface{})
}

func main() {
// From https://github.com/containous/traefik/pull/1817/files
// Tell glog to log into STDERR. Otherwise, we risk
// certain kinds of API errors getting logged into a directory not
// available in a `FROM scratch` Docker container, causing glog to abort
// hard with an exit code > 0.
flag.Set("logtostderr", "true")

usage := `fission-bundle: Package of all fission microservices: controller, router, executor.
Use it to start one or more of the fission servers:
Expand Down
20 changes: 6 additions & 14 deletions hack/release-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,8 @@ build_fission_bundle_image() {

local tag=fission/fission-bundle:$version

pushd $DIR/fission-bundle

./build.sh $version $date $gitcommit
docker build -t $tag .
docker tag $tag fission/fission-bundle:latest

popd
docker build -t $tag -f $ROOT/fission-bundle/Dockerfile.fission-bundle --build-arg GITCOMMIT=$gitcommit --build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version .
docker tag $tag fission/fission-bundle:latest
}

build_fetcher_image() {
Expand All @@ -69,8 +64,7 @@ build_fetcher_image() {

pushd $DIR/environments/fetcher/cmd

./build.sh $version $date $gitcommit
docker build -t $tag .
docker build -t $tag -f $ROOT/environments/fetcher/cmd/Dockerfile.fission-fetcher --build-arg GITCOMMIT=$gitcommit --build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version .
docker tag $tag fission/fetcher:latest

popd
Expand All @@ -89,8 +83,7 @@ build_builder_image() {

pushd $DIR/builder/cmd

./build.sh $version $date $gitcommit
docker build -t $tag .
docker build -t $tag -f $ROOT/builder/cmd/Dockerfile.fission-builder --build-arg GITCOMMIT=$gitcommit --build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version .
docker tag $tag fission/builder:latest

popd
Expand Down Expand Up @@ -134,9 +127,8 @@ build_pre_upgrade_checks_image() {
local tag=fission/pre-upgrade-checks:$version

pushd $DIR/preupgradechecks

./build.sh $version $date $gitcommit
docker build -t $tag .

docker build -t $tag -f $ROOT/preupgradechecks/Dockerfile.fission-preupgradechecks --build-arg GITCOMMIT=$gitcommit --build-arg BUILDDATE=$date --build-arg BUILDVERSION=$version .
docker tag $tag fission/pre-upgrade-checks:latest

popd
Expand Down
1 change: 1 addition & 0 deletions hack/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ fi

release_environment_check $version $chartsrepo

go mod vendor
# Build release-builder image
docker build -t fission-release-builder -f $GOPATH/src/github.com/fission/fission/hack/Dockerfile .

Expand Down
3 changes: 0 additions & 3 deletions preupgradechecks/Dockerfile

This file was deleted.

28 changes: 28 additions & 0 deletions preupgradechecks/Dockerfile.fission-preupgradechecks
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM golang:1.11-alpine as builder
RUN apk add bash ca-certificates git gcc g++ libc-dev

ARG GITCOMMIT=unknown
# E.g. GITCOMMIT=$(git rev-parse HEAD)

ARG BUILDVERSION=unknown
# E.g. BUILDVERSION=$(git rev-parse HEAD)

ARG BUILDDATE=unknown
# E.g. BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')

ARG GOPKG=github.com/fission/fission
COPY . /go/src/${GOPKG}
WORKDIR /go/src/${GOPKG}/preupgradechecks
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a \
-o /go/bin/pre-upgrade-checks \
-gcflags=-trimpath=$GOPATH \
-asmflags=-trimpath=$GOPATH \
-ldflags "-X github.com/fission/fission.GitCommit=${GITCOMMIT} -X github.com/fission/fission.BuildDate=${BUILDDATE} -X github.com/fission/fission.Version=${BUILDVERSION}"


FROM alpine:3.4
RUN apk add --update ca-certificates
COPY --from=builder /go/bin/pre-upgrade-checks /

ENTRYPOINT ["/pre-upgrade-checks"]
EXPOSE 8001
18 changes: 0 additions & 18 deletions preupgradechecks/build.sh

This file was deleted.

58 changes: 58 additions & 0 deletions skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
####################################
# This file can be used with Skaffold (https://github.com/GoogleContainerTools/skaffold) to
# build and deploy Fission to Kubernetes cluster.
#
############## Usage ##############
# Skaffold CLI should be installed on your machine.
# Change <DOCKERHUB_REPO> -> to your Dockerhub username
# Run `go mod vendor` so that all dependencies are downloaded
# Run `skaffold run` to build and deploy with helm.
# Run`skaffold build` to only build and push images
############## Current Limitations ##############
# 1) You can not refer to dynamically generated tag from build section in Helm values
# - hence you have to use "latest" tag
############### Possible enhancements ##############
# 1) Add profiles to suit various deployment needs
####################################
apiVersion: skaffold/v1beta9
kind: Config
build:
artifacts:
- image: <DOCKERHUB_REPO>/fission
context: .
docker:
dockerfile: fission-bundle/Dockerfile.fission-bundle
- image: <DOCKERHUB_REPO>/fetcher
docker:
dockerfile: environments/fetcher/cmd/Dockerfile.fission-fetcher
- image: <DOCKERHUB_REPO>/preupgradechecks
docker:
dockerfile: preupgradechecks/Dockerfile.fission-preupgradechecks
tagPolicy:
envTemplate:
template: "{{.IMAGE_NAME}}:skaffold-test"

deploy:
helm:
releases:
- name: fission
chartPath: ./charts/fission-all
valuesFiles:
- ./charts/fission-all/values.yaml
namespace: "fission"
setValues:
image: <DOCKERHUB_REPO>/fission
imageTag: skaffold-test
fetcherImage: <DOCKERHUB_REPO>/fetcher
fetcherImageTag: skaffold-test
namespace: fission
preUpgradeChecksImage: <DOCKERHUB_REPO>/preupgradechecks
repository: index.docker.io
setValueTemplates: {}
wait: true
recreatePods: false
overrides: {}
packaged: null
imageStrategy:
fqn: null
helm: null
Loading

0 comments on commit 49f9944

Please sign in to comment.