-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e4c4fe
commit 5487025
Showing
2 changed files
with
129 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
settings: &settings | ||
docker: | ||
- image: circleci/openjdk:8-jdk | ||
working_directory: ~/yellowcard-api | ||
environment: | ||
JVM_OPTS: -Xmx3200m | ||
TERM: dumb | ||
|
||
version: 2.1 | ||
commands: | ||
prepare-steps: | ||
steps: | ||
- run: | ||
name: Add Permission | ||
command: chmod +x ./gradlew | ||
- restore_cache: | ||
keys: | ||
- v1-dependencies-{{ checksum "build.gradle" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v1-dependencies- | ||
- run: | ||
name: Download Dependencies | ||
command: ./gradlew dependencies | ||
- save_cache: | ||
paths: | ||
- ~/.gradle | ||
key: v1-dependencies-{{ checksum "build.gradle" }} | ||
jobs: | ||
test: | ||
<<: *settings | ||
steps: | ||
- checkout | ||
- prepare-steps | ||
- run: | ||
name: Run Tests | ||
command: ./gradlew test | ||
- store_artifacts: | ||
path: build/reports/tests/test | ||
- store_test_results: | ||
path: build/test-results/test | ||
build: | ||
<<: *settings | ||
steps: | ||
- checkout | ||
- prepare-steps | ||
- run: | ||
name: Build | ||
command: ./gradlew build -x test | ||
- store_artifacts: | ||
path: build/libs | ||
- persist_to_workspace: | ||
root: ~/yellowcard-api/target | ||
paths: | ||
- build/libs/yellowcard-api-*.jar | ||
deploy: | ||
<<: *settings | ||
steps: | ||
- attach_workspace: | ||
at: ~/yellowcard-api/target | ||
- add_ssh_keys: | ||
fingerprints: | ||
- "2b:7a:75:0b:9d:f0:8c:11:ed:3c:7c:31:db:b8:e7:33" | ||
- run: | ||
name: Stop App | ||
command: ssh -o StrictHostKeyChecking=no 52.78.221.147 '~/web/deploy.sh stop' | ||
- run: | ||
name: Copy App | ||
command: scp -o ~/yellowcard-api/target/depromeet-4th-final-0.0.1.jar 52.78.221.147:~/web | ||
- run: | ||
name: Start App | ||
command: ssh -o 52.78.221.147 '~/web/deploy.sh start' | ||
workflows: | ||
version: 2 | ||
build-deploy: | ||
jobs: | ||
- test | ||
- build: | ||
requires: | ||
- test | ||
filters: | ||
branches: | ||
only: | ||
- develop | ||
- feature/* | ||
- deploy: | ||
requires: | ||
- build |
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,42 @@ | ||
#!/usr/bin/env bash | ||
|
||
# FIELD | ||
PROFILE_NAME="production" | ||
PROJECT_NAME="yellowcard-api" | ||
|
||
NEW_JAR_FULL_PATH="/home/ec2-user/web/${PROJECT_NAME}-0.0.1.jar" | ||
JAR_FULL_PATH="/home/ec2-user/web/${PROJECT_NAME}.jar" | ||
PID_FULL_PATH="/home/ec2-user/web/${PROJECT_NAME}.pid" | ||
|
||
JAVA_OPTS="-server --spring.profiles.active=${PROFILE_NAME}" | ||
|
||
# COMMAND (OPTION) | ||
case $1 in | ||
start) | ||
echo "Starting $PROJECT_NAME ..." | ||
if [ -f ${PID_FULL_PATH} ]; then | ||
echo "$PROJECT_NAME is already running ..." | ||
else | ||
if [ -f ${NEW_JAR_FULL_PATH} ]; then | ||
chmod +x ${NEW_JAR_FULL_PATH} | ||
rm ${JAR_FULL_PATH} | ||
mv ${NEW_JAR_FULL_PATH} ${JAR_FULL_PATH} | ||
fi | ||
|
||
# java -jar ${JAR_FULL_PATH} ${JAVA_OPTS} | ||
nohup java -jar ${JAR_FULL_PATH} ${JAVA_OPTS} /tmp 2>> /dev/null >> /dev/null & echo $! > ${PID_FULL_PATH} | ||
echo "$PROJECT_NAME started ..." | ||
fi | ||
;; | ||
stop) | ||
if [ -f ${PID_FULL_PATH} ]; then | ||
PID=$(cat ${PID_FULL_PATH}); | ||
echo "$PROJECT_NAME stopping ..." | ||
kill ${PID}; | ||
echo "$PROJECT_NAME stopped ..." | ||
rm ${PID_FULL_PATH} | ||
else | ||
echo "$PROJECT_NAME is not running ..." | ||
fi | ||
;; | ||
esac |