Skip to content

Commit ad6d65d

Browse files
committed
add fips compliant package builds
1 parent 1b1e88b commit ad6d65d

File tree

6 files changed

+114
-14
lines changed

6 files changed

+114
-14
lines changed

.github/renovate.json5

+22
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,28 @@
99
"ubuntu"
1010
],
1111
"enabled": false
12+
},
13+
{
14+
// Skip updating package builder image
15+
"matchDatasources": ["docker"],
16+
"matchPackageNames": ["ubuntu"],
17+
"enabled": false,
18+
},
19+
{
20+
"matchDatasources": [
21+
"dockerfile",
22+
"gomod"
23+
],
24+
"matchPackageNames": [
25+
"golang",
26+
"*"
27+
],
28+
"matchPaths": [
29+
"build/Dockerfile",
30+
"go.mod"
31+
],
32+
"extractVersion": "^ARG GO_VERSION=(?<version>.*)$",
33+
"groupName": "go-updates"
1234
}
1335
]
1436
}

build/.goreleaser.yml

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
---
2+
project_name: nri-flex
13
builds:
24
- id: nri-nix
35
main: ./src
@@ -13,7 +15,25 @@ builds:
1315
- amd64
1416
- arm
1517
- arm64
16-
18+
- id: nri-nix-fips
19+
main: ./src
20+
binary: nri-docker
21+
ldflags:
22+
- -s -w -X main.integrationVersion={{.Version}} -X main.gitCommit={{.Commit}} -X main.buildDate={{.Date}}
23+
env:
24+
- CGO_ENABLED=1
25+
- GOEXPERIMENT=boringcrypto
26+
- >-
27+
{{- if eq .Arch "arm64" -}}
28+
CC=aarch64-linux-gnu-gcc
29+
{{- end }}
30+
goos:
31+
- linux
32+
goarch:
33+
- amd64
34+
- arm64
35+
tags:
36+
- fips
1737
archives:
1838
- id: nri-nix
1939
builds:
@@ -23,6 +43,14 @@ archives:
2343
- docker-config.yml
2444
- docker-definition.yml
2545
format: tar.gz
46+
- id: nri-nix-fips
47+
builds:
48+
- nri-nix-fips
49+
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Version }}_{{ .Arch }}_fips_dirty"
50+
files:
51+
- docker-config.yml
52+
- docker-definition.yml
53+
format: tar.gz
2654

2755
# we use custom publisher for fixing archives and signing them
2856
release:

build/Dockerfile

+41-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,46 @@
1-
FROM golang:1.23.2-bookworm
1+
# Use Ubuntu 16.04 as the base image
2+
FROM ubuntu:16.04
23

3-
ARG GH_VERSION='2.23.0'
4+
# Define Go version
5+
ARG GO_VERSION=1.23.2
6+
ARG ARCH='amd64'
7+
ARG GH_VERSION='2.61.0'
48

5-
RUN apt-get update \
6-
&& apt-get -y install \
7-
rpm \
8-
gnupg2 \
9-
gpg-agent \
10-
debsigs \
11-
unzip \
12-
zip
9+
# Install dependencies
10+
RUN apt-get update && apt-get install -y \
11+
gnupg-agent \
12+
unzip \
13+
zip \
14+
curl \
15+
wget \
16+
expect \
17+
git \
18+
tar \
19+
gcc \
20+
jq \
21+
g++ \
22+
gnupg2 \
23+
gnupg-agent \
24+
debsigs \
25+
rpm \
26+
build-essential \
27+
software-properties-common \
28+
python-software-properties \
29+
gcc-arm-linux-gnueabi \
30+
dpkg-sig \
31+
gcc-aarch64-linux-gnu
32+
33+
# Install Go
34+
RUN curl -sSL https://golang.org/dl/go${GO_VERSION}.linux-${ARCH}.tar.gz -o go${GO_VERSION}.linux-${ARCH}.tar.gz && \
35+
tar -C /usr/local -xzf go${GO_VERSION}.linux-${ARCH}.tar.gz && \
36+
rm go${GO_VERSION}.linux-${ARCH}.tar.gz
37+
38+
# Set Go environment variables
39+
ENV PATH="/usr/local/go/bin:${PATH}"
40+
ENV GOPATH="/go"
41+
42+
# Optional: Set Go environment flags
43+
ENV GOFLAGS="-buildvcs=false"
1344

1445
# Since the user does not match the owners of the repo "git rev-parse --is-inside-work-tree" fails and goreleaser does not populate projectName
1546
# https://stackoverflow.com/questions/72978485/git-submodule-update-failed-with-fatal-detected-dubious-ownership-in-repositor

build/release.mk

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BUILD_DIR := ./bin/
2-
GORELEASER_VERSION := v0.172.1
2+
GORELEASER_VERSION := v2.4.4
33
GORELEASER_BIN ?= bin/goreleaser
44

55
bin:
@@ -27,10 +27,10 @@ release/deps: $(GORELEASER_BIN)
2727
release/build: release/deps release/clean
2828
ifeq ($(PRERELEASE), true)
2929
@echo "===> $(INTEGRATION) === [release/build] PRE-RELEASE compiling all binaries, creating packages, archives"
30-
@$(GORELEASER_BIN) release --config $(CURDIR)/build/.goreleaser.yml --rm-dist
30+
@$(GORELEASER_BIN) release --config $(CURDIR)/build/.goreleaser.yml --clean
3131
else
3232
@echo "===> $(INTEGRATION) === [release/build] build compiling all binaries"
33-
@$(GORELEASER_BIN) build --config $(CURDIR)/build/.goreleaser.yml --snapshot --rm-dist
33+
@$(GORELEASER_BIN) build --config $(CURDIR)/build/.goreleaser.yml --snapshot --clean
3434
endif
3535

3636
.PHONY : release/fix-archive

build/s3-publish-schema.yml

+8
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@
1111
- 386
1212
- arm
1313
- arm64
14+
15+
- src: "{app_name}_linux_{version}_{arch}_fips.tar.gz"
16+
uploads:
17+
- type: file
18+
dest: "{dest_prefix}binaries/linux/{arch}/{src}"
19+
arch:
20+
- amd64
21+
- arm64

src/fips.go

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2024 New Relic Corporation. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
//go:build fips
5+
// +build fips
6+
7+
package main
8+
9+
import (
10+
_ "crypto/tls/fipsonly"
11+
)

0 commit comments

Comments
 (0)