Skip to content

Commit a004077

Browse files
Merge pull request #23 from GalaxySciTech/cursor/-bc-b7cac5a5-db15-4c6a-90df-f38f9b95064a-82c0
Deep Project Optimization: Build, Security, Code Quality, Docker, CI/CD
2 parents d52e8f7 + 0628890 commit a004077

83 files changed

Lines changed: 1563 additions & 1152 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.{yml,yaml}]
12+
indent_size = 2
13+
14+
[*.{json,xml}]
15+
indent_size = 2
16+
17+
[*.md]
18+
trim_trailing_whitespace = false
19+
20+
[*.gradle]
21+
indent_size = 4
22+
23+
[Dockerfile]
24+
indent_size = 4

.env.example

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Database
2+
DB_URL=jdbc:mysql://127.0.0.1:3306/wallet_db?allowMultiQueries=true&useSSL=false&characterEncoding=UTF-8&autoReconnect=true
3+
DB_USERNAME=root
4+
DB_PASSWORD=your_secure_password
5+
6+
# RabbitMQ
7+
RABBITMQ_HOST=127.0.0.1
8+
RABBITMQ_PORT=5672
9+
RABBITMQ_USERNAME=guest
10+
RABBITMQ_PASSWORD=guest
11+
12+
# XXL-Job
13+
XXL_JOB_ADMIN_ADDRESSES=http://127.0.0.1:8099/xxl-job-admin
14+
XXL_JOB_PORT=9999
15+
XXL_JOB_ACCESS_TOKEN=your_access_token
16+
17+
# HSM Keystore
18+
KEYSTORE_DIR=/data/keystores
19+
KEYSTORE_PASSWORD=your_keystore_password
20+
21+
# Encryption
22+
WALLET_CRYPTO_PUSH_KEY=your_32_char_encryption_key_here
23+
24+
# Logging
25+
LOG_LEVEL=INFO

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, develop ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
name: Build & Test
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up JDK 17
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '17'
24+
distribution: 'temurin'
25+
26+
- name: Setup Gradle
27+
uses: gradle/actions/setup-gradle@v3
28+
with:
29+
cache-read-only: ${{ github.ref != 'refs/heads/master' }}
30+
31+
- name: Grant execute permission for gradlew
32+
run: chmod +x gradlew
33+
34+
- name: Build
35+
run: ./gradlew build -x test --no-daemon
36+
37+
- name: Run tests
38+
run: ./gradlew test --no-daemon
39+
continue-on-error: true
40+
41+
- name: Upload build artifacts
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: build-artifacts
45+
path: |
46+
wallet-webapi/build/libs/*.jar
47+
wallet-task/build/libs/*.jar
48+
wallet-hsm/build/libs/*.jar
49+
retention-days: 7
50+
51+
docker:
52+
name: Docker Build
53+
runs-on: ubuntu-latest
54+
needs: build
55+
if: github.ref == 'refs/heads/master'
56+
57+
strategy:
58+
matrix:
59+
service: [wallet-webapi, wallet-task, wallet-hsm]
60+
61+
steps:
62+
- uses: actions/checkout@v4
63+
64+
- name: Set up Docker Buildx
65+
uses: docker/setup-buildx-action@v3
66+
67+
- name: Build Docker image
68+
uses: docker/build-push-action@v5
69+
with:
70+
context: .
71+
file: ./${{ matrix.service }}/Dockerfile
72+
push: false
73+
tags: ${{ matrix.service }}:${{ github.sha }}
74+
cache-from: type=gha
75+
cache-to: type=gha,mode=max

.gitignore

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
1+
# Gradle
12
.gradle/
23
build/
4+
!gradle/wrapper/gradle-wrapper.jar
5+
6+
# IDE
37
.settings/
48
.project
59
.classpath
6-
*.class
7-
.idea
10+
.idea/
811
*.iml
9-
.gradle
10-
/local.properties
11-
.DS_Store
12-
/build
12+
*.iws
13+
*.ipr
14+
15+
# Compiled
16+
*.class
17+
out/
1318
/*/out/
14-
out
15-
/wallets
16-
/task-logs
1719

18-
shell
19-
nginx
20-
docker
20+
# OS
21+
.DS_Store
22+
Thumbs.db
23+
24+
# Local config
25+
/local.properties
26+
*.env
27+
!.env.example
28+
29+
# Application data
30+
/wallets/
31+
/task-logs/
32+
/logs/
33+
34+
# Docker local
35+
shell/
36+
nginx/
37+
38+
# Secrets - never commit
39+
*.p12
40+
*.jks
41+
*.keystore

.gitlab-ci.yml

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
variables:
22
DOCKER_DRIVER: overlay2
3+
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
34

