Right now, I deploy my (Spring Boot) application to EC2 instance like:
scp
command (Ubuntu) from my local machineI would like to automate that process, but:
Question: Is it possible to perform 2 simple steps (that are now done manualy - building and deploying via scp
) with GitLab CI/CD tools and if so, can you present simple steps to do it.
Thanks!
Sign in to the AWS Management Console and open the CodeDeploy console at https://console.aws.amazon.com/codedeploy . Sign in with the same account or IAM user information that you used in Getting started with CodeDeploy. In the navigation pane, expand Deploy, then choose Applications.
You need to create a .gitlab-ci.yml file in your repository with CI jobs defined to do the two tasks you've defined.
Here's an example to get you started.
stages:
- build
- deploy
build:
stage: build
image: gradle:jdk
script:
- gradle build
artifacts:
paths:
- my_app.jar
deploy:
stage: deploy
image: ubuntu:latest
script:
- apt-get update
- apt-get -y install openssh-client
- scp my_app.jar target.server:/my_app.jar
In this example, the build job run a gradle container and uses gradle to build the app. GitLab CI artifacts are used to capture the built jar (my_app.jar), which will be passed on to the deploy job.
The deploy job runs an ubuntu container, installs openssh-client (for scp), then executes scp to open my_app.jar (passed from the build job) to the target server.
You have to fill in the actual details of building and copying your app. For secrets like SSH keys, set project level CI/CD variables that will be passed in to your CI jobs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With