diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..b80b8e6 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,79 @@ +version: 2.1 +orbs: + anchore: anchore/anchore-engine@1.3.0 +jobs: + "test": + docker: + - image: circleci/golang:1.12.4 + working_directory: ~/fdk-go + steps: + - checkout + - setup_remote_docker: + docker_layer_caching: true + - run: docker pull fnproject/fnserver + - run: + command: go test -v ./... + - deploy: + command: | + if [[ "${CIRCLE_BRANCH}" == "master" && -z "${CIRCLE_PR_REPONAME}" ]]; then + printenv DOCKER_PASS | docker login -u ${DOCKER_USER} --password-stdin + git config --global user.email "ci@fnproject.com" + git config --global user.name "CI" + git branch --set-upstream-to=origin/${CIRCLE_BRANCH} ${CIRCLE_BRANCH} + fi + + "go1_stretch_security_check": + executor: anchore/anchore_engine + working_directory: ~/fdk-go + steps: + - setup_remote_docker: + docker_layer_caching: true + - checkout + - run: + name: Golang 1 Stretch build + command: | + apk add bash + ./build-images.sh 1 stretch + - anchore/analyze_local_image: + image_name: "fnproject/go:1-stretch fnproject/go:1-stretch-dev" + timeout: '500' + policy_failure: true + policy_bundle_file_path: .circleci/.anchore/policy_bundle.json + - anchore/parse_reports + + "go1_alpine_security_check": + executor: anchore/anchore_engine + working_directory: ~/fdk-go + steps: + - setup_remote_docker: + docker_layer_caching: true + - checkout + - run: + name: Golang 1 Alpine 3.8 build + command: | + apk add bash + ./build-images.sh 1 alpine + - anchore/analyze_local_image: + image_name: "fnproject/go:1-alpine fnproject/go:1-alpine-dev" + timeout: '500' + policy_failure: true + policy_bundle_file_path: .circleci/.anchore/policy_bundle.json + - anchore/parse_reports + +workflows: + version: 2 + build: + jobs: + - "test" + nightly: + triggers: + - schedule: + cron: "0 0 * * *" + filters: + branches: + only: + - master + jobs: + - "test" + - "go1_stretch_security_check" + - "go1_alpine_security_check" diff --git a/build-images.sh b/build-images.sh new file mode 100755 index 0000000..909bb3c --- /dev/null +++ b/build-images.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -xe + +goversion=${1:-"1"} +ostype=${2:-"alpine"} + +pushd images/${goversion}/${ostype}/build-stage && docker build -t fnproject/go:${goversion}-${ostype}-dev . && popd +pushd images/${goversion}/${ostype}/runtime && docker build -t fnproject/go:${goversion}-${ostype} . && popd diff --git a/circle.yml b/circle.yml deleted file mode 100644 index c0bfbce..0000000 --- a/circle.yml +++ /dev/null @@ -1,42 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: circleci/golang:1.11.0 - working_directory: ~/fdk-go - steps: - - checkout - - setup_remote_docker: - docker_layer_caching: true - - run: docker version - - run: docker pull fnproject/fnserver - # installing Fn CLI and starting the Fn server - - run: - command: | - curl -LSs https://raw.githubusercontent.com/fnproject/cli/master/install | sh - - run: - command: fn build - working_directory: examples/hello - - run: - command: docker build -t fnproject/fdk-go-init . - working_directory: images/init - - run: - command: docker build -t fnproject/fdk-go-build . - working_directory: images/build - - run: - command: docker build -t fnproject/fdk-go-runtime . - working_directory: images/runtime - - deploy: - command: | - if [[ "${CIRCLE_BRANCH}" == "master" && -z "${CIRCLE_PR_REPONAME}" ]]; then - func_version=$(awk '/^version:/ { print $2; }' func.yaml) - printenv DOCKER_PASS | docker login -u ${DOCKER_USER} --password-stdin - git config --global user.email "ci@fnproject.com" - git config --global user.name "CI" - git branch --set-upstream-to=origin/${CIRCLE_BRANCH} ${CIRCLE_BRANCH} - docker tag "hello:${func_version}" "fnproject/fdk-go-hello:${func_version}" - docker tag "hello:${func_version}" "fnproject/fdk-go-hello:latest" - docker push "fnproject/fdk-go-hello:${func_version}" - docker push "fnproject/fdk-go-hello:latest" - fi - working_directory: examples/hello diff --git a/images/1/alpine/build-stage/Dockerfile b/images/1/alpine/build-stage/Dockerfile new file mode 100644 index 0000000..2930364 --- /dev/null +++ b/images/1/alpine/build-stage/Dockerfile @@ -0,0 +1,4 @@ +FROM golang:1-alpine3.8 + +RUN apk update && apk upgrade && \ + apk add --no-cache wget curl git bzr mercurial build-base diff --git a/images/runtime/Dockerfile b/images/1/alpine/runtime/Dockerfile similarity index 99% rename from images/runtime/Dockerfile rename to images/1/alpine/runtime/Dockerfile index 43a2e16..bc99d25 100644 --- a/images/runtime/Dockerfile +++ b/images/1/alpine/runtime/Dockerfile @@ -3,5 +3,4 @@ FROM alpine:3.8 RUN apk update && apk upgrade \ && apk add ca-certificates \ && rm -rf /var/cache/apk/* - RUN addgroup -g 1000 -S fn && adduser -S -u 1000 -G fn fn diff --git a/images/1/stretch/build-stage/Dockerfile b/images/1/stretch/build-stage/Dockerfile new file mode 100644 index 0000000..9b63cac --- /dev/null +++ b/images/1/stretch/build-stage/Dockerfile @@ -0,0 +1,5 @@ +FROM golang:1-stretch + +RUN apt-get update && apt-get upgrade -qy && \ + apt-get install wget curl mercurial build-essential gcc -qy && \ + apt-get clean diff --git a/images/1/stretch/runtime/Dockerfile b/images/1/stretch/runtime/Dockerfile new file mode 100644 index 0000000..01c12de --- /dev/null +++ b/images/1/stretch/runtime/Dockerfile @@ -0,0 +1,4 @@ +FROM debian:stretch-slim + +RUN apt-get update && apt-get upgrade -qy && apt-get clean +RUN addgroup --system --gid 1000 --system fn && adduser --system --uid 1000 --ingroup fn fn diff --git a/images/build/Dockerfile b/images/build/Dockerfile deleted file mode 100644 index 81fcc10..0000000 --- a/images/build/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM golang:1.11.0-alpine3.8 - -RUN apk add --no-cache wget curl git bzr mercurial build-base diff --git a/release_images.sh b/release_images.sh new file mode 100755 index 0000000..dd60aaa --- /dev/null +++ b/release_images.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +user="fnproject" +image="go" +goversion="1" +stretch="stretch" +alpine="alpine" + + +docker push ${user}/${image}:${goversion}-${stretch} +docker push ${user}/${image}:${goversion}-${stretch}-dev + +docker push ${user}/${image}:${goversion}-${alpine} +docker push ${user}/${image}:${goversion}-${alpine}-dev