Last active
September 25, 2021 11:06
-
-
Save r4rohan/28c3e2981051e35d16058ad5117211cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"variables": { | |
"account_file": "{{ env `GOOGLE_APPLICATION_CREDENTIALS` }}" | |
}, | |
"builders": [ | |
{ | |
"type": "googlecompute", | |
"project_id": "GCP_PROJECT_ID", | |
"source_image_family": "ubuntu-2004-lts", | |
"account_file": "{{ user `account_file` }}", | |
"zone": "us-central1-a", | |
"ssh_username": "root", | |
"image_name": "portfolio-web-app-{{timestamp}}", | |
"image_description": "Web server for portfolio web app.", | |
"image_storage_locations": ["us-central1"], | |
"image_labels": { | |
"developer": "rohan", | |
"team": "cloud" | |
}, | |
"network": "packer-vpc", | |
"subnetwork": "packer-vpc", | |
"service_account_email": "packer-sa@gcp_project.iam.gserviceaccount.com" | |
} | |
], | |
"provisioners": [ | |
{ | |
"type": "shell", | |
"inline": ["mkdir -p /var/www/html"] | |
}, | |
{ | |
"type": "file", | |
"source": "public/", | |
"destination": "/var/www/html" | |
}, | |
{ | |
"type": "shell", | |
"script": "deploy.sh" | |
} | |
], | |
"post-processors": [ | |
{ | |
"type": "vagrant" | |
}, | |
{ | |
"type": "compress", | |
"output": "portfolio-web-app-vagrant.tar.gz" | |
}, | |
{ | |
"type": "googlecompute-export", | |
"paths": [ | |
"gs://gcs_bucket/portfolio-web-app-vagrant.tar.gz" | |
], | |
"keep_input_artifact": true | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
#prepare for installs | |
apt-get -f autoremove -y | |
apt-get update -y | |
apt-get upgrade -y | |
#install nginx | |
apt install nginx -y | |
#enable ufw | |
ufw allow 'Nginx HTTP' | |
ufw enable | |
#configure | |
chown -R $USER:$USER /var/www/html | |
systemctl start nginx | |
systemctl enable nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment