Skip to content

Commit a843930

Browse files
committed
🔧Setting: Docker initial setting
1 parent bafdb82 commit a843930

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed

.dockerignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Gradle 관련
2+
.gradle/
3+
build/
4+
!gradle/wrapper/gradle-wrapper.jar
5+
6+
# IDE 관련
7+
.idea/
8+
.vscode/
9+
*.iws
10+
*.iml
11+
*.ipr
12+
.classpath
13+
.project
14+
.settings/
15+
16+
# 로그 파일
17+
logs/
18+
*.log
19+
20+
# 기타
21+
.git/
22+
.gitignore
23+
README.md
24+
docker-compose.yml
25+
Dockerfile
26+
.dockerignore

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM eclipse-temurin:21-jdk AS build
2+
3+
# 작업 위치
4+
WORKDIR /app
5+
6+
# 소스 코드 복사
7+
COPY . .
8+
9+
# 실행 권한 부여
10+
RUN chmod +x ./gradlew
11+
12+
# 프로젝트 빌드
13+
RUN ./gradlew build -x test
14+
15+
FROM eclipse-temurin:21-jre
16+
17+
# 빌드 이미지에서 JAR 파일 복사
18+
COPY --from=build /app/build/libs/*.jar app.jar
19+
20+
# 포트 노출
21+
EXPOSE 8080
22+
23+
# 애플리케이션 실행
24+
ENTRYPOINT ["java", "-jar", "app.jar"]

docker-compose.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
services:
2+
postgreSQL:
3+
image: postgres:16
4+
ports:
5+
- "5432:5432"
6+
env_file:
7+
- .env
8+
environment:
9+
- TZ=Asia/Seoul
10+
- POSTGRES_USER=${POSTGRES_USER}
11+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
12+
- POSTGRES_DB=${POSTGRES_DB}
13+
volumes:
14+
- postgres-data:/var/lib/postgresql/data
15+
networks:
16+
- sportize-network
17+
18+
app:
19+
image: imjuyongp/sportize:latest # 추후에 도커 허브에 저장할 이미지 계정이랑 이미지 이름 설정하기
20+
restart: always
21+
expose:
22+
- "8080"
23+
env_file:
24+
- .env # 팀원들끼리만 공유
25+
environment:
26+
- SPRING_PROFILES_ACTIVE=prod # 서브모듈 환경변수 prod 버전 인식
27+
- TZ=Asia/Seoul
28+
volumes:
29+
- /etc/localtime:/etc/localtime:ro
30+
- /etc/timezone:/etc/timezone:ro
31+
command:
32+
- java -Dspring.profiles.active=${SPRING_PROFILES_ACTIVE} -jar app.jar
33+
# 실행 명령어: jar 파일을 실행하면서 Spring 프로필 활성화
34+
depends_on:
35+
- postgreSQL # 이 서비스가 mysql이 먼저 실행된 후 시작되도록
36+
networks:
37+
- sportize-network # services 끼리는 같은 네트워크를 공유
38+
39+
nginx:
40+
image: nginx:alpine
41+
restart: always
42+
ports:
43+
- "80:80"
44+
- "443:443"
45+
volumes:
46+
- ./nginx/conf.d:/etc/nginx/conf.d
47+
- ./nginx/certbot:/etc/letsencrypt
48+
- ./nginx/www:/var/www/certbot
49+
depends_on:
50+
- app
51+
networks:
52+
- sportize-network
53+
certbot:
54+
image: certbot/certbot
55+
volumes:
56+
- ./nginx/certbot:/etc/letsencrypt
57+
- ./nginx/www:/var/www/certbot
58+
networks:
59+
- sportize-network
60+
networks:
61+
sportize-network:
62+
driver: bridge # Docker 기본 브리지 네트워크를 사용
63+
64+
volumes:
65+
postgres-data:

0 commit comments

Comments
 (0)