reuse same base image across all targets (#202)

This commit is contained in:
Itxaka 2024-01-15 13:54:38 +01:00 committed by GitHub
parent 7b3149e9ce
commit 96d9f402a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 12 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
set -e set -ex
# Run agent in the background to bring the webui up # Run agent in the background to bring the webui up
/usr/bin/kairos-agent webui & /usr/bin/kairos-agent webui &

View File

@ -14,7 +14,7 @@ jobs:
strategy: strategy:
matrix: 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 # 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 runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code

View File

@ -13,7 +13,7 @@ jobs:
strategy: strategy:
matrix: 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 # 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 runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4

View File

@ -3,13 +3,14 @@ FROM alpine
# renovate: datasource=docker depName=golang # renovate: datasource=docker depName=golang
ARG --global GOLINT_VERSION=1.52.2 ARG --global GOLINT_VERSION=1.52.2
# renovate: datasource=docker depName=golang # 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 # renovate: datasource=docker depName=cypress/base
ARG --global CYPRESS_VERSION=18.16.0 ARG --global CYPRESS_VERSION=18.16.0
go-deps: go-deps:
ARG GO_VERSION ARG GO_VERSION
FROM golang:$GO_VERSION FROM golang:$GO_VERSION
RUN apt-get update && apt-get install -y rsync gcc bash git
WORKDIR /build WORKDIR /build
COPY go.mod go.sum ./ COPY go.mod go.sum ./
RUN go mod download RUN go mod download
@ -18,7 +19,6 @@ go-deps:
test: test:
FROM +go-deps FROM +go-deps
RUN apk add rsync gcc musl-dev bash
WORKDIR /build WORKDIR /build
COPY . . COPY . .
ARG TEST_PATHS=./... ARG TEST_PATHS=./...
@ -28,8 +28,7 @@ test:
SAVE ARTIFACT coverage.out AS LOCAL coverage.out SAVE ARTIFACT coverage.out AS LOCAL coverage.out
version: version:
FROM alpine FROM +go-deps
RUN apk add git
COPY . ./ COPY . ./
RUN --no-cache echo $(git describe --always --tags --dirty) > VERSION RUN --no-cache echo $(git describe --always --tags --dirty) > VERSION
RUN --no-cache echo $(git describe --always --dirty) > COMMIT RUN --no-cache echo $(git describe --always --dirty) > COMMIT
@ -40,7 +39,6 @@ version:
build-kairos-agent: build-kairos-agent:
FROM +go-deps FROM +go-deps
RUN apk add upx
COPY . . COPY . .
COPY +webui-deps/node_modules ./internal/webui/public/node_modules COPY +webui-deps/node_modules ./internal/webui/public/node_modules
COPY github.com/kairos-io/kairos-docs:main+docs/public ./internal/webui/public/local COPY github.com/kairos-io/kairos-docs:main+docs/public ./internal/webui/public/local
@ -50,16 +48,15 @@ build-kairos-agent:
ARG COMMIT=$(cat COMMIT) ARG COMMIT=$(cat COMMIT)
RUN --no-cache echo "Building Version: ${VERSION} and Commit: ${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" 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} ENV CGO_ENABLED=0
RUN go build -o kairos-agent -ldflags "${LDFLAGS}" main.go && upx kairos-agent RUN go build -o kairos-agent -ldflags "${LDFLAGS}" main.go
SAVE ARTIFACT kairos-agent kairos-agent AS LOCAL build/kairos-agent SAVE ARTIFACT kairos-agent kairos-agent AS LOCAL build/kairos-agent
build: build:
BUILD +build-kairos-agent BUILD +build-kairos-agent
golint: golint:
ARG GO_VERSION FROM +go-deps
FROM golang:$GO_VERSION
ARG GOLINT_VERSION ARG GOLINT_VERSION
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v$GOLINT_VERSION RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v$GOLINT_VERSION
WORKDIR /build WORKDIR /build