How to deploy war file on Tomcat installed in compute engine instance
I need to deploy my spring-boot application on compute engine in Google cloud platform. I have already created an instance and through SSH Apache and Maven have been installed. Further, war file has been uploaded into the bucket. Anybody can provide me with the remaining commands to deploy the war file on tomcat instance.
Thanks
maven spring-boot google-cloud-platform google-compute-engine
|
show 2 more comments
I need to deploy my spring-boot application on compute engine in Google cloud platform. I have already created an instance and through SSH Apache and Maven have been installed. Further, war file has been uploaded into the bucket. Anybody can provide me with the remaining commands to deploy the war file on tomcat instance.
Thanks
maven spring-boot google-cloud-platform google-compute-engine
Is this just a proof of concept or Do you need a basic devops/automation flow?
– JRichardsz
Dec 27 at 20:13
@JRichardsz Actually, I need a basic develops. I searched everywhere but I cannot find any resources to deploy war file on tomcat which installed in compute engine instance.I have already copied my war file into instance. Can you please let me know which commands that need for deployment?
– chk.buddi
Dec 28 at 0:32
Don't worry, I will help you. In the meantime, some questions. Are you in the ability to acquire instances? Basic environments for enterprise consists on 4 instances : dev, testing, production and the last one for continuous integration. Or do you need something more light like a startup or demo? Are you using git?
– JRichardsz
Dec 28 at 1:12
@JRichardsz Thank you for your help. Actually, this is a demo website. Yes, I have used git.This is the git url.
– chk.buddi
Dec 28 at 1:38
github.com/ChkBuk/myexamples/tree/master/SyneBiz
– chk.buddi
Dec 28 at 1:39
|
show 2 more comments
I need to deploy my spring-boot application on compute engine in Google cloud platform. I have already created an instance and through SSH Apache and Maven have been installed. Further, war file has been uploaded into the bucket. Anybody can provide me with the remaining commands to deploy the war file on tomcat instance.
Thanks
maven spring-boot google-cloud-platform google-compute-engine
I need to deploy my spring-boot application on compute engine in Google cloud platform. I have already created an instance and through SSH Apache and Maven have been installed. Further, war file has been uploaded into the bucket. Anybody can provide me with the remaining commands to deploy the war file on tomcat instance.
Thanks
maven spring-boot google-cloud-platform google-compute-engine
maven spring-boot google-cloud-platform google-compute-engine
asked Dec 27 at 14:34
chk.buddi
7710
7710
Is this just a proof of concept or Do you need a basic devops/automation flow?
– JRichardsz
Dec 27 at 20:13
@JRichardsz Actually, I need a basic develops. I searched everywhere but I cannot find any resources to deploy war file on tomcat which installed in compute engine instance.I have already copied my war file into instance. Can you please let me know which commands that need for deployment?
– chk.buddi
Dec 28 at 0:32
Don't worry, I will help you. In the meantime, some questions. Are you in the ability to acquire instances? Basic environments for enterprise consists on 4 instances : dev, testing, production and the last one for continuous integration. Or do you need something more light like a startup or demo? Are you using git?
– JRichardsz
Dec 28 at 1:12
@JRichardsz Thank you for your help. Actually, this is a demo website. Yes, I have used git.This is the git url.
– chk.buddi
Dec 28 at 1:38
github.com/ChkBuk/myexamples/tree/master/SyneBiz
– chk.buddi
Dec 28 at 1:39
|
show 2 more comments
Is this just a proof of concept or Do you need a basic devops/automation flow?
– JRichardsz
Dec 27 at 20:13
@JRichardsz Actually, I need a basic develops. I searched everywhere but I cannot find any resources to deploy war file on tomcat which installed in compute engine instance.I have already copied my war file into instance. Can you please let me know which commands that need for deployment?
– chk.buddi
Dec 28 at 0:32
Don't worry, I will help you. In the meantime, some questions. Are you in the ability to acquire instances? Basic environments for enterprise consists on 4 instances : dev, testing, production and the last one for continuous integration. Or do you need something more light like a startup or demo? Are you using git?
– JRichardsz
Dec 28 at 1:12
@JRichardsz Thank you for your help. Actually, this is a demo website. Yes, I have used git.This is the git url.
– chk.buddi
Dec 28 at 1:38
github.com/ChkBuk/myexamples/tree/master/SyneBiz
– chk.buddi
Dec 28 at 1:39
Is this just a proof of concept or Do you need a basic devops/automation flow?
– JRichardsz
Dec 27 at 20:13
Is this just a proof of concept or Do you need a basic devops/automation flow?
– JRichardsz
Dec 27 at 20:13
@JRichardsz Actually, I need a basic develops. I searched everywhere but I cannot find any resources to deploy war file on tomcat which installed in compute engine instance.I have already copied my war file into instance. Can you please let me know which commands that need for deployment?
– chk.buddi
Dec 28 at 0:32
@JRichardsz Actually, I need a basic develops. I searched everywhere but I cannot find any resources to deploy war file on tomcat which installed in compute engine instance.I have already copied my war file into instance. Can you please let me know which commands that need for deployment?
– chk.buddi
Dec 28 at 0:32
Don't worry, I will help you. In the meantime, some questions. Are you in the ability to acquire instances? Basic environments for enterprise consists on 4 instances : dev, testing, production and the last one for continuous integration. Or do you need something more light like a startup or demo? Are you using git?
– JRichardsz
Dec 28 at 1:12
Don't worry, I will help you. In the meantime, some questions. Are you in the ability to acquire instances? Basic environments for enterprise consists on 4 instances : dev, testing, production and the last one for continuous integration. Or do you need something more light like a startup or demo? Are you using git?
– JRichardsz
Dec 28 at 1:12
@JRichardsz Thank you for your help. Actually, this is a demo website. Yes, I have used git.This is the git url.
– chk.buddi
Dec 28 at 1:38
@JRichardsz Thank you for your help. Actually, this is a demo website. Yes, I have used git.This is the git url.
– chk.buddi
Dec 28 at 1:38
github.com/ChkBuk/myexamples/tree/master/SyneBiz
– chk.buddi
Dec 28 at 1:39
github.com/ChkBuk/myexamples/tree/master/SyneBiz
– chk.buddi
Dec 28 at 1:39
|
show 2 more comments
1 Answer
1
active
oldest
votes
Deploy in compute engine instance of google not substantially different from AWS, Azure or another linux host provider.
You just need an ssh connection to the remote machine and install the required software to compile, build, zip, deploy, etc
I will list some approaches from basic(manually) to advanced(automated):
#1 Bash scripting
- unzip and configure git
- unzip and configure java
- unzip and configure maven
- unzip and configure tomcat (this is not required if spring-boot is used)
- configure the linux host to open 8080 port
- create a script called /devops/pipeline.sh
For war deployment :
# get the source code
cd /tmp/folder/3dac58b7
git clone http://github.com/myrepo.git .
# create war
mvn clean package
# move war to deploy tomcat folder
cp target/my_app.war /my/tomcat/webapps
# stop tomcat
bash /my/tomcat/shutdown.sh
# start tomcat
bash /my/tomcat/startup.sh
Or spring-boot startup
# get the source code
cd /tmp/folder/3dac58b7
git clone http://github.com/myrepo.git .
# create jar
mvn clean package
# kill or stop the application
killall java
# start the application
java $JAVA_OPTS -jar $jar_file_name
- After push to git, just connect to you instance using ssh and execute
bash /devops/pipeline.sh
Improvements: Parametrize repository name, branch name, mvn profile, database credentials, create a tmp/uuid folder in every execution, delete the tmp/uuid after deploy,optimize start and stop of application using pid, etc
#2 Docker
- Install docker in your instance
- Create a docker container with name my-container-name containing all the steps of approach #1
- After push to git, just connect to you instance using ssh and execute:
docker rm my_app -f
docker run -d --name my_app -p 8080:8080 my-container-name
#3 Artifact Repository (an extra instance is required)
Configure Nexus or JFrog Artifactory in the new instance.
Point your maven settings in your development machine to the url provided by the configured Artifact Repository.
Modify the script of #1 or Dockerfile of #2 to :
- avoid git installation
- avoid git clone
- avoid mvn clean package (This is not required any more because, the war file will be created in the development machine)
- download war or jar file from Artifact Repository
Use approaches #1 or #2
When your are ready to deploy , push to git, and execute this in your development machine:
# This will generate the war file and upload to the Artifact Repository.
mvn clean install
#4 Use a continuous integration server (an extra instance is required)
- Install Jenkins in the new instance
- Configure plugins and other required things in jenkins in order to enable webhook url : https://jrichardsz.github.io/devops/configure-webhooks-in-github-bitbucket-gitlab
- Create a job in jenkins to call the script of approach #1 or execute docker commands of approach #2. If you can, Approach #3 would be perfect.
- Configure your SCM (github, bitbucket, gitlab, etc) to point to the webhook url published by Jenkins.
When you are ready to deploy, just push the code to your scm, jenkins will be notified and will execute the previous created job. As you can see, there is no human required to deploy de application in the server(With the exception of developer push)
#5 Advanced (Sysadmin team or extra people and knowledge are required )
- Kubernetes
- Ansible
- High availability / Load balancer
- Backups
- Configurations Management
- And more automations
This will be necessary when more and more web applications, microservices are required in your company/enterprise.
#6 Saas
All the previous approaches could be simplified using WORLD CLASS platforms like:
Jelastic
- Heroku
- Openshift, etc
Many thanks. I will try these ways and let you know the status. Thank you once again.
– chk.buddi
Dec 28 at 17:11
@chk.buddi if this helped to solve your problem, please use the checkmark on the left to mark this as solved :D. Also don't forget to contact me if your have troubleshootings in one of the approaches or steps
– JRichardsz
Dec 28 at 17:17
Sure, once I solve the issue I will mark as the solution. Thank you
– chk.buddi
Dec 28 at 17:21
@JRichardz I tried the #1 method. Now, I'm getting a different issue. My app runs fine when I run as 'Spring boot App' on eclipse but when I run on Tomcat, index page is not displaying.For this app, client app is react based and I have built the client project and copied into the static folder of the main project.Any suggestion?
– chk.buddi
2 days ago
If your app is an spring-boot, you don't need tomcat. Tomcat is mandatory in your requirement? Related to your architecture, I recommend to decouple web client app to the api rest. You can host your app in a separate instance with apache, nginx, nodejs, etc
– JRichardsz
2 days ago
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53946704%2fhow-to-deploy-war-file-on-tomcat-installed-in-compute-engine-instance%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Deploy in compute engine instance of google not substantially different from AWS, Azure or another linux host provider.
You just need an ssh connection to the remote machine and install the required software to compile, build, zip, deploy, etc
I will list some approaches from basic(manually) to advanced(automated):
#1 Bash scripting
- unzip and configure git
- unzip and configure java
- unzip and configure maven
- unzip and configure tomcat (this is not required if spring-boot is used)
- configure the linux host to open 8080 port
- create a script called /devops/pipeline.sh
For war deployment :
# get the source code
cd /tmp/folder/3dac58b7
git clone http://github.com/myrepo.git .
# create war
mvn clean package
# move war to deploy tomcat folder
cp target/my_app.war /my/tomcat/webapps
# stop tomcat
bash /my/tomcat/shutdown.sh
# start tomcat
bash /my/tomcat/startup.sh
Or spring-boot startup
# get the source code
cd /tmp/folder/3dac58b7
git clone http://github.com/myrepo.git .
# create jar
mvn clean package
# kill or stop the application
killall java
# start the application
java $JAVA_OPTS -jar $jar_file_name
- After push to git, just connect to you instance using ssh and execute
bash /devops/pipeline.sh
Improvements: Parametrize repository name, branch name, mvn profile, database credentials, create a tmp/uuid folder in every execution, delete the tmp/uuid after deploy,optimize start and stop of application using pid, etc
#2 Docker
- Install docker in your instance
- Create a docker container with name my-container-name containing all the steps of approach #1
- After push to git, just connect to you instance using ssh and execute:
docker rm my_app -f
docker run -d --name my_app -p 8080:8080 my-container-name
#3 Artifact Repository (an extra instance is required)
Configure Nexus or JFrog Artifactory in the new instance.
Point your maven settings in your development machine to the url provided by the configured Artifact Repository.
Modify the script of #1 or Dockerfile of #2 to :
- avoid git installation
- avoid git clone
- avoid mvn clean package (This is not required any more because, the war file will be created in the development machine)
- download war or jar file from Artifact Repository
Use approaches #1 or #2
When your are ready to deploy , push to git, and execute this in your development machine:
# This will generate the war file and upload to the Artifact Repository.
mvn clean install
#4 Use a continuous integration server (an extra instance is required)
- Install Jenkins in the new instance
- Configure plugins and other required things in jenkins in order to enable webhook url : https://jrichardsz.github.io/devops/configure-webhooks-in-github-bitbucket-gitlab
- Create a job in jenkins to call the script of approach #1 or execute docker commands of approach #2. If you can, Approach #3 would be perfect.
- Configure your SCM (github, bitbucket, gitlab, etc) to point to the webhook url published by Jenkins.
When you are ready to deploy, just push the code to your scm, jenkins will be notified and will execute the previous created job. As you can see, there is no human required to deploy de application in the server(With the exception of developer push)
#5 Advanced (Sysadmin team or extra people and knowledge are required )
- Kubernetes
- Ansible
- High availability / Load balancer
- Backups
- Configurations Management
- And more automations
This will be necessary when more and more web applications, microservices are required in your company/enterprise.
#6 Saas
All the previous approaches could be simplified using WORLD CLASS platforms like:
Jelastic
- Heroku
- Openshift, etc
Many thanks. I will try these ways and let you know the status. Thank you once again.
– chk.buddi
Dec 28 at 17:11
@chk.buddi if this helped to solve your problem, please use the checkmark on the left to mark this as solved :D. Also don't forget to contact me if your have troubleshootings in one of the approaches or steps
– JRichardsz
Dec 28 at 17:17
Sure, once I solve the issue I will mark as the solution. Thank you
– chk.buddi
Dec 28 at 17:21
@JRichardz I tried the #1 method. Now, I'm getting a different issue. My app runs fine when I run as 'Spring boot App' on eclipse but when I run on Tomcat, index page is not displaying.For this app, client app is react based and I have built the client project and copied into the static folder of the main project.Any suggestion?
– chk.buddi
2 days ago
If your app is an spring-boot, you don't need tomcat. Tomcat is mandatory in your requirement? Related to your architecture, I recommend to decouple web client app to the api rest. You can host your app in a separate instance with apache, nginx, nodejs, etc
– JRichardsz
2 days ago
|
show 2 more comments
Deploy in compute engine instance of google not substantially different from AWS, Azure or another linux host provider.
You just need an ssh connection to the remote machine and install the required software to compile, build, zip, deploy, etc
I will list some approaches from basic(manually) to advanced(automated):
#1 Bash scripting
- unzip and configure git
- unzip and configure java
- unzip and configure maven
- unzip and configure tomcat (this is not required if spring-boot is used)
- configure the linux host to open 8080 port
- create a script called /devops/pipeline.sh
For war deployment :
# get the source code
cd /tmp/folder/3dac58b7
git clone http://github.com/myrepo.git .
# create war
mvn clean package
# move war to deploy tomcat folder
cp target/my_app.war /my/tomcat/webapps
# stop tomcat
bash /my/tomcat/shutdown.sh
# start tomcat
bash /my/tomcat/startup.sh
Or spring-boot startup
# get the source code
cd /tmp/folder/3dac58b7
git clone http://github.com/myrepo.git .
# create jar
mvn clean package
# kill or stop the application
killall java
# start the application
java $JAVA_OPTS -jar $jar_file_name
- After push to git, just connect to you instance using ssh and execute
bash /devops/pipeline.sh
Improvements: Parametrize repository name, branch name, mvn profile, database credentials, create a tmp/uuid folder in every execution, delete the tmp/uuid after deploy,optimize start and stop of application using pid, etc
#2 Docker
- Install docker in your instance
- Create a docker container with name my-container-name containing all the steps of approach #1
- After push to git, just connect to you instance using ssh and execute:
docker rm my_app -f
docker run -d --name my_app -p 8080:8080 my-container-name
#3 Artifact Repository (an extra instance is required)
Configure Nexus or JFrog Artifactory in the new instance.
Point your maven settings in your development machine to the url provided by the configured Artifact Repository.
Modify the script of #1 or Dockerfile of #2 to :
- avoid git installation
- avoid git clone
- avoid mvn clean package (This is not required any more because, the war file will be created in the development machine)
- download war or jar file from Artifact Repository
Use approaches #1 or #2
When your are ready to deploy , push to git, and execute this in your development machine:
# This will generate the war file and upload to the Artifact Repository.
mvn clean install
#4 Use a continuous integration server (an extra instance is required)
- Install Jenkins in the new instance
- Configure plugins and other required things in jenkins in order to enable webhook url : https://jrichardsz.github.io/devops/configure-webhooks-in-github-bitbucket-gitlab
- Create a job in jenkins to call the script of approach #1 or execute docker commands of approach #2. If you can, Approach #3 would be perfect.
- Configure your SCM (github, bitbucket, gitlab, etc) to point to the webhook url published by Jenkins.
When you are ready to deploy, just push the code to your scm, jenkins will be notified and will execute the previous created job. As you can see, there is no human required to deploy de application in the server(With the exception of developer push)
#5 Advanced (Sysadmin team or extra people and knowledge are required )
- Kubernetes
- Ansible
- High availability / Load balancer
- Backups
- Configurations Management
- And more automations
This will be necessary when more and more web applications, microservices are required in your company/enterprise.
#6 Saas
All the previous approaches could be simplified using WORLD CLASS platforms like:
Jelastic
- Heroku
- Openshift, etc
Many thanks. I will try these ways and let you know the status. Thank you once again.
– chk.buddi
Dec 28 at 17:11
@chk.buddi if this helped to solve your problem, please use the checkmark on the left to mark this as solved :D. Also don't forget to contact me if your have troubleshootings in one of the approaches or steps
– JRichardsz
Dec 28 at 17:17
Sure, once I solve the issue I will mark as the solution. Thank you
– chk.buddi
Dec 28 at 17:21
@JRichardz I tried the #1 method. Now, I'm getting a different issue. My app runs fine when I run as 'Spring boot App' on eclipse but when I run on Tomcat, index page is not displaying.For this app, client app is react based and I have built the client project and copied into the static folder of the main project.Any suggestion?
– chk.buddi
2 days ago
If your app is an spring-boot, you don't need tomcat. Tomcat is mandatory in your requirement? Related to your architecture, I recommend to decouple web client app to the api rest. You can host your app in a separate instance with apache, nginx, nodejs, etc
– JRichardsz
2 days ago
|
show 2 more comments
Deploy in compute engine instance of google not substantially different from AWS, Azure or another linux host provider.
You just need an ssh connection to the remote machine and install the required software to compile, build, zip, deploy, etc
I will list some approaches from basic(manually) to advanced(automated):
#1 Bash scripting
- unzip and configure git
- unzip and configure java
- unzip and configure maven
- unzip and configure tomcat (this is not required if spring-boot is used)
- configure the linux host to open 8080 port
- create a script called /devops/pipeline.sh
For war deployment :
# get the source code
cd /tmp/folder/3dac58b7
git clone http://github.com/myrepo.git .
# create war
mvn clean package
# move war to deploy tomcat folder
cp target/my_app.war /my/tomcat/webapps
# stop tomcat
bash /my/tomcat/shutdown.sh
# start tomcat
bash /my/tomcat/startup.sh
Or spring-boot startup
# get the source code
cd /tmp/folder/3dac58b7
git clone http://github.com/myrepo.git .
# create jar
mvn clean package
# kill or stop the application
killall java
# start the application
java $JAVA_OPTS -jar $jar_file_name
- After push to git, just connect to you instance using ssh and execute
bash /devops/pipeline.sh
Improvements: Parametrize repository name, branch name, mvn profile, database credentials, create a tmp/uuid folder in every execution, delete the tmp/uuid after deploy,optimize start and stop of application using pid, etc
#2 Docker
- Install docker in your instance
- Create a docker container with name my-container-name containing all the steps of approach #1
- After push to git, just connect to you instance using ssh and execute:
docker rm my_app -f
docker run -d --name my_app -p 8080:8080 my-container-name
#3 Artifact Repository (an extra instance is required)
Configure Nexus or JFrog Artifactory in the new instance.
Point your maven settings in your development machine to the url provided by the configured Artifact Repository.
Modify the script of #1 or Dockerfile of #2 to :
- avoid git installation
- avoid git clone
- avoid mvn clean package (This is not required any more because, the war file will be created in the development machine)
- download war or jar file from Artifact Repository
Use approaches #1 or #2
When your are ready to deploy , push to git, and execute this in your development machine:
# This will generate the war file and upload to the Artifact Repository.
mvn clean install
#4 Use a continuous integration server (an extra instance is required)
- Install Jenkins in the new instance
- Configure plugins and other required things in jenkins in order to enable webhook url : https://jrichardsz.github.io/devops/configure-webhooks-in-github-bitbucket-gitlab
- Create a job in jenkins to call the script of approach #1 or execute docker commands of approach #2. If you can, Approach #3 would be perfect.
- Configure your SCM (github, bitbucket, gitlab, etc) to point to the webhook url published by Jenkins.
When you are ready to deploy, just push the code to your scm, jenkins will be notified and will execute the previous created job. As you can see, there is no human required to deploy de application in the server(With the exception of developer push)
#5 Advanced (Sysadmin team or extra people and knowledge are required )
- Kubernetes
- Ansible
- High availability / Load balancer
- Backups
- Configurations Management
- And more automations
This will be necessary when more and more web applications, microservices are required in your company/enterprise.
#6 Saas
All the previous approaches could be simplified using WORLD CLASS platforms like:
Jelastic
- Heroku
- Openshift, etc
Deploy in compute engine instance of google not substantially different from AWS, Azure or another linux host provider.
You just need an ssh connection to the remote machine and install the required software to compile, build, zip, deploy, etc
I will list some approaches from basic(manually) to advanced(automated):
#1 Bash scripting
- unzip and configure git
- unzip and configure java
- unzip and configure maven
- unzip and configure tomcat (this is not required if spring-boot is used)
- configure the linux host to open 8080 port
- create a script called /devops/pipeline.sh
For war deployment :
# get the source code
cd /tmp/folder/3dac58b7
git clone http://github.com/myrepo.git .
# create war
mvn clean package
# move war to deploy tomcat folder
cp target/my_app.war /my/tomcat/webapps
# stop tomcat
bash /my/tomcat/shutdown.sh
# start tomcat
bash /my/tomcat/startup.sh
Or spring-boot startup
# get the source code
cd /tmp/folder/3dac58b7
git clone http://github.com/myrepo.git .
# create jar
mvn clean package
# kill or stop the application
killall java
# start the application
java $JAVA_OPTS -jar $jar_file_name
- After push to git, just connect to you instance using ssh and execute
bash /devops/pipeline.sh
Improvements: Parametrize repository name, branch name, mvn profile, database credentials, create a tmp/uuid folder in every execution, delete the tmp/uuid after deploy,optimize start and stop of application using pid, etc
#2 Docker
- Install docker in your instance
- Create a docker container with name my-container-name containing all the steps of approach #1
- After push to git, just connect to you instance using ssh and execute:
docker rm my_app -f
docker run -d --name my_app -p 8080:8080 my-container-name
#3 Artifact Repository (an extra instance is required)
Configure Nexus or JFrog Artifactory in the new instance.
Point your maven settings in your development machine to the url provided by the configured Artifact Repository.
Modify the script of #1 or Dockerfile of #2 to :
- avoid git installation
- avoid git clone
- avoid mvn clean package (This is not required any more because, the war file will be created in the development machine)
- download war or jar file from Artifact Repository
Use approaches #1 or #2
When your are ready to deploy , push to git, and execute this in your development machine:
# This will generate the war file and upload to the Artifact Repository.
mvn clean install
#4 Use a continuous integration server (an extra instance is required)
- Install Jenkins in the new instance
- Configure plugins and other required things in jenkins in order to enable webhook url : https://jrichardsz.github.io/devops/configure-webhooks-in-github-bitbucket-gitlab
- Create a job in jenkins to call the script of approach #1 or execute docker commands of approach #2. If you can, Approach #3 would be perfect.
- Configure your SCM (github, bitbucket, gitlab, etc) to point to the webhook url published by Jenkins.
When you are ready to deploy, just push the code to your scm, jenkins will be notified and will execute the previous created job. As you can see, there is no human required to deploy de application in the server(With the exception of developer push)
#5 Advanced (Sysadmin team or extra people and knowledge are required )
- Kubernetes
- Ansible
- High availability / Load balancer
- Backups
- Configurations Management
- And more automations
This will be necessary when more and more web applications, microservices are required in your company/enterprise.
#6 Saas
All the previous approaches could be simplified using WORLD CLASS platforms like:
Jelastic
- Heroku
- Openshift, etc
edited Dec 28 at 17:14
answered Dec 28 at 17:06
JRichardsz
1,6161239
1,6161239
Many thanks. I will try these ways and let you know the status. Thank you once again.
– chk.buddi
Dec 28 at 17:11
@chk.buddi if this helped to solve your problem, please use the checkmark on the left to mark this as solved :D. Also don't forget to contact me if your have troubleshootings in one of the approaches or steps
– JRichardsz
Dec 28 at 17:17
Sure, once I solve the issue I will mark as the solution. Thank you
– chk.buddi
Dec 28 at 17:21
@JRichardz I tried the #1 method. Now, I'm getting a different issue. My app runs fine when I run as 'Spring boot App' on eclipse but when I run on Tomcat, index page is not displaying.For this app, client app is react based and I have built the client project and copied into the static folder of the main project.Any suggestion?
– chk.buddi
2 days ago
If your app is an spring-boot, you don't need tomcat. Tomcat is mandatory in your requirement? Related to your architecture, I recommend to decouple web client app to the api rest. You can host your app in a separate instance with apache, nginx, nodejs, etc
– JRichardsz
2 days ago
|
show 2 more comments
Many thanks. I will try these ways and let you know the status. Thank you once again.
– chk.buddi
Dec 28 at 17:11
@chk.buddi if this helped to solve your problem, please use the checkmark on the left to mark this as solved :D. Also don't forget to contact me if your have troubleshootings in one of the approaches or steps
– JRichardsz
Dec 28 at 17:17
Sure, once I solve the issue I will mark as the solution. Thank you
– chk.buddi
Dec 28 at 17:21
@JRichardz I tried the #1 method. Now, I'm getting a different issue. My app runs fine when I run as 'Spring boot App' on eclipse but when I run on Tomcat, index page is not displaying.For this app, client app is react based and I have built the client project and copied into the static folder of the main project.Any suggestion?
– chk.buddi
2 days ago
If your app is an spring-boot, you don't need tomcat. Tomcat is mandatory in your requirement? Related to your architecture, I recommend to decouple web client app to the api rest. You can host your app in a separate instance with apache, nginx, nodejs, etc
– JRichardsz
2 days ago
Many thanks. I will try these ways and let you know the status. Thank you once again.
– chk.buddi
Dec 28 at 17:11
Many thanks. I will try these ways and let you know the status. Thank you once again.
– chk.buddi
Dec 28 at 17:11
@chk.buddi if this helped to solve your problem, please use the checkmark on the left to mark this as solved :D. Also don't forget to contact me if your have troubleshootings in one of the approaches or steps
– JRichardsz
Dec 28 at 17:17
@chk.buddi if this helped to solve your problem, please use the checkmark on the left to mark this as solved :D. Also don't forget to contact me if your have troubleshootings in one of the approaches or steps
– JRichardsz
Dec 28 at 17:17
Sure, once I solve the issue I will mark as the solution. Thank you
– chk.buddi
Dec 28 at 17:21
Sure, once I solve the issue I will mark as the solution. Thank you
– chk.buddi
Dec 28 at 17:21
@JRichardz I tried the #1 method. Now, I'm getting a different issue. My app runs fine when I run as 'Spring boot App' on eclipse but when I run on Tomcat, index page is not displaying.For this app, client app is react based and I have built the client project and copied into the static folder of the main project.Any suggestion?
– chk.buddi
2 days ago
@JRichardz I tried the #1 method. Now, I'm getting a different issue. My app runs fine when I run as 'Spring boot App' on eclipse but when I run on Tomcat, index page is not displaying.For this app, client app is react based and I have built the client project and copied into the static folder of the main project.Any suggestion?
– chk.buddi
2 days ago
If your app is an spring-boot, you don't need tomcat. Tomcat is mandatory in your requirement? Related to your architecture, I recommend to decouple web client app to the api rest. You can host your app in a separate instance with apache, nginx, nodejs, etc
– JRichardsz
2 days ago
If your app is an spring-boot, you don't need tomcat. Tomcat is mandatory in your requirement? Related to your architecture, I recommend to decouple web client app to the api rest. You can host your app in a separate instance with apache, nginx, nodejs, etc
– JRichardsz
2 days ago
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53946704%2fhow-to-deploy-war-file-on-tomcat-installed-in-compute-engine-instance%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Is this just a proof of concept or Do you need a basic devops/automation flow?
– JRichardsz
Dec 27 at 20:13
@JRichardsz Actually, I need a basic develops. I searched everywhere but I cannot find any resources to deploy war file on tomcat which installed in compute engine instance.I have already copied my war file into instance. Can you please let me know which commands that need for deployment?
– chk.buddi
Dec 28 at 0:32
Don't worry, I will help you. In the meantime, some questions. Are you in the ability to acquire instances? Basic environments for enterprise consists on 4 instances : dev, testing, production and the last one for continuous integration. Or do you need something more light like a startup or demo? Are you using git?
– JRichardsz
Dec 28 at 1:12
@JRichardsz Thank you for your help. Actually, this is a demo website. Yes, I have used git.This is the git url.
– chk.buddi
Dec 28 at 1:38
github.com/ChkBuk/myexamples/tree/master/SyneBiz
– chk.buddi
Dec 28 at 1:39