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
45 changes: 21 additions & 24 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,11 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Docker Buildx μ„€μ •
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Docker 이미지 λΉŒλ“œ 및 ν‘Έμ‹œ
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.DOCKER_IMAGE }}:latest
${{ env.DOCKER_IMAGE }}:${{ github.sha }}
${{ env.DOCKER_IMAGE }}:${{ github.event.pull_request.head.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
- name: Build and Push Docker image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/blockcloud-server .
docker push ${{ secrets.DOCKER_USERNAME }}/blockcloud-server

deploy:
needs: build-and-test
Expand All @@ -88,8 +76,11 @@ jobs:
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
set -e
IMAGE="${{ env.DOCKER_IMAGE }}:${{ github.event.pull_request.head.sha }}"
set -euo pipefail

IMAGE="${{ secrets.DOCKER_USERNAME }}/blockcloud-server:latest"

echo "Pulling image: $IMAGE"
docker pull "$IMAGE"

# κΈ°μ‘΄ μ»¨ν…Œμ΄λ„ˆ 정리
Expand All @@ -106,15 +97,21 @@ jobs:
"$IMAGE"

# ν—¬μŠ€μ²΄ν¬
for i in {1..30}; do
echo "πŸ₯ ν—¬μŠ€μ²΄ν¬ μ‹œμž‘ (μ΅œλŒ€ 60초 λŒ€κΈ°)..."
for i in {1..20}; do
if curl -fsS http://127.0.0.1:8080/actuator/health >/dev/null 2>&1; then
echo "βœ… Application is UP and healthy!"
echo "πŸŽ‰ 배포 성곡!"
exit 0
else
echo "⏳ Waiting for application to start... (${i}/20)"
sleep 3
fi
echo "⏳ Waiting for application to start... ($i/30)"
sleep 3
done

echo "❌ Application failed to start properly"
docker logs --tail=200 blockcloud-app || true
exit 1
echo "πŸ“Š μ»¨ν…Œμ΄λ„ˆ μƒνƒœ:"
docker ps -a | grep blockcloud-app || true
echo "πŸ“‹ μ»¨ν…Œμ΄λ„ˆ 둜그:"
docker logs --tail=100 blockcloud-app || true
exit 1
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# ---------- Build ----------
FROM gradle:8.7-jdk21 AS build
WORKDIR /app
COPY gradlew ./
COPY gradle gradle
COPY build.gradle settings.gradle version.properties ./
RUN ./gradlew dependencies --no-daemon || true
COPY src src
RUN ./gradlew clean bootJar -x test -x jacocoTestCoverageVerification -x jacocoTestReport --no-daemon

# ---------- Runtime ----------
FROM eclipse-temurin:21-jre
WORKDIR /app
COPY --from=build /app/build/libs/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","app.jar"]
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ BlockCloud is a Spring Boot-based backend service designed to support the core f

## 🏁 Quick Start

### 둜컬 개발 ν™˜κ²½

```bash
git clone https://github.com/your-username/blockcloud-backend.git
cd blockcloud-backend
Expand All @@ -24,6 +26,58 @@ cd blockcloud-backend

Visit: [http://localhost:8080](http://localhost:8080)

### Dockerλ₯Ό μ‚¬μš©ν•œ μ‹€ν–‰

```bash
# 개발 ν™˜κ²½ μ‹€ν–‰
docker-compose --profile dev up -d

# ν”„λ‘œλ•μ…˜ ν™˜κ²½ μ‹€ν–‰
docker-compose up -d
```

## πŸš€ 배포

### μžλ™ 배포 (GitHub Actions)

1. GitHub Secrets μ„€μ •:
- `HOST`: μ„œλ²„ IP μ£Όμ†Œ
- `USERNAME`: SSH μ‚¬μš©μžλͺ…
- `SSH_KEY`: SSH κ°œμΈν‚€
- `PORT`: SSH 포트 (κΈ°λ³Έκ°’: 22)

2. main λΈŒλžœμΉ˜μ— pushν•˜λ©΄ μžλ™μœΌλ‘œ λ°°ν¬λ©λ‹ˆλ‹€.

### μˆ˜λ™ 배포

```bash
# 배포 슀크립트 μ‹€ν–‰
chmod +x scripts/deploy.sh
./scripts/deploy.sh production latest
```

## πŸ”§ ν™˜κ²½ λ³€μˆ˜

ν”„λ‘œμ νŠΈ λ£¨νŠΈμ— `.env` νŒŒμΌμ„ μƒμ„±ν•˜κ³  λ‹€μŒ λ³€μˆ˜λ“€μ„ μ„€μ •ν•˜μ„Έμš”:

```bash
# Spring Boot ν”„λ‘œν•„
SPRING_PROFILES_ACTIVE=dev

# λ°μ΄ν„°λ² μ΄μŠ€ μ„€μ •
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/blockcloud_dev
SPRING_DATASOURCE_USERNAME=blockcloud
SPRING_DATASOURCE_PASSWORD=password

# JWT μ„€μ •
JWT_SECRET=your-jwt-secret-key-here
JWT_EXPIRATION=86400000

# OAuth2 μ„€μ •
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
```

---

## πŸ“„ License
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/blockcloud/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
"/error",
"/login/oauth2/code/google",
"/swagger-ui/**",
"/v3/api-docs/**"
"/v3/api-docs/**",
"/actuator/**"
).permitAll()
.anyRequest().authenticated()
)
Expand Down