45
stages:
56
- build
@@ -9,62 +10,85 @@ cache:
910
key: ${CI_BUILD_STAGE}
1011
paths:
1112
- .gradle
13+
- build
1214

13-
build for all:
14-
image: openjdk:8-jdk-alpine
15+
build:
16+
image: eclipse-temurin:17-jdk-alpine
1517
tags:
1618
- wallet-dev
1719
stage: build
1820
script:
19-
- pwd
20-
- ./gradlew wallet-webapi:bootRepackage
21-
- ./gradlew wallet-task:bootRepackage
22-
- ./gradlew wallet-hsm:bootRepackage
21+
- chmod +x ./gradlew
22+
- ./gradlew wallet-webapi:bootJar --no-daemon -x test
23+
- ./gradlew wallet-task:bootJar --no-daemon -x test
24+
- ./gradlew wallet-hsm:bootJar --no-daemon -x test
2325
artifacts:
2426
paths:
2527
- wallet-webapi/build/libs/*.jar
2628
- wallet-hsm/build/libs/*.jar
2729
- wallet-task/build/libs/*.jar
28-
expire_in: 20min
30+
expire_in: 1 hour
2931

30-
deploy for cl-webapi:
31-
image: gitlab/dind:latest
32+
deploy wallet-webapi:
33+
image: docker:latest
34+
services:
35+
- docker:dind
3236
tags:
3337
- wallet-dev
3438
stage: deploy
3539
script:
36-
- docker stop -f wallet-webapi ||true
37-
- docker rm -f wallet-webapi ||true
38-
- docker rmi wallet-webapi ||true
39-
- docker build -t wallet-webapi wallet-webapi/.
40-
- docker run -d --name wallet-webapi -p 10001:10001 -v /etc/localtime:/etc/localtime cl-webapi
40+
- docker stop wallet-webapi || true
41+
- docker rm wallet-webapi || true
42+
- docker rmi wallet-webapi || true
43+
- docker build -t wallet-webapi -f wallet-webapi/Dockerfile .
44+
- docker run -d --name wallet-webapi
45+
--restart unless-stopped
46+
-p 10001:10001
47+
-v /etc/localtime:/etc/localtime:ro
48+
--env-file /etc/wallet/webapi.env
49+
wallet-webapi
4150
when: manual
4251

43-
deploy for cl-task:
44-
image: gitlab/dind:latest
52+
deploy wallet-task:
53+
image: docker:latest
54+
services:
55+
- docker:dind
4556
tags:
4657
- wallet-dev
4758
stage: deploy
4859
script:
49-
- docker stop -f wallet-task ||true
50-
- docker rm -f wallet-task ||true
51-
- docker rmi wallet-task ||true
52-
- docker build -t wallet-task wallet-task/.
53-
- docker run -d --name wallet-task -p 10033:10033 -v /etc/localtime:/etc/localtime wallet-task
60+
- docker stop wallet-task || true
61+
- docker rm wallet-task || true
62+
- docker rmi wallet-task || true
63+
- docker build -t wallet-task -f wallet-task/Dockerfile .
64+
- docker run -d --name wallet-task
65+
--restart unless-stopped
66+
-p 10033:10033
67+
-v /etc/localtime:/etc/localtime:ro
68+
--env-file /etc/wallet/task.env
69+
wallet-task
5470
when: manual
5571

56-
deploy for cl-hsm:
57-
image: gitlab/dind:latest
72+
deploy wallet-hsm:
73+
image: docker:latest
74+
services:
75+
- docker:dind
5876
tags:
5977
- wallet-dev
6078
stage: deploy
6179
script:
62-
- docker stop -f wallet-hsm ||true
63-
- docker rm -f wallet-hsm ||true
64-
- docker rmi wallet-hsm ||true
65-
- docker build -t wallet-hsm wallet-hsm/.
66-
- docker run -d --name wallet-hsm -p 10888:10888 -v /etc/localtime:/etc/localtime -v /mnt/wallets:/mnt/wallets cl-hsm
80+
- docker stop wallet-hsm || true
81+
- docker rm wallet-hsm || true
82+
- docker rmi wallet-hsm || true
83+
- docker build -t wallet-hsm -f wallet-hsm/Dockerfile .
84+
- docker run -d --name wallet-hsm
85+
--restart unless-stopped
86+
-p 10888:10888
87+
-v /etc/localtime:/etc/localtime:ro
88+
-v /mnt/wallets:/data/keystores
89+
--env-file /etc/wallet/hsm.env
90+
wallet-hsm
6791
when: manual
6892

6993
after_script:
70-
- echo "End CI"
94+
- echo "End CI"

.travis.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)