Add domain variable to cloud-init and fix PROJECT_NAME references
This commit is contained in:
parent
dd40b38b99
commit
e1633a041f
2 changed files with 11 additions and 7 deletions
|
|
@ -18,14 +18,17 @@ apt-get install -y nodejs
|
||||||
|
|
||||||
# Create directories
|
# Create directories
|
||||||
mkdir -p /opt/contact-api
|
mkdir -p /opt/contact-api
|
||||||
mkdir -p /var/www/${PROJECT_NAME}
|
mkdir -p /var/www/${project_name}
|
||||||
mkdir -p /var/www/${PROJECT_NAME}/css
|
mkdir -p /var/www/${project_name}/css
|
||||||
mkdir -p /var/www/${PROJECT_NAME}/js
|
mkdir -p /var/www/${project_name}/js
|
||||||
|
|
||||||
|
# Set domain variable
|
||||||
|
DOMAIN=${DOMAIN}
|
||||||
|
|
||||||
# Set up nginx configuration
|
# Set up nginx configuration
|
||||||
cat << 'EOF' > /etc/nginx/sites-available/${PROJECT_NAME}
|
cat << 'EOF' > /etc/nginx/sites-available/${project_name}
|
||||||
server {
|
server {
|
||||||
root /var/www/${PROJECT_NAME};
|
root /var/www/${project_name};
|
||||||
index index.html;
|
index index.html;
|
||||||
server_name ${DOMAIN} www.${DOMAIN};
|
server_name ${DOMAIN} www.${DOMAIN};
|
||||||
|
|
||||||
|
|
@ -62,7 +65,7 @@ server {
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Symlink nginx config
|
# Symlink nginx config
|
||||||
ln -sf /etc/nginx/sites-available/${PROJECT_NAME} /etc/nginx/sites-enabled/${PROJECT_NAME}
|
ln -sf /etc/nginx/sites-available/${project_name} /etc/nginx/sites-enabled/${project_name}
|
||||||
|
|
||||||
# Remove default nginx site
|
# Remove default nginx site
|
||||||
rm -f /etc/nginx/sites-enabled/default
|
rm -f /etc/nginx/sites-enabled/default
|
||||||
|
|
@ -130,7 +133,7 @@ npm install
|
||||||
|
|
||||||
# Set permissions
|
# Set permissions
|
||||||
chown -R www-data:www-data /opt/contact-api
|
chown -R www-data:www-data /opt/contact-api
|
||||||
chown -R www-data:www-data /var/www/${PROJECT_NAME}
|
chown -R www-data:www-data /var/www/${project_name}
|
||||||
|
|
||||||
# Start contact-api
|
# Start contact-api
|
||||||
systemctl start contact-api.service
|
systemctl start contact-api.service
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ resource "hcloud_server" "krustyplanet" {
|
||||||
user_data = templatefile("${path.module}/cloud-init.yaml.tpl", {
|
user_data = templatefile("${path.module}/cloud-init.yaml.tpl", {
|
||||||
project_name = var.project_name
|
project_name = var.project_name
|
||||||
node_version = var.node_version
|
node_version = var.node_version
|
||||||
|
domain = var.domain
|
||||||
})
|
})
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue