Skip to content

Commit 2d9a994

Browse files
authored
Merge pull request #39 from spectrocloud/fips-cicd
Spectro FIPS and CICD
2 parents c143588 + 7d8674a commit 2d9a994

File tree

3 files changed

+91
-10
lines changed

3 files changed

+91
-10
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Spectro Release
2+
run-name: Release for Cluster API Vsphere Static IP ${{ github.event.inputs.release_version }}
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_version:
7+
description: 'Cluster API Version to Build'
8+
required: true
9+
default: '0.0.0'
10+
jobs:
11+
builder:
12+
# edge-runner machine group is a bunch of machines in US Datacenter
13+
runs-on: ubuntu-latest
14+
# Initialize all secrets required for the job
15+
# Ensure that the credentials are provided as encrypted secrets
16+
env:
17+
SPECTRO_VERSION: ${{ github.event.inputs.release_version }}
18+
steps:
19+
-
20+
uses: mukunku/[email protected]
21+
id: checkTag
22+
with:
23+
tag: spectro-v${{ github.event.inputs.release_version }}
24+
-
25+
if: ${{ steps.checkTag.outputs.exists == 'true' }}
26+
run: |
27+
echo "Tag already exists for spectro-v${{ github.event.inputs.release_version }}..."
28+
exit 1
29+
-
30+
uses: actions/checkout@v3
31+
-
32+
name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v1
34+
-
35+
name: Login to private registry
36+
uses: docker/login-action@v1
37+
with:
38+
registry: ${{ secrets.REGISTRY_URL }}
39+
username: ${{ secrets.REGISTRY_USERNAME }}
40+
password: ${{ secrets.REGISTRY_PASSWORD }}
41+
-
42+
name: Build Image
43+
env:
44+
REGISTRY: gcr.io/spectro-images-public/release/cluster-api-vsphere
45+
run: |
46+
make docker-build
47+
make docker-push
48+
-
49+
name: Build Image - FIPS Mode
50+
env:
51+
FIPS_ENABLE: yes
52+
REGISTRY: gcr.io/spectro-images-public/release-fips/cluster-api-vsphere
53+
run: |
54+
make docker-build
55+
make docker-push
56+
-
57+
name: Create Release
58+
id: create_release
59+
uses: actions/create-release@v1
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
with:
63+
tag_name: spectro-v${{ github.event.inputs.release_version }}
64+
release_name: Release spectro-v${{ github.event.inputs.release_version }}
65+
body: |
66+
Release version ${{ github.event.inputs.release_version }}
67+
draft: false
68+
prerelease: false

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Build the manager binary
22
FROM golang:1.19.8 as builder
33

4+
# FIPS
5+
ARG CRYPTO_LIB
6+
ENV GOEXPERIMENT=${CRYPTO_LIB:+boringcrypto}
7+
48
WORKDIR /workspace
59
# Copy the Go Modules manifests
610
COPY go.mod go.mod
@@ -13,12 +17,12 @@ RUN go mod download
1317
COPY . .
1418

1519
# Build
16-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
20+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags "${LDFLAGS} -extldflags '-static'" -a -o manager main.go
1721

1822
# Use distroless as minimal base image to package the manager binary
1923
# Refer to https://github.com/GoogleContainerTools/distroless for more details
2024
#FROM gcr.io/distroless/static:latest
21-
FROM alpine:3.17
25+
FROM alpine:3.18
2226
RUN addgroup -S spectro
2327
RUN adduser -S -D -h / spectro spectro
2428
USER spectro

Makefile

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11

22
.DEFAULT_GOAL:=help
33

4-
VERSION_SUFFIX ?= -dev
5-
PROD_VERSION ?= 0.7.4${VERSION_SUFFIX}
6-
PROD_BUILD_ID ?= latest
4+
# Fips Flags
5+
FIPS_ENABLE ?= ""
76

8-
IMG_URL ?= gcr.io/$(shell gcloud config get-value project)/${USER}
9-
IMG_TAG ?= latest
10-
STATIC_IP_IMG ?= ${IMG_URL}/capv-static-ip:${IMG_TAG}
11-
OVERLAY ?= base
7+
RELEASE_LOC := release
8+
ifeq ($(FIPS_ENABLE),yes)
9+
RELEASE_LOC := release-fips
10+
endif
11+
12+
SPECTRO_VERSION ?= 4.0.0-dev
13+
TAG ?= spectro-${SPECTRO_VERSION}
14+
ARCH ?= amd64
15+
# ALL_ARCH = amd64 arm arm64 ppc64le s390x
16+
ALL_ARCH = amd64
17+
18+
REGISTRY ?= gcr.io/spectro-dev-public/$(USER)/${RELEASE_LOC}
19+
20+
STATIC_IP_IMG ?= ${REGISTRY}/capv-static-ip:${TAG}
1221

1322
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
1423
CRD_OPTIONS ?= "crd:trivialVersions=true"
@@ -82,7 +91,7 @@ bin: generate ## Generate binaries
8291
docker: docker-build docker-push ## Tags docker image and also pushes it to container registry
8392

8493
docker-build: ## Build the docker image for controller-manager
85-
docker build . -t ${STATIC_IP_IMG}
94+
docker build --build-arg CRYPTO_LIB=${FIPS_ENABLE} . -t ${STATIC_IP_IMG}
8695

8796
docker-push: ## Push the docker image
8897
docker push ${STATIC_IP_IMG}

0 commit comments

Comments
 (0)