Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
70 changes: 70 additions & 0 deletions .github/workflows/be-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Uniro-server CD

on:
push:
branches:
- be

jobs:
uniro-ci:
name: Build & Push Docker Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}

- name: Create application.properties from secret
run: |
echo "${{ secrets.BE_SPRING_APPLICATION_SECRET }}" > ./uniro_backend/src/main/resources/application.properties
shell: bash

- name: Build Spring Boot Application
run: |
cd uniro_backend
./gradlew clean build -x test

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Docker Hub Login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_LOGIN_USERNAME }}
password: ${{ secrets.DOCKERHUB_LOGIN_ACCESSTOKEN }}

- name: Build & Push Multi-Arch Docker Image
run: |
cd uniro_backend
docker buildx create --use
docker buildx build --platform linux/amd64,linux/arm64 -t uniro5th/uniro-docker-repo:develop --build-arg SPRING_PROFILE=dev --push .

deploy-run:
name: Deploy to Server
needs: uniro-ci
runs-on: ubuntu-latest
steps:
- name: Run Docker Container on Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.BE_SERVER_IP }}
username: ${{ secrets.BE_SERVER_USER }}
key: ${{ secrets.BE_SERVER_KEY }}
script: |
cd ~/myapp
chmod +x ./deploy.sh
./deploy.sh
42 changes: 42 additions & 0 deletions .github/workflows/be-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Uniro-server CI

on:
pull_request:
branches:
- be

jobs:
build-springboot:
name: Build and analyze (SpringBoot)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}

- name: Create application.properties from secret
run: |
echo "${{ secrets.BE_SPRING_APPLICATION_SECRET }}" > ./uniro_backend/src/main/resources/application.properties
shell: bash

- name: Debug application.properties
run: cat ./uniro_backend/src/main/resources/application.properties

- name: Build and analyze (SpringBoot)
run: |
cd uniro_backend
./gradlew clean build -x test
10 changes: 10 additions & 0 deletions uniro_backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM openjdk:17

ARG JAR_FILE=./build/libs/*.jar
ARG SPRING_PROFILE

COPY ${JAR_FILE} uniro-server.jar

ENV SPRING_PROFILE=${SPRING_PROFILE}

ENTRYPOINT ["java", "-Duser.timezone=Asia/Seoul","-Dspring.profiles.active=${SPRING_PROFILE}" ,"-jar" ,"uniro-server.jar"]
5 changes: 4 additions & 1 deletion uniro_backend/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.4.2'
id 'org.springframework.boot' version '3.3.8'
id 'io.spring.dependency-management' version '1.1.7'
id 'org.hibernate.orm' version '6.3.1.Final'
}
Expand Down Expand Up @@ -65,6 +65,9 @@ dependencies {

//webClient
implementation 'org.springframework.boot:spring-boot-starter-webflux'

// actuator
implementation 'org.springframework.boot:spring-boot-starter-actuator'
}

tasks.named('test') {
Expand Down
28 changes: 28 additions & 0 deletions uniro_backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: '3.8'

services:
spring-green:
image: uniro5th/uniro-docker-repo:develop
container_name: spring-green
environment:
- SPRING_PROFILES_ACTIVE=dev
restart: always
ports:
- "8080:8080"
networks:
- my_network1

spring-blue:
image: uniro5th/uniro-docker-repo:develop
container_name: spring-blue
environment:
- SPRING_PROFILES_ACTIVE=dev
restart: always
ports:
- "8081:8080"
networks:
- my_network1

networks:
my_network1:
external: true
41 changes: 41 additions & 0 deletions uniro_backend/src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
spring:
config:
import: application.properties
datasource:
url: ${DB_URL}
username: ${DB_USER}
password: ${DB_PASSWORD}
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
hibernate:
ddl-auto:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL8Dialect
format_sql: true
show_sql: true
open-in-view: false
defer-datasource-initialization: true
sql:
init:
schema-locations: classpath:h2gis-setting.sql
h2:
console:
enabled: true
path: /h2-console
map:
api:
key: ${google.api.key}

management:
endpoints:
jmx:
exposure:
exclude: "*"
web:
exposure:
include: info, health, prometheus
prometheus:
metrics:
export:
enabled: true
15 changes: 14 additions & 1 deletion uniro_backend/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,17 @@ spring:
path: /h2-console
map:
api:
key: ${google.api.key}
key: ${google.api.key}

management:
endpoints:
jmx:
exposure:
exclude: "*"
web:
exposure:
include: info, health, prometheus
prometheus:
metrics:
export:
enabled: true
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
spring:
config:
activate:
on-profile: test

datasource:
url: jdbc:h2:mem:uniro-local-db;DATABASE_TO_UPPER=FALSE;mode=mysql
driverClassName: org.h2.Driver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
import org.locationtech.jts.geom.Point;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest
@ActiveProfiles("test")
public class MapClientImplTest {
@Autowired
private MapClientImpl mapClientImpl;
Expand Down