Compare commits
15 Commits
eb199775b3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
ef7289f6d2
|
|||
|
b8ae4feb4f
|
|||
|
9bb7a2e764
|
|||
|
2ef81803c6
|
|||
|
53e79c0067
|
|||
|
80dbbb90a0
|
|||
|
c1122e9abd
|
|||
|
|
395ccacf0a | ||
|
|
30eb922427 | ||
|
|
7701524322 | ||
|
6e88162fcf
|
|||
|
|
3b77400dcc | ||
|
22972fdc37
|
|||
|
144ec36a75
|
|||
| 1720f57f7c |
45
.gitea/workflows/docker.yml
Normal file
45
.gitea/workflows/docker.yml
Normal file
@@ -0,0 +1,45 @@
|
||||
name: Build and Push Multi-Arch Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Set Registry Domain
|
||||
run: |
|
||||
REGISTRY_DOMAIN=$(echo "${{ github.server_url }}" | sed 's|https://||' | sed 's|http://||')
|
||||
echo "REGISTRY_DOMAIN=$REGISTRY_DOMAIN" >> $GITHUB_ENV
|
||||
|
||||
- name: Login to Gitea Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ env.REGISTRY_DOMAIN }}
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Extract Version
|
||||
run: |
|
||||
VERSION=$(grep "^version = " build.gradle | sed "s/version = '//" | sed "s/'//")
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
echo "MAJOR=$(echo $VERSION | cut -d. -f1)" >> $GITHUB_ENV
|
||||
echo "MAJOR_MINOR=$(echo $VERSION | cut -d. -f1,2)" >> $GITHUB_ENV
|
||||
|
||||
- name: Build and Push Multi-Arch Image
|
||||
run: |
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
-t ${{ env.REGISTRY_DOMAIN }}/${{ github.repository }}:latest \
|
||||
-t ${{ env.REGISTRY_DOMAIN }}/${{ github.repository }}:${{ env.MAJOR }} \
|
||||
-t ${{ env.REGISTRY_DOMAIN }}/${{ github.repository }}:${{ env.MAJOR_MINOR }} \
|
||||
-t ${{ env.REGISTRY_DOMAIN }}/${{ github.repository }}:${{ env.VERSION }} \
|
||||
--push .
|
||||
11
.github/dependabot.yml
vendored
11
.github/dependabot.yml
vendored
@@ -1,11 +0,0 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
|
||||
- package-ecosystem: "gradle"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
39
.github/workflows/deploy-hetzner.yaml
vendored
39
.github/workflows/deploy-hetzner.yaml
vendored
@@ -1,39 +0,0 @@
|
||||
---
|
||||
name: 'deploy to hetzner'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Cloning repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
cache: gradle
|
||||
|
||||
- name: Build with Gradle (no Testing)
|
||||
run: ./gradlew clean build -x test
|
||||
|
||||
- name: Push to dokku
|
||||
timeout-minutes: 20
|
||||
uses: dokku/github-action@v1
|
||||
with:
|
||||
branch: main
|
||||
git_remote_url: ${{ secrets.HETZNER_GIT_URI }}
|
||||
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
git_push_flags: --force
|
||||
@@ -11,9 +11,11 @@ USER app
|
||||
|
||||
# Copy all needed project files to a folder
|
||||
COPY --chown=app ./gradle/ ./gradle
|
||||
COPY --chown=app ./gradlew ./build.gradle ./settings.gradle ./app.json ./
|
||||
COPY --chown=app ./gradlew ./build.gradle ./settings.gradle ./
|
||||
COPY --chown=app ./src ./src
|
||||
|
||||
RUN curl -OL https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
|
||||
|
||||
# Build the production package
|
||||
RUN ./gradlew clean build -x test
|
||||
|
||||
@@ -24,7 +26,8 @@ RUN useradd -m app
|
||||
USER app
|
||||
|
||||
COPY --chown=app --from=build /usr/src/app/build/libs/*-SNAPSHOT.jar /usr/app/config.jar
|
||||
COPY --chown=app --from=build /usr/src/app/opentelemetry-javaagent.jar /usr/app/opentelemetry-javaagent.jar
|
||||
|
||||
HEALTHCHECK CMD curl --fail http://localhost:5000/actuator/health || exit 1
|
||||
HEALTHCHECK CMD curl --fail http://localhost:8888/actuator/health || exit 1
|
||||
|
||||
CMD ["java", "-jar", "/usr/app/config.jar"]
|
||||
|
||||
20
Makefile
Normal file
20
Makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
REMOTE_HOST = mars3142@172.16.20.1
|
||||
PROJECT_NAME = firmware-hq
|
||||
SERVICE_NAME = config-service
|
||||
RASPI_PATH = /mnt/data/${PROJECT_NAME}
|
||||
|
||||
install: build deploy import cleanup
|
||||
|
||||
build:
|
||||
docker buildx build --platform linux/arm64 --no-cache -t ${PROJECT_NAME}/${SERVICE_NAME}:latest -o type=docker,dest=./${SERVICE_NAME}-arm64.tar .
|
||||
|
||||
deploy:
|
||||
scp ./${SERVICE_NAME}-arm64.tar ${REMOTE_HOST}:${RASPI_PATH}/
|
||||
|
||||
import:
|
||||
ssh ${REMOTE_HOST} "sudo docker load -i ${RASPI_PATH}/${SERVICE_NAME}-arm64.tar && rm ${RASPI_PATH}/${SERVICE_NAME}-arm64.tar"
|
||||
|
||||
cleanup:
|
||||
rm -f ${SERVICE_NAME}-arm64.tar
|
||||
|
||||
.PHONY: build deploy import cleanup
|
||||
14
app.json
14
app.json
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"healthchecks": {
|
||||
"web": [
|
||||
{
|
||||
"type": "readiness",
|
||||
"name": "web check",
|
||||
"description": "Checking if the app responds to the /actuator/health/readiness endpoint",
|
||||
"path": "/actuator/health/readiness",
|
||||
"port": 5000,
|
||||
"attempts": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
17
build.gradle
17
build.gradle
@@ -1,12 +1,11 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '3.3.4'
|
||||
id 'org.springframework.boot' version '3.4.0'
|
||||
id 'io.spring.dependency-management' version '1.1.6'
|
||||
id "io.sentry.jvm.gradle" version "4.11.0"
|
||||
}
|
||||
|
||||
group = 'dev.mars3142.fhq'
|
||||
version = '0.0.1-SNAPSHOT'
|
||||
version = '0.1.0-SNAPSHOT'
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
@@ -25,16 +24,16 @@ repositories {
|
||||
}
|
||||
|
||||
ext {
|
||||
set('springCloudVersion', "2023.0.3")
|
||||
set('springCloudVersion', "2024.0.0")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.springframework.cloud:spring-cloud-config-server'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
||||
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
|
||||
implementation 'com.github.ben-manes.caffeine:caffeine:3.1.8'
|
||||
compileOnly 'org.projectlombok:lombok'
|
||||
annotationProcessor 'org.projectlombok:lombok'
|
||||
compileOnly 'org.projectlombok:lombok'
|
||||
implementation 'com.github.ben-manes.caffeine:caffeine:3.1.8'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
||||
implementation 'org.springframework.cloud:spring-cloud-config-server'
|
||||
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||
}
|
||||
|
||||
@@ -17,11 +17,7 @@ spring:
|
||||
native:
|
||||
search-locations: classpath:/configurations
|
||||
git:
|
||||
uri: https://github.com/${GIT_USER}/configuration.git
|
||||
username: ${GIT_USER}
|
||||
password: ${GIT_TOKEN}
|
||||
clone-on-start: true
|
||||
uri: https://${GIT_LOGIN_USER}:${GIT_TOKEN}@${GIT_USER}/${GIT_REPO}/remote-config.git
|
||||
default-label: main
|
||||
searchPaths: configurations
|
||||
profiles:
|
||||
active: native
|
||||
|
||||
@@ -14,15 +14,16 @@ info:
|
||||
|
||||
logging:
|
||||
level:
|
||||
com:
|
||||
netflix:
|
||||
discovery: off
|
||||
com.netflix.discovery: off
|
||||
|
||||
management:
|
||||
endpoint:
|
||||
health:
|
||||
probes:
|
||||
enabled: true
|
||||
web:
|
||||
exposure:
|
||||
include: refresh, bus-refresh, beans, env
|
||||
|
||||
sentry:
|
||||
dsn: https://354321d371291036cffcdb5b1a72fd6e@o394865.ingest.us.sentry.io/4507718826262528
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
server:
|
||||
port: ${PORT:8080}
|
||||
springdoc:
|
||||
enable-native-support: true
|
||||
api-docs:
|
||||
enabled: true
|
||||
swagger-ui:
|
||||
enabled: true
|
||||
path: /swagger-ui.html
|
||||
config-url: /v3/api-docs/swagger-config
|
||||
urls:
|
||||
- url: /v3/api-docs
|
||||
name: API Gateway Service
|
||||
primaryName: API Gateway Service
|
||||
- url: /timezone-service/v3/api-docs
|
||||
name: Timezone Service
|
||||
primaryName: Timezone Service
|
||||
- url: /google-service/v3/api-docs
|
||||
name: Google Service
|
||||
primaryName: Google Service
|
||||
|
||||
spring:
|
||||
cloud:
|
||||
@@ -18,33 +34,26 @@ spring:
|
||||
locator:
|
||||
enabled: false
|
||||
routes:
|
||||
- id: edge
|
||||
uri: lb://edge-service
|
||||
predicates:
|
||||
- Path=/v3/api-docs/**
|
||||
filters:
|
||||
- RewritePath=/v3/api-docs/(?<path>.*), /$\{path}/v3/api-docs
|
||||
|
||||
- id: timezone-service
|
||||
uri: lb://timezone-service
|
||||
predicates:
|
||||
- Path=/v1/timezone/**, /health/timezone, /timezone/v3/api-docs
|
||||
- Path=/v1/timezone/**, /health/timezone, /timezone-service/v3/api-docs
|
||||
filters:
|
||||
- RewritePath=/health/timezone, /actuator/health
|
||||
- RewritePath=/timezone/(?<segment>.*), /$\{segment}
|
||||
- RewritePath=/timezone-service/(?<segment>.*), /$\{segment}
|
||||
|
||||
- id: google-service
|
||||
uri: ${GOOGLE_SERVICE_URI:http://google-service.web:8080}
|
||||
uri: lb://google-service
|
||||
predicates:
|
||||
- Path=/v1/account/**, /health/google, /google/v3/api-docs
|
||||
- Path=/v1/account/**, /health/google, /google-service/v3/api-docs
|
||||
filters:
|
||||
- RewritePath=/health/google, /actuator/health
|
||||
- RewritePath=/google/(?<segment>.*), /$\{segment}
|
||||
- RewritePath=/google-service/(?<segment>.*), /$\{segment}
|
||||
|
||||
- id: token-service
|
||||
uri: ${BACKEND_SERVICE_URI:http://backend-service.web:8080}
|
||||
uri: lb://backend-service
|
||||
predicates:
|
||||
- Path=/v1/token/**, /health/backend, /token/v3/api-docs
|
||||
- Path=/v1/token/**, /health/backend, /token-service/v3/api-docs
|
||||
filters:
|
||||
- RewritePath=/health/backend, /actuator/health
|
||||
- RewritePath=/token/(?<segment>.*), /$\{segment}
|
||||
- RewritePath=/token-service/(?<segment>.*), /$\{segment}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
server:
|
||||
port: ${PORT:8081}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
server:
|
||||
port: ${PORT:9000}
|
||||
|
||||
Reference in New Issue
Block a user