Skip to content

Commit 2271cf0

Browse files
committed
[docker] 프로젝트에 도커 적용
Dockerfile 을 작성하여 프로젝트에 도커를 적용하고 DB 를 호스트의 DB 와 연결하였습니다.
1 parent 226459f commit 2271cf0

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# 빌드 스테이지: Gradle과 JDK 17을 사용하여 WAR 파일 빌드
2+
FROM gradle:7.6.1-jdk17 AS build
3+
WORKDIR /app
4+
COPY . .
5+
RUN ./gradlew clean build
6+
7+
# 실행 스테이지: Tomcat 10.1.26과 JDK 17을 사용하여 WAR 실행
8+
FROM tomcat:10.1.26-jdk17
9+
WORKDIR /usr/local/tomcat/webapps/
10+
COPY --from=build /app/build/libs/*.war ./ROOT.war
11+
12+
# 8080 포트 노출 (Tomcat 기본 포트)
13+
EXPOSE 8080
14+
15+
# Tomcat 실행
16+
CMD ["catalina.sh", "run"]

src/main/java/lass9436/config/Database.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
public class Database {
1313

14-
private static final String url = "jdbc:mysql://localhost:3306/jsp_cafe";
14+
private static final String url = "jdbc:mysql://host.docker.internal:3306/jsp_cafe";
1515
private static final String user = "user";
1616
private static final String password = "1234";
1717
private static final MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();

0 commit comments

Comments
 (0)