嗨,伙计们,不知道我在这里做错了什么,但当我上传我的项目Docker图像到弹性豆茎,我得到这个错误:示例部署:Docker容器在启动后意外结束。我是新来的,我不知道为什么会发生这种情况,如果可以的话请帮助。
码头形象
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install --force
COPY . .
ENV APP_PORT 8080
EXPOSE 8080
CMD [ "node", "app.js" ]
.gitlab-ci.yml档案
- build
- run
variables:
APP_NAME: ${CI_PROJECT_NAME}
APP_VERSION: "1.0.0"`enter code here`
S3_BUCKET: "${S3_BUCKET}"
AWS_ID: ${MY_AWS_ID}
AWS_ACCESS_KEY_ID: ${MY_AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${MY_AWS_SECRET_ACCESS_KEY}
AWS_REGION: us-east-1
AWS_PLATFORM: Docker
create_eb_version:
stage: build
image: python:latest
allow_failure: false
script: |
pip install awscli #Install awscli tools
echo "Creating zip file ${APP_NAME}"
python zip.py ${APP_NAME}
echo "Creating AWS Version Label"
AWS_VERSION_LABEL=${APP_NAME}-${APP_VERSION}-${CI_PIPELINE_ID}
S3_KEY="$AWS_VERSION_LABEL.zip"
echo "Uploading to S3"
aws s3 cp ${APP_NAME}.zip s3://${S3_BUCKET}/${S3_KEY} --region ${AWS_REGION}
echo "Creating app version"
aws elasticbeanstalk create-application-version \
--application-name ${APP_NAME} \
--version-label $AWS_VERSION_LABEL \
--region ${AWS_REGION} \
--source-bundle S3Bucket=${S3_BUCKET},S3Key=${S3_KEY} \
--description "${CI_COMMIT_DESCRIPTION}" \
--auto-create-application \
only:
refs:
- main
deploy_aws_eb:
stage: run
image: coxauto/aws-ebcli
when: manual
script: |
AWS_VERSION_LABEL=${APP_NAME}-${APP_VERSION}-${CI_PIPELINE_ID}
echo "Deploying app to tf test"
eb init -i ${APP_NAME} -p ${AWS_PLATFORM} -k ${AWS_ID} --region ${AWS_REGION}
echo "Deploying to enviroment"
eb deploy ${APP_ENVIROMENT_NAME} --version ${AWS_VERSION_LABEL}
echo "done"
only:
refs:
- main
1条答案
按热度按时间lndjwyie1#
我让它工作,我的节点版本在我的docker文件被设置为10,而不是16更改节点版本为16,还取代APP_PORT与PORT,因为这是我命名它