From aa17e840182a5f7bad35c534945400fb95fdfadd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=ED=98=84=EC=B2=A0?= Date: Mon, 16 Oct 2023 13:31:57 +0900 Subject: [PATCH] =?UTF-8?q?infra=20:=20dockerfile=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 24 +++++++++--------------- appspec.yml | 2 +- scripts/deploy.sh | 13 +++++++++++++ 3 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 scripts/deploy.sh diff --git a/Dockerfile b/Dockerfile index 8e5c2f8c..eb375dbd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,9 @@ -FROM adoptopenjdk:11 AS builder -COPY gradlew . -COPY settings.gradle . -COPY build.gradle . -COPY gradle gradle -COPY src src -RUN chmod +x ./gradlew -RUN ./gradlew build -x test - -FROM adoptopenjdk:11 -RUN mkdir /opt/app -COPY --from=builder build/libs/*.jar /opt/app/spring-boot-application.jar -EXPOSE 8080 -ENV PROFILE local -ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=${PROFILE}" ,"/opt/app/spring-boot-application.jar"] \ No newline at end of file +FROM openjdk:11-jdk + +VOLUME /tmp + +ARG JAR_FILE=./build/libs/*.jar + +COPY ${JAR_FILE} app.jar + +ENTRYPOINT ["nohup","java","-jar","-Dspring.profiles.active=prod","app.jar","2>&1","&"] \ No newline at end of file diff --git a/appspec.yml b/appspec.yml index 6ca75f8e..c93ee2cf 100644 --- a/appspec.yml +++ b/appspec.yml @@ -12,7 +12,7 @@ permissions: group: ubuntu mode: 755 hooks: - AfterInstall: + ApplicationStart: - location: scripts/deploy.sh timeout: 60 runas: ubuntu \ No newline at end of file diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100644 index 00000000..1296d579 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,13 @@ +# 가동중인 ssafsound-app 도커 중단 및 삭제 +sudo docker ps -a -q --filter "name=ssafsound-app" | grep -q . && docker stop ssafsound-app && docker rm ssafsound-app | true + +# 기존 이미지 삭제 +sudo docker rmi kimssafy/ssafsound-app:latest + +# 도커허브 이미지 pull +sudo docker pull kimssafy/ssafsound-app:latest + +# 도커 run +docker run -d -p 8080:8080 -e TZ=Asia/Seoul -v /home/ubuntu/logs:/logs --name ssafsound-app kimssafy/ssafsound-app:latest + +docker rmi -f $(docker images -f "dangling=true" -q) || true \ No newline at end of file