网络科技有限公司:四、浪潮云服务器自动化部署验证
在本次的项目实施中,我们采用了Jenkins进行自动化部署,确保了应用程序的快速和高效地发布。以下是我们在Jenkins上配置的脚本:
首先,我们进入了工作空间目录 /home/jenkins/workspace/lease-java1,然后删除了 dist 和 app 目录,以便清理之前的构建文件。
cd /home/jenkins/workspace/lease-java1
rm -rf dist
rm -rf app
接下来,我们切换到了 /home/jenkins/workspace/lease-vue1 目录,并复制了一份 dist 文件夹到 /home/jenkins/workspace/lease-java1/dist 中。
cd /home/jenkins/workspace/lease-vue1
cp -r dist /home/jenkins/workspace/lease-java1/dist
接着,我们进入了 /home/jenkins/workspace/lease-app1/dist/build/h5 目录,并将其复制到 /home/jenkins/workspace/lease-java1/app 中。
cd /home/jenkins/workspace/lease-app1/dist/build/h5
cp -r h5 /home/j Jenkins/ws okspace/app/
然后,我们切换到了 /root/tomcat/logs/target/zsy- lease.war 的位置并将其复制到同级别的 zsy- lease.war 位置`.
cd /root/tomcat/logs/target/
cp zsy- lease.war zsy-
随后,我们使用Docker命令来创建一个名为 `zsy- lease.zyj.com:6600 服务.
FROM openjdk:8-jdk-alpine
COPY target/zsy-*.war $CATALINA_HOME/webapps/root.war
CMD ["catalina.sh", "run"]
EXPOSE 8080
RUN apk add --no-cache curl && rm -rf /tmp/* && rm -rf /*.a* && rm -rf /*.sw* && rm -vf /
VOLUME ["/usr/local/tomcat/conf", "/usr/local/tomcat/data"]
ENV CATALINA_HOME=/usr/local/tomcat
# COPY . $CATALINA_HOME/webapps/
WORKDIR $CATALINA_HOME/webapps
ENTRYPOINT ["sh","catalina.sh","start"]
CMD ["catalina.sh","start"]
USER root
LABEL maintainer="Tom Zhang"
LABEL version="v2"
LABEL build-date="20230202T060000Z"
buildah push zyj.com:6600 zyj.com:6600:v2 | tee >(awk '{print strftime("%Y-%m-%d %H:%M:%S", systime()) ": " $0}' | grep 'manifest' | cut '-d'"'"' "'f" 'x')
buildah tag golang-webapp-container:v2 golang-webapp-container:v2
buildah commit --change='USER root' --change='USER root'
buildah run --name=zsj-com-golang-webapp-container-zsytbpmwqgqw \
--detach=true \
--publish=80 \
--volume="/etc/timezone:/etc/timezone" \
--volume="/etc/localtime:/etc/localtime" \
zyj-com/golang-webapp-container-zsytbpmwqgqw:golang-webapp-container-zsytbpmwqgqw
docker stop zsj-com-golang-webapp-container-zsytbpmwqgqw
docker rm zsj-com-golang-web
docker run --name=zsj-com-golangwebcontainer-test-run-d-p66001:
Build and start a container with the specified name and image.
The command to start the container is passed as an argument.
The command to stop the container is passed as an argument.
The command to remove the container is passed as an argument.
docker ps
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL (with errors)
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:3.2.0:test (default-cli) on project parent:
Failed to clean project:
Failed to delete file:C:\Users\Tom\.jenkins\workspace\leaserepo\target\classes\
C:\Users\Tom\.jenkins\workspace\[ERROR]
Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.3.0:test-resources (default-cli) on project parent:
File D:\tomcatserver\target/classes/resources not found in workspace C:\Users\Tom\.jenkins\workspace\[ERROR]
Failed t