Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connect frontend to ec2 container #34

Merged
merged 1 commit into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions deploy/ec2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ resource "aws_instance" "jukebox_server" {
JWT_SECRET_KEY = var.SERVER__JWT_SECRET_KEY
TOKEN_HEADER_KEY = var.SERVER__TOKEN_HEADER_KEY
MONGO_URI = "mongodb://${var.DB__MONGO_USER}:${var.DB__MONGO_PASSWORD}@mongodb:27017"
SP_ID = var.SERVER__SP_ID
SP_SECRET = var.SERVER__SP_SECRET
SP_ID = var.SERVER__SPOTIFY_CLIENT_ID
SP_SECRET = var.SERVER__SPOTIFY_CLIENT_SECRET
MONGO_USER = var.DB__MONGO_USER
MONGO_PASSWORD = var.DB__MONGO_PASSWORD
} })
Expand Down
8 changes: 8 additions & 0 deletions deploy/sample.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ssh_key_name = "some_key"

SERVER__JWT_SECRET_KEY = "very_long_secret_key"
SPOTIFY_CLIENT_ID="changeme"
SPOTIFY_CLIENT_SECRET="supersecret"

DB__MONGO_USER = "root"
DB__MONGO_PASSWORD = "password"
24 changes: 16 additions & 8 deletions deploy/templates/ec2/server-setup.sh.tpl
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
#!/bin/bash
set -e
set -e # Exit if a command yields a non-zero exit code

# Update yum and install Docker onto the EC2 server
sudo yum update -y
sudo yum install -y docker

# Start up Docker
sudo service docker start
sudo chkconfig docker on # auto restart docker

# sudo systemctl enable docker.service
# sudo systemctl start docker.service

# Install Docker Compose
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

sudo usermod -aG docker ec2-user # Add user to "docker" group for permissions

# cd ~

# Install git
sudo yum install -y git
git clone https://github.com/ufosc/Jukebox-Server.git /home/ec2-user/Jukebox-Server

# Jukebox-Server Configuration ========================
git clone https://github.com/ufosc/Jukebox-Server.git /home/ec2-user/Jukebox-Server
echo "# Environment Variables, created by terraform on $(date)" > /home/ec2-user/Jukebox-Server/.env

%{ for env_key, env_value in env }
echo "${env_key}=${env_value}" >> /home/ec2-user/Jukebox-Server/.env
%{ endfor ~}


sudo docker-compose -f /home/ec2-user/Jukebox-Server/docker-compose.prod.yml up -d --build

# Jukebox-Frontend Configuration ======================
git clone https://github.com/ufosc/Jukebox-Frontend.git /home/ec2-user/Jukebox-Frontend
sudo docker-compose -f /home/ec2-user/Jukebox-Frontend/docker-compose.network.yml run --rm client sh -c "npm run build" --build




4 changes: 2 additions & 2 deletions deploy/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ variable "SERVER__TOKEN_HEADER_KEY" {
default = "Authorization"
}
#
variable "SERVER__SP_ID" {
variable "SERVER__SPOTIFY_CLIENT_ID" {
description = "Spotify App ID"
}
variable "SERVER__SP_SECRET" {
variable "SERVER__SPOTIFY_CLIENT_SECRET" {
description = "Spotify App Secret"
}

Expand Down
4 changes: 3 additions & 1 deletion proxy/default.conf.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ server {
location / {
root /vol/client;
index index.html index.htm;

# try_files $uri $uri/ index.html;
error_page 404 =200 /index.html;
}

error_page 404 =200 index.html;
}