gpt4 book ai didi

angular - 在artifactory中存储 Angular dist文件夹

转载 作者:行者123 更新时间:2023-12-02 18:15:14 25 4
gpt4 key购买 nike

我们使用artifactory来提取库并存储artifact。我们将 npm 注册表设置为该 Artifactory url 以下拉库。我们使用 gitlab 作为我们的 CI。我编写了一份使用 ng build --prod 构建 Angular 应用程序的作业。我的问题是将 dist/文件夹推送到神器的最佳实践是什么?在下一步中,我将检索 dist/文件夹并使用 cf Push 将其部署到 Cloud Foundry。我查看了 npm install,但它说它需要 package.json。我要在 dist 文件夹中创建一个吗?如果是的话我该放什么进去?另一个选择似乎是 tar dist/,但这似乎也需要 package.json 。 非常感谢任何想法。

我尝试使用artifactory的REST API和curl与--data-binary推送文件夹,但这仅支持单个文件(如预期)

curl -u $ARTIFACTORY_USER:$ARTIFACTORY_APIKEY --data-binary @$RELEASE_PACKAGE -X PUT $ARTIFACTORY_URL/artifactory/

我希望能够推送整个 dist 文件夹,以便我可以检索并部署它。但是,我不知道最佳实践是什么(推送文件夹是否正确,或者我应该推送 tar.gz)

最佳答案

I was able to zip up the dist directory as tar.gz and push that into artifactory with the rest api and pull it down with curl, unzip and delpoy it.

So only question is around the best practice for an angular app. Do people follow the approach I listed above or is there a better way?

似乎没有官方的最佳实践,只有这样一个过程的轶事证据。

but can we grab all the generated files and put them inside the zip file. Therefore, we have to build the app, locate the project dist folder and compress its content to a zip file.

stage: deployscript:
# Installing zip / unzip in order to zip the artifact before uploading it.
- apk add curl zip
# Create artifactName and remove version-file as it is supposed to only be used during the build
- artifactName=${ARTIFACT_NAME_TEMPLATE/<VERSION>/$(cat $CI_PROJECT_DIR/$SUB_PATH/version)}
- rm $CI_PROJECT_DIR/$SUB_PATH/version
# Zip artifact (note: we are using relative paths; otherwise the ZIP will include all parent folders)
- cd $CI_PROJECT_DIR/$SUB_PATH
- zip -9 -r ${artifactName} ./dist
# Upload to Sonatype Nexus
- curl -v -u $SONAR_CI_USER:$SONAR_CI_PASSWORD --upload-file $CI_PROJECT_DIR/$SUB_PATH/${artifactName} $NEXUS_URL/

交付(在本例中为 Docker)是:

build_image:
script:
# Install curl and unzip in order to download and unzip artifact
- apk add curl unzip

# Download artifact
- curl $ARTIFACT_ON_NEXUS --output $CI_PROJECT_DIR/$OUTPUT_FILE

# Unzip artifact
- unzip $CI_PROJECT_DIR/$OUTPUT_FILE -d $CI_PROJECT_DIR/frontend/
- docker build -t particles-front-frontend-nginx:$VERSION_TO_PUBLISH .

artifacts:
expire_in: 1 hour
paths:
- $CI_PROJECT_DIR

所以总体思路仍然是:将 dist 存储为 zip,将其卷回部署环境。

关于angular - 在artifactory中存储 Angular dist文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56820596/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com