Merge branch 'main' of github.com:cgzirim/song-recognition

This commit is contained in:
Chigozirim Igweamaka 2024-05-18 05:58:46 +01:00
commit b8996a914c
4 changed files with 72 additions and 0 deletions

12
appspec.yml Normal file
View file

@ -0,0 +1,12 @@
version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu/song-recognition
hooks:
BeforeInstall:
- location: scripts/BeforeInstall.sh
AfterInstall:
- location: scripts/AfterInstall.sh
- location: scripts/ApplicationStart.sh
runas: ubuntu

3
scripts/AfterInstall.sh Normal file
View file

@ -0,0 +1,3 @@
sudo chown -R ubuntu:ubuntu /home/ubuntu/song-recognition
sudo systemctl start mongod

View file

@ -0,0 +1,24 @@
#!/usr/bin/env bash
start_backend() {
cd /home/ubuntu/song-recognition
touch back.txt
go build -tags netgo -ldflags '-s -w' -o app
nohup ./app > backend.log 2>&1 &
}
start_client() {
cd /home/ubuntu/song-recognition/client
touch client.txt
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"
nvm install 16
nvm use 16
npm install
npm run build
nohup serve -s build > client.log 2>&1 &
}
start_backend && start_client

33
scripts/BeforeInstall.sh Normal file
View file

@ -0,0 +1,33 @@
#!/usr/bin/env bash
sudo apt-get -y update
if [ ! -f "/home/ubuntu/install" ]; then
# install CodeDeploy agent
sudo apt-get -y install ruby
sudo apt-get -y install wget
cd /home/ubuntu
wget https://aws-codedeploy-eu-north-1.s3.amazonaws.com/latest/install
sudo chmod +x ./install
sudo ./install auto
fi
# install golang
sudo apt-get -y install golang-go
# install nodeJS, npm, and nvm
sudo apt -y install nodejs
sudo apt -y install npm
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# Install MongoDB only if not already present
if [ ! -f "/usr/bin/mongod" ]; then
sudo apt-get install gnupg curl
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
--dearmor
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo apt-get install -y mongosh
fi