-
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.
- #356
- Loading branch information
Showing
4 changed files
with
156 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,123 @@ | ||
# This is an appspec.yml template file for use with an EC2/On-Premises deployment in CodeDeploy. | ||
# The lines in this template starting with the hashtag symbol are | ||
# instructional comments and can be safely left in the file or | ||
# ignored. | ||
# For help completing this file, see the "AppSpec File Reference" in the | ||
# "CodeDeploy User Guide" at | ||
# https://docs.aws.amazon.com/codedeploy/latest/userguide/app-spec-ref.html | ||
version: 0.0 | ||
# Specify "os: linux" if this revision targets Amazon Linux, | ||
# Red Hat Enterprise Linux (RHEL), or Ubuntu Server | ||
# instances. | ||
# Specify "os: windows" if this revision targets Windows Server instances. | ||
# (You cannot specify both "os: linux" and "os: windows".) | ||
os: linux | ||
# os: windows | ||
# During the Install deployment lifecycle event (which occurs between the | ||
# BeforeInstall and AfterInstall events), copy the specified files | ||
# in "source" starting from the root of the revision's file bundle | ||
# to "destination" on the Amazon EC2 instance. | ||
# Specify multiple "source" and "destination" pairs if you want to copy | ||
# from multiple sources or to multiple destinations. | ||
# If you are not copying any files to the Amazon EC2 instance, then remove the | ||
# "files" section altogether. A blank or incomplete "files" section | ||
# may cause associated deployments to fail. | ||
files: | ||
- source: ./app | ||
destination: /home/ubuntu/42Stat-Backend/app | ||
- source: ./env | ||
destination: /home/ubuntu/42Stat-Backend/env | ||
# For deployments to Amazon Linux, Ubuntu Server, or RHEL instances, | ||
# you can specify a "permissions" | ||
# section here that describes special permissions to apply to the files | ||
# in the "files" section as they are being copied over to | ||
# the Amazon EC2 instance. | ||
# For more information, see the documentation. | ||
# If you are deploying to Windows Server instances, | ||
# then remove the | ||
# "permissions" section altogether. A blank or incomplete "permissions" | ||
# section may cause associated deployments to fail. | ||
permissions: | ||
- object: /home/ubuntu/42Stat-Backend | ||
pattern: "**" | ||
owner: ubuntu | ||
group: ubuntu | ||
mode: 644 | ||
type: | ||
- file | ||
- object: /home/ubuntu/42Stat-Backend | ||
pattern: "**" | ||
owner: ubuntu | ||
group: ubuntu | ||
mode: 755 | ||
type: | ||
- directory | ||
# acls: | ||
# - | ||
# context: | ||
# user: | ||
# type: | ||
# range: | ||
# type: | ||
# - | ||
# If you are not running any commands on the Amazon EC2 instance, then remove | ||
# the "hooks" section altogether. A blank or incomplete "hooks" section | ||
# may cause associated deployments to fail. | ||
hooks: | ||
# For each deployment lifecycle event, specify multiple "location" entries | ||
# if you want to run multiple scripts during that event. | ||
# You can specify "timeout" as the number of seconds to wait until failing the deployment | ||
# if the specified scripts do not run within the specified time limit for the | ||
# specified event. For example, 900 seconds is 15 minutes. If not specified, | ||
# the default is 1800 seconds (30 minutes). | ||
# Note that the maximum amount of time that all scripts must finish executing | ||
# for each individual deployment lifecycle event is 3600 seconds (1 hour). | ||
# Otherwise, the deployment will stop and CodeDeploy will consider the deployment | ||
# to have failed to the Amazon EC2 instance. Make sure that the total number of seconds | ||
# that are specified in "timeout" for all scripts in each individual deployment | ||
# lifecycle event does not exceed a combined 3600 seconds (1 hour). | ||
# For deployments to Amazon Linux, Ubuntu Server, or RHEL instances, | ||
# you can specify "runas" in an event to | ||
# run as the specified user. For more information, see the documentation. | ||
# If you are deploying to Windows Server instances, | ||
# remove "runas" altogether. | ||
# If you do not want to run any commands during a particular deployment | ||
# lifecycle event, remove that event declaration altogether. Blank or | ||
# incomplete event declarations may cause associated deployments to fail. | ||
# During the ApplicationStop deployment lifecycle event, run the commands | ||
# in the script specified in "location" starting from the root of the | ||
# revision's file bundle. | ||
# ApplicationStop: | ||
# - location: | ||
# timeout: | ||
# runas: | ||
# - location: | ||
# timeout: | ||
# runas: | ||
# During the BeforeInstall deployment lifecycle event, run the commands | ||
# in the script specified in "location". | ||
BeforeInstall: | ||
- location: ./deploy-script/beforeInstall.sh | ||
timeout: 30 | ||
runas: ubuntu | ||
# During the AfterInstall deployment lifecycle event, run the commands | ||
# in the script specified in "location". | ||
# AfterInstall: | ||
# - location: | ||
# timeout: | ||
# runas: | ||
# - location: | ||
# timeout: | ||
# runas: | ||
# During the ApplicationStart deployment lifecycle event, run the commands | ||
# in the script specified in "location". | ||
ApplicationStart: | ||
- location: ./deploy-script/applicationStart.sh | ||
timeout: 60 | ||
runas: ubuntu | ||
# During the ValidateService deployment lifecycle event, run the commands | ||
# in the script specified in "location". | ||
ValidateService: | ||
- location: ./deploy-script/validateService.sh | ||
timeout: 600 | ||
runas: ubuntu |
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,7 @@ | ||
#!/bin/bash | ||
|
||
# https://github.com/nvm-sh/nvm | ||
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" | ||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | ||
cd ~/42Stat-Backend/app && pnpm i || exit 1 | ||
nohup pnpm start:prod > ./nohup.out 2>&1 & |
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,8 @@ | ||
#!/bin/bash | ||
|
||
# https://github.com/nvm-sh/nvm | ||
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" | ||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | ||
nvm install 18 && nvm use 18 || exit 1 | ||
npm i -g pnpm || exit 1 | ||
mkdir ~/42Stat-Backend |
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,18 @@ | ||
#!/bin/bash | ||
|
||
attempt=0 | ||
|
||
while [ $attempt -le 50 ] | ||
do | ||
curl --connect-timeout 1 http://localhost:4000/healthcheck | ||
|
||
if [ $? -eq 0 ] | ||
then | ||
exit 0 | ||
else | ||
((attempt++)) | ||
sleep 10 | ||
fi | ||
done | ||
|
||
exit 1 |