-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from COW-dev/main
- Loading branch information
Showing
8 changed files
with
179 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Release Deploy | ||
|
||
on: | ||
push: | ||
branches: [ "release" ] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'corretto' | ||
cache: "gradle" | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew clean build --no-daemon --exclude-task test | ||
|
||
- name: Login To DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
build-args: | | ||
DB_URL=${{ secrets.DB_URL }} | ||
DB_USERNAME=${{ secrets.DB_USERNAME }} | ||
DB_PASSWORD=${{ secrets.DB_PASSWORD }} | ||
tags: | | ||
eatda/api-server:latest | ||
- name: Get Github IP | ||
id: ip | ||
uses: haythem/[email protected] | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-region: ${{ secrets.AWS_REGION } | ||
role-to-assume: ${{ secrets.AWS_ARN_ROLE_TO_ASSUME } | ||
|
||
- name: Add GitHub IP to AWS | ||
run: | | ||
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port ${{ secrets.EC2_SSH_PORT }} --cidr ${{ steps.ip.outputs.ipv4 }}/32 | ||
- name: Deploy | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USERNAME }} | ||
password: ${{ secrets.EC2_PASSWORD }} | ||
port: ${{ secrets.EC2_SSH_PORT }} | ||
timeout: 60s | ||
script: | | ||
cd eatda-api-server/ | ||
sudo docker rm - f $(docker ps -qa) | ||
sudo docker pull eatda/api-server:latest | ||
sudo docker stop $(sudo docker ps -aq) | ||
sudo docker run -d eatda/api-server:latest \ | ||
--name api-server \ | ||
-p 8080:8080 \ | ||
- name: Remove IP FROM security group | ||
run: | | ||
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port ${{ secrets.EC2_SSH_PORT }} --cidr ${{ steps.ip.outputs.ipv4 }}/32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM amazoncorretto:17-alpine | ||
|
||
CMD ["./gradlew", "clean", "build"] | ||
EXPOSE 8080 | ||
|
||
ARG JAR_FILE=build/libs/*.jar | ||
ARG PROFILE=prod | ||
ARG DB_URL | ||
ARG DB_USERNAME | ||
ARG DB_PASSWORD | ||
|
||
COPY ${JAR_FILE} app.jar | ||
|
||
ENV PROFILE=${PROFILE} | ||
ENV DB_URL=${DB_URL} | ||
ENV DB_USERNAME=${DB_USERNAME} | ||
ENV DB_PASSWORD=${DB_PASSWORD} | ||
|
||
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=${PROFILE}", "-Djava.security.egd=file:/dev/./urandom", "/app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
<include resource="org/springframework/boot/logging/logback/defaults.xml" /> | ||
|
||
<!-- log Record Location --> | ||
<property name="LOGS_ABSOLUTE_PATH" value="./logs" /> | ||
<property name="CONSOLE_LOG_PATTERN" | ||
value="[%d{yyyy-MM-dd HH:mm:ss}:%-3relative] %clr(%-5level) %clr(${PID:-}){magenta} %clr(---){faint} %clr([%15.15thread]){faint} %clr(%-40.40logger{36}){cyan} %clr(:){faint} %msg%n"/> | ||
<property name="FILE_LOG_PATTERN" | ||
value="[%d{yyyy-MM-dd HH:mm:ss}:%-3relative] %-5level ${PID:-} --- [%15.15thread] %-40.40logger{36} : %msg%n"/> | ||
|
||
<!-- Console Setup (STDOUT) --> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<layout class="ch.qos.logback.classic.PatternLayout"> | ||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern> | ||
</layout> | ||
</appender> | ||
|
||
<appender name="QUERY_FILE_ASYNC" class="ch.qos.logback.classic.AsyncAppender"> | ||
<appender-ref ref="FILE" /> | ||
<queueSize>512</queueSize> | ||
<discardingThreshold>0</discardingThreshold> | ||
<includeCallerData>false</includeCallerData> | ||
<neverBlock>true</neverBlock> | ||
<maxFlushTime>1000</maxFlushTime> | ||
</appender> | ||
|
||
<!-- File Setup (FILE) --> | ||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<file>${LOGS_ABSOLUTE_PATH}/logback.log</file> | ||
<encoder> | ||
<pattern>${FILE_LOG_PATTERN}</pattern> | ||
</encoder> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
<fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern> | ||
<maxHistory>30</maxHistory> | ||
<totalSizeCap>3GB</totalSizeCap> | ||
</rollingPolicy> | ||
</appender> | ||
|
||
<!-- log Level Setting (logging.level.root=info)--> | ||
<root level="info"> | ||
<appender-ref ref="STDOUT" /> | ||
<appender-ref ref="FILE" /> | ||
</root> | ||
</configuration> |