Skip to content

Commit

Permalink
Merge pull request #125 from hyperledger/base_image
Browse files Browse the repository at this point in the history
Allow configuration of a base and build image in Dockerfile
  • Loading branch information
peterbroadhurst authored May 23, 2024
2 parents c7dc33d + 66e0aba commit 3a3c7af
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/docker_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
--label commit=$GITHUB_SHA \
--label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label tag=${{ steps.build_tag_generator.outputs.BUILD_TAG }} \
--build-arg BASE_IMAGE=alpine:3.19 \
--build-arg BUILD_IMAGE=golang:1.21-alpine3.19 \
--tag ghcr.io/hyperledger/firefly-fabconnect:${{ steps.build_tag_generator.outputs.BUILD_TAG }} .
- name: Tag release
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/docker_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
--label commit=$GITHUB_SHA \
--label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label tag=${GITHUB_REF##*/} \
--build-arg BASE_IMAGE=alpine:3.19 \
--build-arg BUILD_IMAGE=golang:1.21-alpine3.19 \
--tag ghcr.io/hyperledger/firefly-fabconnect:${GITHUB_REF##*/} \
--tag ghcr.io/hyperledger/firefly-fabconnect:head \
.
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ jobs:
--label commit=$GITHUB_SHA \
--label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label tag=${{ steps.build_tag_generator.outputs.BUILD_TAG }} \
--build-arg BASE_IMAGE=alpine:3.19 \
--build-arg BUILD_IMAGE=golang:1.21-alpine3.19 \
--tag ghcr.io/hyperledger/firefly-fabconnect:${{ steps.build_tag_generator.outputs.BUILD_TAG }} .
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM golang:1.21-alpine3.19 AS fabconnect-builder
ARG BASE_IMAGE
ARG BUILD_IMAGE

FROM ${BUILD_IMAGE} AS fabconnect-builder
RUN apk add make
ADD . /fabconnect
WORKDIR /fabconnect
Expand All @@ -15,7 +18,7 @@ RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/
RUN trivy fs --format spdx-json --output /sbom.spdx.json /SBOM
RUN trivy sbom /sbom.spdx.json --severity UNKNOWN,HIGH,CRITICAL --exit-code 1 --ignorefile /SBOM/.trivyignore

FROM alpine:3.19
FROM $BASE_IMAGE
RUN apk add curl
WORKDIR /fabconnect
COPY --from=fabconnect-builder /fabconnect/fabconnect ./
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ firefly-fabconnect: ${GOFILES}
$(VGO) build -o ${BINARY_NAME} -ldflags "-X main.buildDate=`date -u +\"%Y-%m-%dT%H:%M:%SZ\"` -X main.buildVersion=$(BUILD_VERSION)" -tags=prod -tags=prod -v
go-mod-tidy: .ALWAYS
go mod tidy
docker:
docker build --build-arg BASE_IMAGE=alpine:3.19 --build-arg BUILD_IMAGE=golang:1.21-alpine3.19 -t hyperledger/firefly-fabconnect .
build: firefly-fabconnect-nocgo firefly-fabconnect
.ALWAYS: ;
clean:
Expand Down

0 comments on commit 3a3c7af

Please sign in to comment.