Skip to content

Commit

Permalink
reuse same base image across all targets (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
Itxaka authored Jan 15, 2024
1 parent 7b3149e commit 96d9f40
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/cypress_tests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -e
set -ex
# Run agent in the background to bring the webui up
/usr/bin/kairos-agent webui &

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
# Match this version to the maintained FIPS version in packages at https://github.com/kairos-io/packages/blob/main/packages/toolchain-go/collection.yaml#L63
go-version: ["1.19.10-alpine3.18", "1.20-alpine3.18", "1.21-alpine3.18"]
go-version: ["1.19.10-bookworm", "1.20-bookworm", "1.21-bookworm"]
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/webui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
# Match this version to the maintained FIPS version in packages at https://github.com/kairos-io/packages/blob/main/packages/toolchain-go/collection.yaml#L63
go-version: [ "1.19.10-alpine3.18", "1.20-alpine3.18", "1.21-alpine3.18" ]
go-version: [ "1.19.10-bookworm", "1.20-bookworm", "1.21-bookworm" ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
15 changes: 6 additions & 9 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ FROM alpine
# renovate: datasource=docker depName=golang
ARG --global GOLINT_VERSION=1.52.2
# renovate: datasource=docker depName=golang
ARG --global GO_VERSION=1.20-alpine3.17
ARG --global GO_VERSION=1.20-bookworm
# renovate: datasource=docker depName=cypress/base
ARG --global CYPRESS_VERSION=18.16.0

go-deps:
ARG GO_VERSION
FROM golang:$GO_VERSION
RUN apt-get update && apt-get install -y rsync gcc bash git
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
Expand All @@ -18,7 +19,6 @@ go-deps:

test:
FROM +go-deps
RUN apk add rsync gcc musl-dev bash
WORKDIR /build
COPY . .
ARG TEST_PATHS=./...
Expand All @@ -28,8 +28,7 @@ test:
SAVE ARTIFACT coverage.out AS LOCAL coverage.out

version:
FROM alpine
RUN apk add git
FROM +go-deps
COPY . ./
RUN --no-cache echo $(git describe --always --tags --dirty) > VERSION
RUN --no-cache echo $(git describe --always --dirty) > COMMIT
Expand All @@ -40,7 +39,6 @@ version:

build-kairos-agent:
FROM +go-deps
RUN apk add upx
COPY . .
COPY +webui-deps/node_modules ./internal/webui/public/node_modules
COPY github.com/kairos-io/kairos-docs:main+docs/public ./internal/webui/public/local
Expand All @@ -50,16 +48,15 @@ build-kairos-agent:
ARG COMMIT=$(cat COMMIT)
RUN --no-cache echo "Building Version: ${VERSION} and Commit: ${COMMIT}"
ARG LDFLAGS="-s -w -X github.com/kairos-io/kairos-agent/v2/internal/common.VERSION=${VERSION} -X github.com/kairos-io/kairos-agent/v2/internal/common.gitCommit=$COMMIT"
ENV CGO_ENABLED=${CGO_ENABLED}
RUN go build -o kairos-agent -ldflags "${LDFLAGS}" main.go && upx kairos-agent
ENV CGO_ENABLED=0
RUN go build -o kairos-agent -ldflags "${LDFLAGS}" main.go
SAVE ARTIFACT kairos-agent kairos-agent AS LOCAL build/kairos-agent

build:
BUILD +build-kairos-agent

golint:
ARG GO_VERSION
FROM golang:$GO_VERSION
FROM +go-deps
ARG GOLINT_VERSION
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v$GOLINT_VERSION
WORKDIR /build
Expand Down

0 comments on commit 96d9f40

Please sign in to comment.