Skip to content
Snippets Groups Projects
Verified Commit de21a676 authored by Réthelyi Bálint's avatar Réthelyi Bálint :no_mouth:
Browse files

deploy backend

parent d60133e8
No related branches found
No related tags found
No related merge requests found
Pipeline #19766 failed
......@@ -2,13 +2,14 @@ image: golang:alpine
variables:
CONTAINER_IMAGE: "mosogepsch-notification-server:$CI_COMMIT_REF_NAME"
MOSOGEPSCH_HOST: "root@mosogep-ng.sch.bme.hu"
stages:
- build
- docker
- deploy
backend build:
noti backend build:
image: golang:alpine
stage: build
before_script:
......@@ -24,6 +25,20 @@ backend build:
- notifications/**/*
- .gitlab-ci.yml
backend build:
image: gradle:7.1
stage: build
script:
- cd backend
- ./gradlew shadowJar
artifacts:
paths:
- backend/build/libs/mosogepsch-backend.jar
only:
changes:
- backend/**/*
- .gitlab-ci.yml
android-debug:
variables:
GRADLE_USER_HOME: /cache/gradle/android/mosogepsch
......@@ -78,7 +93,7 @@ dockerhub:
- echo "{\"auths\":{\"https://index.docker.io/v1/\":{\"username\":\"$DOCKERHUB_USER\",\"password\":\"$DOCKERHUB_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --force --context $CI_PROJECT_DIR/notifications --dockerfile $CI_PROJECT_DIR/notifications/Dockerfile --destination blintmester/$CONTAINER_IMAGE
needs:
- backend build
- noti backend build
only:
changes:
- notifications/**/*
......@@ -104,3 +119,25 @@ k8s:
- .gitlab-ci.yml
refs:
- main
deploy backend:
stage: deploy
image: kroniak/ssh-client
before_script:
- eval $(ssh-agent -s)
- echo "$SSH" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- 'echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
needs:
- backend build
script:
- scp backend/mosogepch-backend.service $MOSOGEPSCH_HOST:/etc/systemd/system/
- scp backend/build/libs/mosogepsch-backend.jar $MOSOGEPSCH_HOST:/opt/mosogepsch/
- ssh $MOSOGEPSCH_HOST systemctl restart mosogepsch-backend.service
only:
changes:
- backend/**/*
- .gitlab-ci.yml
refs:
- main
\ No newline at end of file
......@@ -6,8 +6,19 @@ plugins {
application
kotlin("jvm") version "1.6.10"
id("org.jetbrains.kotlin.plugin.serialization") version "1.6.10"
id("com.github.johnrengelman.shadow") version "7.1.2"
}
tasks {
shadowJar {
archiveBaseName.set("mosogepsch-backend")
archiveClassifier.set("")
archiveVersion.set("")
}
}
group = "space.rethelyi"
version = "0.0.1"
application {
......
[Unit]
Description=MosogepSCH backend
[Service]
Type=simple
User=mosogepsch
Group=mosogepsch
ExecStart=java -jar /opt/mosogepsch/mosogepsch-backend.jar
Restart=on-failure
[Install]
WantedBy=multi-user.target
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment