-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce release docker image size (#19)
* feat: use multi-stage docker build and node slim as final docker base to reduce the docker image size * feat: add a dockerfile with alpine base * chore: remove all auto generated files * fix: add make generate to ci/cd flow * feat: use alpine as the final base image
- Loading branch information
Showing
471 changed files
with
106 additions
and
75,143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
From 5dcdc9a0e93a05efe3cf0eb3fae7669bf0975354 Mon Sep 17 00:00:00 2001 | ||
From: Hongjian Fan <[email protected]> | ||
Date: Tue, 9 Jul 2024 15:28:25 -0500 | ||
Subject: [PATCH] fix missing import | ||
|
||
--- | ||
pkg/redfishapi/model_resource_status_conditions_inner.go | 2 ++ | ||
1 file changed, 2 insertions(+) | ||
|
||
diff --git a/pkg/redfishapi/model_resource_status_conditions_inner.go b/pkg/redfishapi/model_resource_status_conditions_inner.go | ||
index 94ba4c9..a543d69 100644 | ||
--- a/pkg/redfishapi/model_resource_status_conditions_inner.go | ||
+++ b/pkg/redfishapi/model_resource_status_conditions_inner.go | ||
@@ -8,6 +8,8 @@ | ||
|
||
package redfishapi | ||
|
||
+import "time" | ||
+ | ||
type ResourceStatusConditionsInner struct { | ||
LogEntry OdataV4IdRef `json:"LogEntry,omitempty"` | ||
|
||
-- | ||
2.25.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,75 @@ | ||
FROM golang:1.22.1 | ||
FROM openapitools/openapi-generator-cli:v7.0.0 AS api-gen | ||
|
||
LABEL org.opencontainers.image.source https://github.com/seagate/cfm | ||
|
||
RUN apt update | ||
RUN apt install -y nodejs npm | ||
ENV OPENAPI_YAML=api/cfm-openapi.yaml | ||
ENV OPENAPI_REDFISH_YAML=api/redfish-openapi.yaml | ||
ENV BASEPATH=/cfm | ||
|
||
# Copy whole repo into the image | ||
COPY . /cfm | ||
COPY . ${BASEPATH} | ||
|
||
# Validating ${OPENAPI_YAML} using openapi-generator-cli | ||
RUN docker-entrypoint.sh validate -i ${BASEPATH}/${OPENAPI_YAML} | ||
RUN docker-entrypoint.sh validate -i ${BASEPATH}/${OPENAPI_REDFISH_YAML} | ||
|
||
# Generating ${OPENAPI_YAML} go server using openapi-generator-cli | ||
RUN docker-entrypoint.sh generate -i ${BASEPATH}/${OPENAPI_YAML} -g go-server -o ${BASEPATH}/pkg/openapi --additional-properties=sourceFolder=,outputAsLibrary=true,router=mux,serverPort=8080,enumClassPrefix=true -t ${BASEPATH}/api/templates/go-server --skip-validate-spec | ||
|
||
# Generating ${OPENAPI_YAML} go client using openapi-generator-cli | ||
RUN docker-entrypoint.sh generate -i ${BASEPATH}/${OPENAPI_YAML} -g go -o ${BASEPATH}/pkg/client -p isGoSubmodule=true,withGoMod=false --package-name client --ignore-file-override ${BASEPATH}/api/ignore/.openapi-generator-ignore-client -t ${BASEPATH}/api/templates/go | ||
|
||
# workaround for withGoMod=false not functioning with openapi-generator | ||
RUN rm ${BASEPATH}/pkg/client/go.mod | ||
RUN rm ${BASEPATH}/pkg/client/go.sum | ||
|
||
# Generating ${OPENAPI_YAML} redfish server using openapi-generator-cli | ||
RUN docker-entrypoint.sh generate -i ${BASEPATH}/${OPENAPI_REDFISH_YAML} -g go-server -o ${BASEPATH}/pkg/redfishapi --package-name redfishapi --additional-properties=sourceFolder=,outputAsLibrary=true,router=mux,serverPort=8080,enumClassPrefix=true -t ${BASEPATH}/api/templates/go-server --skip-validate-spec | ||
|
||
# Generating ${OPENAPI_YAML} axios server using openapi-generator-cli | ||
RUN docker-entrypoint.sh generate -i ${BASEPATH}/${OPENAPI_YAML} -g typescript-axios -o ${BASEPATH}/webui/src/axios --skip-validate-spec | ||
|
||
|
||
FROM golang:1.22.1-alpine AS go | ||
ENV BASEPATH=/cfm | ||
|
||
RUN apk add git make | ||
# copy source code with generated files to go image | ||
COPY --from=api-gen ${BASEPATH} ${BASEPATH} | ||
|
||
WORKDIR ${BASEPATH} | ||
|
||
# Format files to conform to project standard | ||
RUN gofmt -w ${BASEPATH} | ||
|
||
# apply local patch for xml response fix | ||
RUN git apply api/patch/Apply-xml-workaround-to-fix-metadata-response.patch | ||
RUN git apply api/patch/fix-missing-import.patch | ||
|
||
# build the excutable | ||
RUN make build-go | ||
|
||
FROM node:alpine as npm | ||
ENV BASEPATH=/cfm | ||
|
||
# copy source code with generated files to go image | ||
COPY --from=go ${BASEPATH}/webui ${BASEPATH}/webui | ||
|
||
# setup web UI and build the dist package | ||
WORKDIR /cfm/webui | ||
WORKDIR ${BASEPATH}/webui | ||
RUN npm install | ||
RUN npm run build | ||
|
||
# Build CFM SERVICE & CLI | ||
WORKDIR /cfm | ||
RUN rm cfmdatastore.json | ||
RUN ln -s /local/cfmdatastore.json cfmdatastore.json | ||
RUN make build-go | ||
FROM alpine:latest | ||
ENV BASEPATH=/cfm | ||
|
||
# copy source code with generated files to go image | ||
COPY --from=go ${BASEPATH}/cfm-service ${BASEPATH}/cfm-service | ||
COPY --from=go ${BASEPATH}/cfm-cli ${BASEPATH}/cfm-cli | ||
COPY --from=npm ${BASEPATH}/webui/dist ${BASEPATH}/webui/dist | ||
|
||
RUN ln -s /local/cfmdatastore.json ${BASEPATH}/cfmdatastore.json | ||
|
||
LABEL org.opencontainers.image.source https://github.com/seagate/cfm | ||
|
||
WORKDIR ${BASEPATH} | ||
# Start the service | ||
ENTRYPOINT [ "/cfm/cfm-service" ] | ||
ENTRYPOINT [ "/cfm/cfm-service" ] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.