зеркало из https://github.com/Azure/ARO-RP.git
Integrate JS asset build into Golang Dockerfile to ensure consistent builds and deployment process" (#3576)
* SRE Portal build is now incorporated into the RP build process in "make ci-rp"
This commit is contained in:
Родитель
335e64a0b7
Коммит
7bf05051f0
|
@ -1,13 +0,0 @@
|
||||||
ARG REGISTRY
|
|
||||||
|
|
||||||
FROM ${REGISTRY}/ubi8/nodejs-16 AS portal-base
|
|
||||||
WORKDIR /build/portal/v2
|
|
||||||
USER root
|
|
||||||
|
|
||||||
FROM portal-base AS portal-build
|
|
||||||
COPY /portal/v2/package*.json ./
|
|
||||||
RUN npm ci
|
|
||||||
RUN npm audit --omit=dev
|
|
||||||
COPY /portal/v2/ ./
|
|
||||||
RUN npm run lint
|
|
||||||
RUN npm run build
|
|
|
@ -2,20 +2,38 @@ ARG REGISTRY
|
||||||
ARG VERSION
|
ARG VERSION
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
# Stage 1: Build the SRE Portal Assets
|
||||||
# builder is responsible for all compilation and validation of the RP
|
# builder is responsible for all compilation and validation of the RP
|
||||||
###############################################################################
|
###############################################################################
|
||||||
FROM ${REGISTRY}/ubi8/go-toolset:1.20.12-5 as builder
|
FROM ${REGISTRY}/ubi8/nodejs-16 as portal-build
|
||||||
|
WORKDIR /build/portal/v2
|
||||||
|
USER root
|
||||||
|
|
||||||
|
# Copying package files and installing dependencies
|
||||||
|
COPY portal/v2/package*.json ./
|
||||||
|
RUN npm ci
|
||||||
|
RUN npm audit --omit=dev # Run audit without dev dependencies
|
||||||
|
|
||||||
|
# Copying the rest of the source and build
|
||||||
|
COPY --chown=root:root portal/v2/ ./
|
||||||
|
RUN npm run lint && npm run build
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Stage 2: Compile the Golang RP code
|
||||||
|
###############################################################################
|
||||||
|
FROM ${REGISTRY}/ubi8/go-toolset:1.20.12-5 AS builder
|
||||||
USER root
|
USER root
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# golang config
|
# golang config and build steps
|
||||||
ENV GOPATH=/root/go
|
ENV GOPATH=/root/go
|
||||||
ENV GOFLAGS="-tags=containers_image_openpgp,exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper"
|
ENV GOFLAGS="-tags=containers_image_openpgp,exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper"
|
||||||
|
|
||||||
# install general build tools
|
# Install golangci-lint and verify
|
||||||
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin v1.56.2
|
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin v1.56.2 && \
|
||||||
|
golangci-lint --version || (echo "golangci-lint not found" && exit 1)
|
||||||
|
|
||||||
# copy from least changed -> most changed to improve cache hits
|
# Copy dependencies and source files
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
COPY vendor vendor
|
COPY vendor vendor
|
||||||
COPY swagger swagger
|
COPY swagger swagger
|
||||||
|
@ -25,20 +43,21 @@ COPY cmd cmd
|
||||||
COPY pkg pkg
|
COPY pkg pkg
|
||||||
COPY test test
|
COPY test test
|
||||||
|
|
||||||
# lint
|
# Ensure JS assets are available before generating Go code
|
||||||
RUN golangci-lint run --verbose
|
COPY --from=portal-build /build/pkg/portal/assets/v2/build /app/pkg/portal/assets/v2/build
|
||||||
|
|
||||||
# build
|
# Lint, generate, build, and test
|
||||||
|
RUN golangci-lint run --verbose
|
||||||
RUN go generate ./...
|
RUN go generate ./...
|
||||||
RUN go build -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=${VERSION}" ./cmd/aro
|
RUN go build -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=${VERSION}" ./cmd/aro
|
||||||
RUN go test ./test/e2e/... -tags e2e,codec.safe -c -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=${VERSION}" -o e2e.test
|
RUN go test ./test/e2e/... -tags e2e,codec.safe -c -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=${VERSION}" -o e2e.test
|
||||||
|
|
||||||
# test
|
# Additional tests
|
||||||
RUN ARO_RUN_PKI_TESTS=nope go run gotest.tools/gotestsum@v1.11.0 --format pkgname --junitfile report.xml -- -coverprofile=cover.out ./...
|
RUN ARO_RUN_PKI_TESTS=nope go run gotest.tools/gotestsum@v1.11.0 --format pkgname --junitfile report.xml -- -coverprofile=cover.out ./...
|
||||||
RUN hack/fips/validate-fips.sh ./aro
|
RUN hack/fips/validate-fips.sh ./aro
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# final is our slim image with minimal layers and tools
|
# Stage 3: final is our slim image with minimal layers and tools
|
||||||
###############################################################################
|
###############################################################################
|
||||||
FROM ${REGISTRY}/ubi8/ubi-minimal AS final
|
FROM ${REGISTRY}/ubi8/ubi-minimal AS final
|
||||||
RUN microdnf update && microdnf clean all
|
RUN microdnf update && microdnf clean all
|
||||||
|
|
|
@ -10,4 +10,17 @@
|
||||||
!pkg
|
!pkg
|
||||||
!swagger
|
!swagger
|
||||||
!test
|
!test
|
||||||
!vendor
|
!vendor
|
||||||
|
|
||||||
|
# Ignore locally built NPM artifacts - using new automated process
|
||||||
|
pkg/portal/assets/v2/build
|
||||||
|
|
||||||
|
# Allow files and directories for JavaScript build
|
||||||
|
!portal/v2/package*.json
|
||||||
|
!portal/v2/src
|
||||||
|
!portal/v2/public
|
||||||
|
!portal/v2/config-overrides.js
|
||||||
|
!portal/v2/tsconfig.json
|
||||||
|
!portal/v2/.eslintrc.yml
|
||||||
|
!portal/v2/.npmrc
|
||||||
|
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -79,9 +79,6 @@ client: generate
|
||||||
ci-rp: fix-macos-vendor
|
ci-rp: fix-macos-vendor
|
||||||
docker build . -f Dockerfile.ci-rp --ulimit=nofile=4096:4096 --build-arg REGISTRY=$(REGISTRY) --build-arg VERSION=$(VERSION) --no-cache=$(NO_CACHE)
|
docker build . -f Dockerfile.ci-rp --ulimit=nofile=4096:4096 --build-arg REGISTRY=$(REGISTRY) --build-arg VERSION=$(VERSION) --no-cache=$(NO_CACHE)
|
||||||
|
|
||||||
ci-portal:
|
|
||||||
docker build . -f Dockerfile.ci-portal --build-arg REGISTRY=$(REGISTRY) --no-cache=$(NO_CACHE)
|
|
||||||
|
|
||||||
# TODO: hard coding dev-config.yaml is clunky; it is also probably convenient to
|
# TODO: hard coding dev-config.yaml is clunky; it is also probably convenient to
|
||||||
# override COMMIT.
|
# override COMMIT.
|
||||||
deploy:
|
deploy:
|
||||||
|
@ -123,7 +120,6 @@ generate-kiota:
|
||||||
|
|
||||||
init-contrib:
|
init-contrib:
|
||||||
install -v hack/git/hooks/* .git/hooks/
|
install -v hack/git/hooks/* .git/hooks/
|
||||||
|
|
||||||
|
|
||||||
image-aro-multistage:
|
image-aro-multistage:
|
||||||
docker build --platform=linux/amd64 --network=host --no-cache -f Dockerfile.aro-multistage -t $(ARO_IMAGE) --build-arg REGISTRY=$(REGISTRY) .
|
docker build --platform=linux/amd64 --network=host --no-cache -f Dockerfile.aro-multistage -t $(ARO_IMAGE) --build-arg REGISTRY=$(REGISTRY) .
|
||||||
|
|
Загрузка…
Ссылка в новой задаче