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

Updated Terraform code & fixed some bugs with Umami setup #6

Merged
merged 1 commit into from
Dec 15, 2023
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
7 changes: 7 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ packages:
- nginx
- certbot
- python3-certbot-nginx
- npm

# Add users to the system. Users are added after groups are added.
users:
Expand All @@ -28,6 +29,11 @@ users:

runcmd:
- /usr/bin/git clone https://github.com/dills122/backbone-infa.git backbone-src
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
- export NVM_DIR="$HOME/.nvm"
- [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
- [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
- nvm alias default lts/iron
- sudo ufw allow 'Nginx Full'
- sudo ufw deny 6379 # Lockdown redis port from the outside world
- sudo wget -O /usr/local/bin/ufw-docker https://github.com/chaifeng/ufw-docker/raw/master/ufw-docker
Expand All @@ -38,5 +44,6 @@ runcmd:
- /usr/bin/bash ./backbone-src/scripts/umami-setup.sh
- sudo systemctl restart nginx
- /usr/bin/docker update --restart unless-stopped $(docker ps -q)
- sudo echo "0 12 * * * terraform /usr/bin/certbot renew --quiet" >/etc/cron.d/certbot_renew

final_message: "The system is finally up, after $UPTIME seconds"
12 changes: 3 additions & 9 deletions droplet.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
data "template_file" "userdata" {
template = file("${path.module}/app.yaml")

vars = {
pub_key = var.ssh_public_key != "default" ? var.ssh_public_key : file(var.ssh_public_key_path)
}
}

# Setup a DO droplet
resource "digitalocean_droplet" "backbone_server_1" {
image = var.droplet_image
Expand All @@ -15,7 +7,9 @@ resource "digitalocean_droplet" "backbone_server_1" {
ssh_keys = [
var.ssh_key_fingerprint
]
user_data = data.template_file.userdata.rendered
user_data = templatefile("${path.module}/app.yaml", {
pub_key = var.ssh_public_key != "default" ? var.ssh_public_key : file(var.ssh_public_key_path)
})
}

################################################################################
Expand Down
6 changes: 3 additions & 3 deletions scripts/certbot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ domain="dsteele.dev"
umami_sub_domain="umami"
ssl_email="dylansteele57@gmail.com"

#TODO fix issue with nginx config/ cert install; cant have listen 80 and 443 in same server, certbot doesnt remove the 80
sudo rm -rf /etc/nginx/conf.d/* && sudo rm -rf /etc/nginx/sites-enabled/default
# Need to update the naming to the url of site ex. umami.dsteele.dev
sudo rm -rf /etc/nginx/conf.d/* && sudo rm -rf /etc/nginx/sites-available/*
# Copy Nginx config files
sudo cp ~/backbone-src/.docker/nginx/conf.d/prod/* /etc/nginx/sites-enabled/
sudo cp ~/backbone-src/.docker/nginx/conf.d/prod/* /etc/nginx/sites-available/

sudo nginx -t

Expand Down
7 changes: 5 additions & 2 deletions scripts/umami-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ git clone https://github.com/mikecao/umami.git

pushd umami

npm i
npm run build
sudo npm i -g yarn
yarn install
# yarn build

echo "DATABASE_URL=postgresql://main:Ba21tedao23094!@localhost:5432/mydb" >.env

docker pull ghcr.io/mikecao/umami:postgresql-latest
docker-compose up -d
Expand Down
Loading