Minetest Deployment
This commit is contained in:
commit
68f8cad354
11 changed files with 153 additions and 0 deletions
10
config
Normal file
10
config
Normal file
|
@ -0,0 +1,10 @@
|
|||
base_system_image = "ubuntu-20-04-x64"
|
||||
region = "nyc3"
|
||||
size = "512mb"
|
||||
domain = "brandonrozek.com"
|
||||
subdomain = "minetest"
|
||||
|
||||
# Secrets
|
||||
do_token = "DO-TOKEN-HERE"
|
||||
key_name = "SSH-NAME-ON-DO-HERE"
|
||||
|
29
packer/do.pkr.hcl
Normal file
29
packer/do.pkr.hcl
Normal file
|
@ -0,0 +1,29 @@
|
|||
source "digitalocean" "web" {
|
||||
api_token = var.do_token
|
||||
image = var.base_system_image
|
||||
region = var.region
|
||||
size = var.size
|
||||
ssh_username = "root"
|
||||
snapshot_name = "packer-docker"
|
||||
}
|
||||
|
||||
|
||||
build {
|
||||
sources = [
|
||||
"source.digitalocean.web",
|
||||
]
|
||||
|
||||
provisioner "file" {
|
||||
source = "docker-compose.yml"
|
||||
destination = "/root/docker-compose.yml"
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
source = "docker-compose.service"
|
||||
destination = "/etc/systemd/system/docker-compose.service"
|
||||
}
|
||||
|
||||
provisioner "shell" {
|
||||
scripts = [ "setup.sh" ]
|
||||
}
|
||||
}
|
16
packer/docker-compose.service
Normal file
16
packer/docker-compose.service
Normal file
|
@ -0,0 +1,16 @@
|
|||
[Unit]
|
||||
Description=Docker Compose Application Service
|
||||
Requires=docker.service
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
WorkingDirectory=/root
|
||||
ExecStart=/usr/bin/docker-compose up -d
|
||||
ExecStop=/usr/bin/docker-compose down
|
||||
TimeoutStartSec=0
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
14
packer/docker-compose.yml
Normal file
14
packer/docker-compose.yml
Normal file
|
@ -0,0 +1,14 @@
|
|||
version: "2.1"
|
||||
services:
|
||||
minetest:
|
||||
image: linuxserver/minetest
|
||||
container_name: minetest
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- TZ=US/Eastern
|
||||
volumes:
|
||||
- /volumes/minetest/config/.minetest:/config/.minetest
|
||||
ports:
|
||||
- 30000:30000/udp
|
||||
restart: unless-stopped
|
13
packer/setup.sh
Executable file
13
packer/setup.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
apt update
|
||||
apt upgrade -y
|
||||
|
||||
apt install -y docker.io docker-compose
|
||||
systemctl enable docker-compose
|
||||
systemctl start docker-compose
|
||||
|
||||
ufw allow OpenSSH
|
||||
# Add any firewall rules you need
|
||||
# for your application here
|
||||
ufw allow 30000/udp
|
||||
ufw --force enable
|
1
packer/variables.auto.pkrvars.hcl
Symbolic link
1
packer/variables.auto.pkrvars.hcl
Symbolic link
|
@ -0,0 +1 @@
|
|||
../config
|
1
packer/variables.pkr.hcl
Symbolic link
1
packer/variables.pkr.hcl
Symbolic link
|
@ -0,0 +1 @@
|
|||
../variables.hcl
|
38
terraform/do.tf
Normal file
38
terraform/do.tf
Normal file
|
@ -0,0 +1,38 @@
|
|||
provider "digitalocean" {
|
||||
token = var.do_token
|
||||
}
|
||||
|
||||
data "digitalocean_ssh_key" laptop {
|
||||
name = var.key_name
|
||||
}
|
||||
|
||||
data "digitalocean_droplet_snapshot" "packer_snapshot" {
|
||||
name = "packer-docker"
|
||||
most_recent = true
|
||||
}
|
||||
|
||||
# Create a droplet
|
||||
resource "digitalocean_droplet" "web" {
|
||||
name = "tf-1"
|
||||
image = data.digitalocean_droplet_snapshot.packer_snapshot.id
|
||||
region = var.region
|
||||
size = var.size
|
||||
ssh_keys = [data.digitalocean_ssh_key.laptop.id]
|
||||
backups = false
|
||||
}
|
||||
|
||||
# Attach a subdomain
|
||||
resource "digitalocean_record" "www" {
|
||||
domain = var.domain
|
||||
type = "A"
|
||||
name = var.subdomain
|
||||
value = digitalocean_droplet.web.ipv4_address
|
||||
}
|
||||
|
||||
output "ip" {
|
||||
value = digitalocean_droplet.web.ipv4_address
|
||||
}
|
||||
|
||||
output "domain" {
|
||||
value = "${digitalocean_record.www.name}.${digitalocean_record.www.domain}"
|
||||
}
|
1
terraform/terraform.tfvars
Symbolic link
1
terraform/terraform.tfvars
Symbolic link
|
@ -0,0 +1 @@
|
|||
../config
|
1
terraform/variables.tf
Symbolic link
1
terraform/variables.tf
Symbolic link
|
@ -0,0 +1 @@
|
|||
../variables.hcl
|
29
variables.hcl
Normal file
29
variables.hcl
Normal file
|
@ -0,0 +1,29 @@
|
|||
variable "do_token" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "base_system_image" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "domain" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "key_name" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "subdomain" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "size" {
|
||||
type = string
|
||||
}
|
||||
|
||||
|
Loading…
Reference in a new issue