зеркало из https://github.com/Azure/ARO-RP.git
75 строки
2.7 KiB
Docker
75 строки
2.7 KiB
Docker
ARG REGISTRY
|
|
ARG ARO_VERSION
|
|
|
|
###############################################################################
|
|
# Stage 1: Build the SRE Portal Assets
|
|
# builder is responsible for all compilation and validation of the RP
|
|
###############################################################################
|
|
FROM ${REGISTRY}/ubi8/nodejs-16 as portal-build
|
|
LABEL aro-portal-build=true
|
|
WORKDIR /build/portal/v2
|
|
USER root
|
|
|
|
# Copying package files and installing dependencies
|
|
COPY portal/v2/package*.json ./
|
|
RUN npm ci
|
|
RUN npm audit --audit-level high --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
|
|
LABEL stage="portal-build-cache-layer"
|
|
|
|
###############################################################################
|
|
# Stage 2: Compile the Golang RP code
|
|
###############################################################################
|
|
FROM ${REGISTRY}/ubi8/go-toolset:1.21.11-1.1720406008 AS builder
|
|
ARG ARO_VERSION
|
|
LABEL aro-builder=true
|
|
USER root
|
|
WORKDIR /app
|
|
|
|
# golang config and build steps
|
|
ENV GOPATH=/root/go
|
|
ENV GOFLAGS="-tags=containers_image_openpgp,exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper"
|
|
|
|
# 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 && \
|
|
golangci-lint --version || (echo "golangci-lint not found" && exit 1)
|
|
|
|
# Copy dependencies and source files
|
|
COPY go.mod go.sum ./
|
|
COPY vendor vendor
|
|
COPY swagger swagger
|
|
COPY .golangci.yml ./
|
|
COPY hack hack
|
|
COPY cmd cmd
|
|
COPY pkg pkg
|
|
COPY test test
|
|
|
|
# Ensure JS assets are available before generating Go code
|
|
COPY --from=portal-build /build/pkg/portal/assets/v2/build /app/pkg/portal/assets/v2/build
|
|
|
|
# Lint, generate, build, and test
|
|
RUN golangci-lint run --verbose
|
|
RUN go generate ./...
|
|
RUN go build -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=${ARO_VERSION}" ./cmd/aro
|
|
RUN go test ./test/e2e/... -tags e2e,codec.safe -c -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=${ARO_VERSION}" -o e2e.test
|
|
|
|
# Additional tests
|
|
RUN go run gotest.tools/gotestsum@v1.11.0 --format pkgname --junitfile report.xml -- -coverprofile=cover.out ./...
|
|
RUN hack/fips/validate-fips.sh ./aro
|
|
LABEL stage="rp-build-cache-layer"
|
|
|
|
###############################################################################
|
|
# Stage 3: final is our slim image with minimal layers and tools
|
|
###############################################################################
|
|
FROM ${REGISTRY}/ubi8/ubi-minimal AS final
|
|
LABEL aro-final=true
|
|
RUN microdnf update && microdnf clean all
|
|
COPY --from=builder /app/aro /app/e2e.test /usr/local/bin/
|
|
ENTRYPOINT ["aro"]
|
|
EXPOSE 2222/tcp 8080/tcp 8443/tcp 8444/tcp
|
|
USER 1000
|
|
ENV HOME=/tmp
|