Skip to content

Commit

Permalink
add deployment config for info collector
Browse files Browse the repository at this point in the history
  • Loading branch information
derklaro committed Nov 26, 2024
1 parent b333427 commit e0c0a20
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Deploy Release
on:
workflow_dispatch:
inputs:
api:
type: boolean
description: API
collector:
type: boolean
description: Data-Collector

concurrency:
cancel-in-progress: true
group: deploy-${{ github.ref }}

permissions:
contents: read

jobs:
deploy_api:
runs-on: ubuntu-latest
name: Deploy Rest API
if: ${{ github.event.inputs.api == 'true' }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Push to Dokku
uses: dokku/github-action@master
with:
branch: main
git_push_flags: --force
ssh_private_key: ${{ secrets.DOKKU_PRIVATE_KEY }}
git_remote_url: 'ssh://dokku@${{ secrets.DOKKU_HOST }}:22/sit-api'

deploy_datacollect:
runs-on: ubuntu-latest
name: Deploy Data Collector
if: ${{ github.event.inputs.collector == 'true' }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Push to Dokku
uses: dokku/github-action@master
with:
branch: main
git_push_flags: --force
ssh_private_key: ${{ secrets.DOKKU_PRIVATE_KEY }}
git_remote_url: 'ssh://dokku@${{ secrets.DOKKU_HOST }}:22/sit-collector'
11 changes: 11 additions & 0 deletions info-collector/.deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM --platform=$BUILDPLATFORM azul/zulu-openjdk:23 AS builder
WORKDIR /build

COPY ./ ./
RUN ./gradlew clean buildForDocker -x test -x checkstyleMain -x checkstyleTest --no-daemon

FROM azul/zulu-openjdk-alpine:23-jre-headless
WORKDIR /app

COPY --from=builder /build/info-collector/build/libs/docker/info-collector.jar ./
CMD ["java", "-Duser.timezone=Europe/Berlin", "-Dspring.profiles.active=prd", "-jar", "--enable-preview", "/app/info-collector.jar"]
37 changes: 37 additions & 0 deletions info-collector/.deploy/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "info-collector",
"description": "Info Collector for SIT",
"repository": "https://github.com/simrailtools/backend",
"addons": [],
"healthchecks": {
"web": [
{
"wait": 5,
"initialDelay": 3,
"type": "readiness",
"path": "/admin/health",
"name": "container readiness check"
},
{
"wait": 5,
"type": "liveness",
"path": "/admin/health",
"name": "container liveness check"
}
]
},
"env": {
"SPRING_DATASOURCE_URL": {
"required": true,
"description": "The datasource url"
},
"SPRING_DATASOURCE_USERNAME": {
"required": true,
"description": "The datasource username"
},
"SPRING_DATASOURCE_PASSWORD": {
"required": true,
"description": "The datasource password"
}
}
}
9 changes: 9 additions & 0 deletions info-collector/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,12 @@ protobuf {
}
}
}

// From StackOverflow: https://stackoverflow.com/a/53087407
tasks.register<Copy>("buildForDocker") {
from(tasks.getByName("bootJar"))
into("build/libs/docker")
rename { fileName ->
fileName.replace("-$version", "")
}
}
47 changes: 47 additions & 0 deletions info-collector/src/main/resources/application-prd.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# This file is part of simrail-tools-backend, licensed under the MIT License (MIT).
#
# Copyright (c) 2024 Pasqual Koschmieder and contributors
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

spring.jpa.open-in-view=false
spring.jpa.database=postgresql
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.order_updates=true
spring.jpa.properties.hibernate.jdbc.batch_size=250

logging.pattern.console=%yellow(%date{dd.MM.yy HH:mm:ss}) [%highlight(%5p)] %cyan(%-40.40logger{0})[%magenta(%4.4line)]: %msg %ex%n

server.error.path=/error
server.http2.enabled=true
server.error.whitelabel.enabled=false

management.endpoint.health.enabled=true
management.endpoint.health.show-details=never
management.endpoint.health.probes.enabled=true
management.endpoint.health.show-components=never
management.endpoint.health.cache.time-to-live=10s

management.endpoints.web.base-path=/admin
management.endpoints.enabled-by-default=false
management.endpoints.web.exposure.include=health
management.endpoints.web.discovery.enabled=false

0 comments on commit e0c0a20

Please sign in to comment.