Skip to content

Commit b48b0ba

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

File tree

5 files changed

+93
-14
lines changed

5 files changed

+93
-14
lines changed

build/.goreleaser.yml

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
---
2+
version: 2
3+
project_name: nri-docker
14
builds:
25
- id: nri-nix
36
main: ./src
@@ -13,7 +16,25 @@ builds:
1316
- amd64
1417
- arm
1518
- arm64
16-
19+
- id: nri-nix-fips
20+
main: ./src
21+
binary: nri-docker
22+
ldflags:
23+
- -s -w -X main.integrationVersion={{.Version}} -X main.gitCommit={{.Commit}} -X main.buildDate={{.Date}}
24+
env:
25+
- CGO_ENABLED=1
26+
- GOEXPERIMENT=boringcrypto
27+
- >-
28+
{{- if eq .Arch "arm64" -}}
29+
CC=aarch64-linux-gnu-gcc
30+
{{- end }}
31+
goos:
32+
- linux
33+
goarch:
34+
- amd64
35+
- arm64
36+
tags:
37+
- fips
1738
archives:
1839
- id: nri-nix
1940
builds:
@@ -23,6 +44,14 @@ archives:
2344
- docker-config.yml
2445
- docker-definition.yml
2546
format: tar.gz
47+
- id: nri-nix-fips
48+
builds:
49+
- nri-nix-fips
50+
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Version }}_{{ .Arch }}_fips_dirty"
51+
files:
52+
- docker-config.yml
53+
- docker-definition.yml
54+
format: tar.gz
2655

2756
# we use custom publisher for fixing archives and signing them
2857
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)