Skip to content

Commit

Permalink
chore(ci): updtae goboring to 1.17.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Zenithar committed Jan 12, 2022
1 parent 289d9a5 commit d10447c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 69 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/docker-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@ name: Build and push docker tools
env:
REGISTRY: ghcr.io

on:
push:
branches:
- main
paths:
- 'build/**'
- 'tools/**'
- '.github/workflows/docker-tools.yml'
release:
types: [published]
on: workflow_dispatch

jobs:
build-push:
Expand All @@ -26,12 +17,14 @@ jobs:
matrix:
include:
# normal
- golang-image: "golang"
golang-version: "1.17"
- golang-image: "golang:1.17"
golang-version: "1.17.5"
goboring-version: ""
tools-image: harp-tools
# fips
- golang-image: "goboring/golang"
golang-version: "1.16.7b7"
- golang-image: "goboring/golang:1.16.7b7"
golang-version: "1.17.5"
goboring-version: "1.17.5b7"
tools-image: harp-tools-fips
steps:
-
Expand Down Expand Up @@ -65,11 +58,13 @@ jobs:
echo "DOCKERFILE_ONLY=1" >> $GITHUB_ENV
echo "GOLANG_IMAGE=$GOLANG_IMAGE" >> $GITHUB_ENV
echo "GOLANG_VERSION=$GOLANG_VERSION" >> $GITHUB_ENV
echo "GOBORING_VERSION=$GOBORING_VERSION" >> $GITHUB_ENV
echo "DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME" >> $GITHUB_ENV
env:
DOCKERFILE_ONLY: 1
GOLANG_IMAGE: ${{ matrix.golang-image }}
GOLANG_VERSION: ${{ matrix.golang-version }}
GOBORING_VERSION: ${{ matrix.goboring-version }}
DOCKER_IMAGE_NAME: ${{ matrix.tools-image }}
-
name: Generate Dockerfile
Expand All @@ -96,7 +91,7 @@ jobs:
tags: |
ghcr.io/elastic/harp/${{ matrix.tools-image }}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
build-args: |
GOLANG_IMAGE=${{ matrix.golang-image }}
GOLANG_VERSION=${{ matrix.golang-version }}
Expand Down Expand Up @@ -124,3 +119,8 @@ jobs:
env:
COSIGN_KEY: ${{ secrets.COSIGN_KEY }}
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
-
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
14 changes: 0 additions & 14 deletions build/mage/docker/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ ARG VCS_REF={{.VcsRef}}
# Builder arguments
ARG TOOLS_IMAGE={{.ToolImageName}}
ARG GOLANG_IMAGE={{.GolangImage}}
ARG GOLANG_VERSION={{.GolangVersion}}
FROM $TOOLS_IMAGE as compiler
Expand Down Expand Up @@ -125,16 +123,6 @@ func Build(cmd *artifact.Command) func() error {
return func() error {
mg.Deps(git.CollectInfo)

// Retrieve golang attributes
golangImage := golangImage
if os.Getenv("GOLANG_IMAGE") != "" {
golangImage = os.Getenv("GOLANG_IMAGE")
}
golangVersion := golangVersion
if os.Getenv("GOLANG_VERSION") != "" {
golangVersion = os.Getenv("GOLANG_VERSION")
}

// Docker image name
toolImageName := toolImage
if os.Getenv("TOOL_IMAGE_NAME") != "" {
Expand All @@ -146,8 +134,6 @@ func Build(cmd *artifact.Command) func() error {
"BuildDate": time.Now().Format(time.RFC3339),
"Version": git.Tag,
"VcsRef": git.Revision,
"GolangImage": golangImage,
"GolangVersion": golangVersion,
"Cmd": cmd,
})
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions build/mage/docker/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ package docker

const (
// Standard build mode
golangImage = "golang"
golangVersion = "1.17"
toolImage = "elastic/harp-tools:latest"
golangImage = "golang:1.17"
golangVersion = "1.17.5"
goBoringVersion = "1.17.5b7"
toolImage = "elastic/harp-tools:latest"
)
15 changes: 1 addition & 14 deletions build/mage/docker/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ ARG VCS_REF={{.VcsRef}}
# Builder arguments
ARG TOOLS_IMAGE={{.ToolImageName}}
ARG GOLANG_IMAGE={{.GolangImage}}
ARG GOLANG_VERSION={{.GolangVersion}}
ARG RELEASE={{.Release}}
FROM $TOOLS_IMAGE as compiler
Expand Down Expand Up @@ -132,16 +130,6 @@ func Release(cmd *artifact.Command) func() error {
return func() error {
mg.Deps(git.CollectInfo)

// Retrieve golang attributes
golangImage := golangImage
if os.Getenv("GOLANG_IMAGE") != "" {
golangImage = os.Getenv("GOLANG_IMAGE")
}
golangVersion := golangVersion
if os.Getenv("GOLANG_VERSION") != "" {
golangVersion = os.Getenv("GOLANG_VERSION")
}

// Docker image name
toolImageName := toolImage
if os.Getenv("TOOL_IMAGE_NAME") != "" {
Expand All @@ -161,8 +149,6 @@ func Release(cmd *artifact.Command) func() error {
"BuildDate": time.Now().Format(time.RFC3339),
"Version": git.Tag,
"VcsRef": git.Revision,
"GolangImage": golangImage,
"GolangVersion": golangVersion,
"Cmd": cmd,
"Release": release,
})
Expand All @@ -176,6 +162,7 @@ func Release(cmd *artifact.Command) func() error {
}

// Prepare command
//nolint:gosec // Expected behavior
c := exec.Command("docker", "build",
"-t", fmt.Sprintf("elastic/%s:artifacts-%s", cmd.Kebab(), relVer.String()),
"-f", "-",
Expand Down
61 changes: 38 additions & 23 deletions build/mage/docker/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ ARG BUILD_DATE={{.BuildDate}}
ARG VERSION={{.Version}}
ARG VCS_REF={{.VcsRef}}
# Builder argumentsgolang
ARG GOLANG_IMAGE={{.GolangImage}}
# Builder arguments
ARG GOLANG_BASE_IMAGE={{.GolangImage}}
ARG GOLANG_VERSION={{.GolangVersion}}
## -------------------------------------------------------------------------------------------------
FROM ${GOLANG_IMAGE}:${GOLANG_VERSION}
FROM ${GOLANG_BASE_IMAGE}
# Arguments
ARG BUILD_DATE={{.BuildDate}}
Expand All @@ -57,14 +57,21 @@ ARG GOLANG_VERSION={{.GolangVersion}}
LABEL \
org.opencontainers.image.created=$BUILD_DATE \
org.opencontainers.image.title="Harp SDK Environment" \
org.opencontainers.image.description="Harp SDK Tools used to build harp and all related tools" \
org.opencontainers.image.url="https://github.com/elastic/harp" \
org.opencontainers.image.source="https://github.com/elastic/harp.git" \
org.opencontainers.image.revision=$VCS_REF \
org.opencontainers.image.vendor="Elastic" \
org.opencontainers.image.version=$VERSION \
org.opencontainers.image.licences="ASL2"
org.opencontainers.image.title="Harp SDK Environment (Go {{.GolangVersion}})" \
org.opencontainers.image.description="Harp SDK Tools used to build harp and all related tools" \
org.opencontainers.image.url="https://github.com/elastic/harp" \
org.opencontainers.image.source="https://github.com/elastic/harp.git" \
org.opencontainers.image.revision=$VCS_REF \
org.opencontainers.image.vendor="Elastic" \
org.opencontainers.image.version=$VERSION \
org.opencontainers.image.licences="ASL2"
{{ if .OverrideGoBoringVersion }}
# Override goboring version
RUN wget https://storage.googleapis.com/go-boringcrypto/go{{ .GoBoringVersion }}.linux-amd64.tar.gz \
&& rm -rf /usr/local/go && tar -C /usr/local -xzf go{{ .GoBoringVersion }}.linux-amd64.tar.gz \
rm go{{ .GoBoringVersion }}.linux-amd64.tar.gz
{{ end }}
# hadolint ignore=DL3008
RUN set -eux; \
Expand Down Expand Up @@ -105,11 +112,11 @@ ENV USER golang
# Clean go mod cache
RUN set -eux; \
go clean -modcache
go clean -modcache
# Checkout mage
RUN set -eux; \
git clone https://github.com/magefile/mage .mage
git clone https://github.com/magefile/mage .mage
# Go to tools
WORKDIR $GOPATH/src/workspace/.mage
Expand All @@ -128,7 +135,7 @@ WORKDIR $GOPATH/src/workspace/tools
# Install tools
RUN set -eux; \
mage
mage
# Set path for tools usages
ENV PATH=$GOPATH/src/workspace/tools/bin:$PATH
Expand All @@ -139,21 +146,29 @@ func Tools() error {
mg.Deps(git.CollectInfo)

// Retrieve golang attributes
golangImage := golangImage
if os.Getenv("GOLANG_IMAGE") != "" {
golangImage = os.Getenv("GOLANG_IMAGE")
golangBaseImage := golangImage
if os.Getenv("GOLANG_BASE_IMAGE") != "" {
golangBaseImage = os.Getenv("GOLANG_BASE_IMAGE")
}
golangVersion := golangVersion
if os.Getenv("GOLANG_VERSION") != "" {
golangVersion = os.Getenv("GOLANG_VERSION")
}
goBoringVersion := goBoringVersion
overrideGoBoringVersion := false
if os.Getenv("GOBORING_VERSION") != "" {
goBoringVersion = os.Getenv("GOBORING_VERSION")
overrideGoBoringVersion = true
}

buf, err := merge(dockerToolTemplate, map[string]string{
"BuildDate": time.Now().Format(time.RFC3339),
"Version": git.Tag,
"VcsRef": git.Revision,
"GolangImage": golangImage,
"GolangVersion": golangVersion,
buf, err := merge(dockerToolTemplate, map[string]interface{}{
"BuildDate": time.Now().Format(time.RFC3339),
"Version": git.Tag,
"VcsRef": git.Revision,
"GolangImage": golangBaseImage,
"GolangVersion": golangVersion,
"OverrideGoBoringVersion": overrideGoBoringVersion,
"GoBoringVersion": goBoringVersion,
})
if err != nil {
return err
Expand Down

0 comments on commit d10447c

Please sign in to comment.