Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy and release scripts #79

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions .rultor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,37 @@ architect:
docker:
image: l3r8y/rultor-image:1.0.3
assets:
ghcr.txt: tracehubpm/secrets#assets/ghcr.txt
ghcr.txt: tracehubpm/secrets#assets/ghcr-hanna.txt
creds.txt: tracehubpm/secrets#assets/creds.txt
dukris marked this conversation as resolved.
Show resolved Hide resolved
pmo.env: tracehubpm/secrets#assets/pmo.env
keycloak.env: tracehubpm/secrets#assets/keycloak.env
merge:
script: |
mvn clean install --errors
release:
sensitive:
- ghcr.txt
script: |
[[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9_]+)?$ ]] || exit -1
mvn versions:set "-DnewVersion=${tag}"
git commit -am "${tag}"
[[ "${TAG}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9_]+)?$ ]] || exit -1
dukris marked this conversation as resolved.
Show resolved Hide resolved
mvn versions:set "-DnewVersion=${TAG}"
git commit -am "${TAG}"
mvn clean install
docker build -t ghcr.io/tracehubpm/pmo:${tag} .
cat ../ghcr.txt | docker login ghcr.io --username h1alexbel --password-stdin
docker push ghcr.io/tracehubpm/pmo:${tag}
# @todo #2:90min Create deploy script for rultor configuration.
# We should create deploy script that will deliver our Java software
# into some target platform. For now, we assuming that it will be
# Cloud VM with public IP, and SSH connection.
docker build -t ghcr.io/tracehubpm/pmo:${TAG} .
cat ../ghcr.txt | docker login ghcr.io --username hizmailovich --password-stdin
docker push ghcr.io/tracehubpm/pmo:${TAG}
sudo apt-get -y install sshpass
echo ${TAG} >> /home/r/repo/scripts/release/tag.txt
sshpass -f ../creds.txt scp -r /home/r/repo/scripts/release root@${IP}:~/
sshpass -f ../creds.txt scp ../pmo.env root@${IP}:~/release/pmo.env
sshpass -f ../creds.txt scp ../keycloak.env root@${IP}:~/release/keycloak.env
sshpass -f ../creds.txt ssh -o StrictHostKeyChecking=no root@${IP}
cd release
TAG=$(cat tag.txt)
dukris marked this conversation as resolved.
Show resolved Hide resolved
TAG=${TAG} docker-compose up -d --build
dukris marked this conversation as resolved.
Show resolved Hide resolved
deploy:
script: |
sudo apt-get -y install sshpass
sshpass -f ../creds.txt scp -r /home/r/repo/scripts/deploy root@${IP}:~/
sshpass -f ../creds.txt ssh -o StrictHostKeyChecking=no root@${IP}
cd deploy
sh setup.sh
12 changes: 12 additions & 0 deletions scripts/deploy/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
server {
listen 80;

server_name pmo.tracehub.git;

location /realms/ {
proxy_pass http://localhost:8090;
}
location / {
proxy_pass http://localhost:8080;
}
}
19 changes: 19 additions & 0 deletions scripts/deploy/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt-get -y install docker-ce
sudo systemctl status docker
sudo apt-get -y install curl gnupg2 ca-certificates lsb-release ubuntu-keyring
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/mainline/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
| sudo tee /etc/apt/preferences.d/99nginx
sudo apt-get -y install nginx
sudo mv default.conf /etc/nginx/conf.d/default.conf
sudo systemctl restart nginx
sudo systemctl status nginx
37 changes: 37 additions & 0 deletions scripts/release/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: '3.9'

services:
keycloak:
image: quay.io/keycloak/keycloak:23.0.2
container_name: keycloak
environment:
KC_DB: ${KC_DB}
KC_DB_URL_HOST: ${KC_DB_URL_HOST}
KC_DB_USERNAME: ${KC_DB_USERNAME}
KC_DB_PASSWORD: ${KC_DB_PASSWORD}
KEYCLOAK_ADMIN: ${KEYCLOAK_ADMIN}
KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD}
ports:
- '8090:8090'
networks:
- pmo
command: start --import-realm --http-port=8090
volumes:
- ./realm-export.json:/opt/keycloak/data/import/realm-export.json
env_file:
- keycloak.env
app:
container_name: tracehub-pmo
image: ghcr.io/tracehubpm/pmo:${TAG}
ports:
- '8080:8080'
depends_on:
- keycloak
networks:
- pmo
env_file:
- pmo.env

networks:
pmo:
driver: bridge
Loading