feat: publish script and cleanup
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
.gitignore
|
||||
.dockerignore
|
||||
Dockerfile
|
||||
|
||||
**/plugged
|
||||
**/completions
|
||||
**/conf.d
|
||||
**/fish_variables
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -8,11 +8,7 @@
|
||||
**/known_hosts*
|
||||
|
||||
# setup files
|
||||
**/plugged
|
||||
**/autoload
|
||||
**/completions
|
||||
**/conf.d
|
||||
**/fish_variables
|
||||
**/gcloud
|
||||
**/coc
|
||||
**/configstore
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# andrejusk/dotfiles
|
||||
# dots.andrejus.dev
|
||||
|
||||
Collection of experimental dotfiles and supporting install scripts.
|
||||
|
||||
## Install
|
||||
|
||||
wget https://raw.githubusercontent.com/andrejusk/dotfiles/master/scripts/setup.sh -qO - | bash
|
||||
wget https://dots.andrejus.dev/setup.sh -qO - | bash
|
||||
|
||||
## Stack
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# env:
|
||||
# TERM: xterm-256color
|
||||
env:
|
||||
TERM: xterm-256color
|
||||
|
||||
window:
|
||||
dynamic_title: true
|
||||
|
||||
5
files/home/.config/fish/.gitignore
vendored
5
files/home/.config/fish/.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
functions
|
||||
!functions/nvm.fish
|
||||
completions
|
||||
conf.d
|
||||
fish_variables
|
||||
|
||||
@@ -4,3 +4,4 @@ jorgebucaran/replay.fish
|
||||
joseluisq/gitnow
|
||||
tomyun/base16-fish
|
||||
PatrickF1/fzf.fish
|
||||
jorgebucaran/fisher
|
||||
|
||||
1
files/home/.config/nvim/.gitignore
vendored
Normal file
1
files/home/.config/nvim/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
plugged
|
||||
@@ -48,13 +48,6 @@ export YARN_DIR=${YARN_DIR:-"$HOME/.yarn"}
|
||||
mkdir -p "$YARN_DIR"
|
||||
export PATH="$YARN_DIR/bin:$PATH"
|
||||
|
||||
# fzf
|
||||
export FZF_DEFAULT_OPTS="--reverse"
|
||||
export FZF_DEFAULT_COMMAND='fdfind --type f --hidden --follow --exclude .git'
|
||||
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
|
||||
export FZF_COMPLETION_TRIGGER='**'
|
||||
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
|
||||
|
||||
# z (jump around)
|
||||
export Z_DATA_DIR=${Z_DATA:-"$XDG_DATA_HOME/z"}
|
||||
export Z_DATA=${Z_DATA:-"$Z_DATA_DIR/data"}
|
||||
@@ -74,3 +67,4 @@ fi
|
||||
# (__) (__)(_")("_)\_)-' '-(_/(__) (__)(__)
|
||||
#
|
||||
alias j="z"
|
||||
alias fd=`which fdfind`
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
poetry --version
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
java --version
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
if [ ! -d ~/.emacs.d ]; then
|
||||
echo "Cloning spacemacs"
|
||||
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
|
||||
fi
|
||||
|
||||
@@ -3,9 +3,11 @@ docker --version
|
||||
|
||||
readonly docker_group="docker"
|
||||
if ! grep -q "$docker_group" /etc/group; then
|
||||
echo "Adding docker group"
|
||||
sudo groupadd "$docker_group"
|
||||
fi
|
||||
|
||||
if ! groups "$USER" | grep -q "\b$docker_group\b"; then
|
||||
echo "Adding user to docker group"
|
||||
sudo usermod -aG docker "$USER"
|
||||
fi
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
gcloud --version
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
firebase --version
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
aws --version
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
terraform --version
|
||||
@@ -51,6 +51,7 @@
|
||||
"fish",
|
||||
"fonts-nanum",
|
||||
"fortune-mod",
|
||||
"fzf",
|
||||
"google-cloud-sdk",
|
||||
"git",
|
||||
"kubectl",
|
||||
|
||||
11
scripts/publish.sh
Normal file → Executable file
11
scripts/publish.sh
Normal file → Executable file
@@ -1,8 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
|
||||
#
|
||||
# Script that publishes the set up script for new installations.
|
||||
#
|
||||
BUCKET=${BUCKET:-"dots.andrejus.dev"}
|
||||
|
||||
echo "Publishing..."
|
||||
NAME=$(basename "$0")
|
||||
REL_DIR=$(dirname "$0")
|
||||
ABS_DIR=$(readlink -f $REL_DIR/../) # Scripts are nested inside of /scripts
|
||||
|
||||
# Publish setup script to public bucket
|
||||
gsutil cp "$ABS_DIR/scripts/setup.sh" "gs://$BUCKET/setup.sh"
|
||||
|
||||
@@ -15,7 +15,7 @@ setup_dir=${DOTFILES_DIR:-$HOME/.dotfiles}
|
||||
|
||||
# Prevent overwriting existing installation
|
||||
mkdir -p $setup_dir
|
||||
if [ -z `ls -A $setup_dir` ]; then
|
||||
if [[ -z $(ls -A $setup_dir) ]]; then
|
||||
echo "Setting up $setup_dir"
|
||||
else
|
||||
echo "Failed: Setup directory not empty $setup_dir"
|
||||
|
||||
@@ -1,36 +1,112 @@
|
||||
# Static bucket
|
||||
locals {
|
||||
fqdn = "${var.domain}."
|
||||
}
|
||||
|
||||
# =================================================================
|
||||
# Public bucket for static content
|
||||
# =================================================================
|
||||
resource "google_project_service" "storage" {
|
||||
service = "storage.googleapis.com"
|
||||
}
|
||||
|
||||
resource "google_storage_bucket" "bucket" {
|
||||
provider = google-beta
|
||||
|
||||
project = var.project
|
||||
|
||||
name = var.domain
|
||||
location = "EU"
|
||||
storage_class = "MULTI_REGIONAL"
|
||||
depends_on = [google_project_service.storage]
|
||||
|
||||
versioning {
|
||||
enabled = var.enable_versioning
|
||||
}
|
||||
location = var.gcs_location
|
||||
}
|
||||
|
||||
# Allow public read
|
||||
resource "google_storage_default_object_acl" "bucket_acl" {
|
||||
provider = google-beta
|
||||
resource "google_storage_default_object_access_control" "bucket_public" {
|
||||
bucket = google_storage_bucket.bucket.name
|
||||
role_entity = ["READER:allUsers"]
|
||||
role = "READER"
|
||||
entity = "allUsers"
|
||||
}
|
||||
|
||||
# DNS entry
|
||||
resource "google_dns_record_set" "cname" {
|
||||
provider = google-beta
|
||||
|
||||
depends_on = [google_storage_bucket.bucket]
|
||||
# =================================================================
|
||||
# Expose bucket via HTTPS using Cloud CDN
|
||||
#
|
||||
# Adapted from
|
||||
# https://medium.com/cognite/configuring-google-cloud-cdn-with-terraform-ab65bb0456a9
|
||||
# =================================================================
|
||||
resource "google_project_service" "compute" {
|
||||
service = "compute.googleapis.com"
|
||||
}
|
||||
|
||||
project = var.project
|
||||
resource "google_compute_backend_bucket" "backend" {
|
||||
name = "${var.prefix}-backend"
|
||||
depends_on = [google_project_service.compute]
|
||||
|
||||
name = "${var.domain}."
|
||||
bucket_name = google_storage_bucket.bucket.name
|
||||
description = "Bucket backend for serving static content through CDN"
|
||||
enable_cdn = true
|
||||
}
|
||||
|
||||
resource "google_compute_url_map" "urlmap" {
|
||||
name = "${var.prefix}-urlmap"
|
||||
description = "URL map to bucket backend service"
|
||||
default_service = google_compute_backend_bucket.backend.self_link
|
||||
}
|
||||
|
||||
resource "google_compute_managed_ssl_certificate" "certificate" {
|
||||
name = "${var.prefix}-certificate"
|
||||
depends_on = [google_project_service.compute]
|
||||
|
||||
managed {
|
||||
domains = [local.fqdn]
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_target_https_proxy" "https" {
|
||||
name = "${var.prefix}-https-proxy"
|
||||
url_map = google_compute_url_map.urlmap.self_link
|
||||
ssl_certificates = [google_compute_managed_ssl_certificate.certificate.self_link]
|
||||
}
|
||||
|
||||
resource "google_compute_global_address" "ipv4" {
|
||||
name = "${var.prefix}-ipv4"
|
||||
depends_on = [google_project_service.compute]
|
||||
|
||||
ip_version = "IPV4"
|
||||
address_type = "EXTERNAL"
|
||||
}
|
||||
|
||||
resource "google_compute_global_address" "ipv6" {
|
||||
name = "${var.prefix}-ipv6"
|
||||
depends_on = [google_project_service.compute]
|
||||
|
||||
ip_version = "IPV6"
|
||||
address_type = "EXTERNAL"
|
||||
}
|
||||
|
||||
resource "google_compute_global_forwarding_rule" "fwd_ipv4" {
|
||||
name = "${var.prefix}-fwd-ipv4"
|
||||
target = google_compute_target_https_proxy.https.self_link
|
||||
ip_address = google_compute_global_address.ipv4.address
|
||||
port_range = "443"
|
||||
}
|
||||
|
||||
resource "google_compute_global_forwarding_rule" "fwd_ipv6" {
|
||||
name = "${var.prefix}-fwd-ipv6"
|
||||
target = google_compute_target_https_proxy.https.self_link
|
||||
ip_address = google_compute_global_address.ipv6.address
|
||||
port_range = "443"
|
||||
}
|
||||
|
||||
resource "google_dns_record_set" "dns_a_record" {
|
||||
name = local.fqdn
|
||||
managed_zone = var.dns_zone
|
||||
type = "CNAME"
|
||||
ttl = 300
|
||||
rrdatas = ["c.storage.googleapis.com."]
|
||||
|
||||
type = "A"
|
||||
ttl = var.dns_ttl
|
||||
rrdatas = [google_compute_global_address.ipv4.address]
|
||||
}
|
||||
|
||||
resource "google_dns_record_set" "dns_aaaa_record" {
|
||||
name = local.fqdn
|
||||
managed_zone = var.dns_zone
|
||||
|
||||
type = "AAAA"
|
||||
ttl = var.dns_ttl
|
||||
rrdatas = [google_compute_global_address.ipv6.address]
|
||||
}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
variable "prefix" {
|
||||
description = "Resource prefix"
|
||||
default = "dots"
|
||||
}
|
||||
|
||||
variable "project" {
|
||||
description = "Google Cloud project to host resources in"
|
||||
type = string
|
||||
@@ -12,3 +17,15 @@ variable "dns_zone" {
|
||||
description = "Cloud DNS zone to use"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "gcs_location" {
|
||||
type = string
|
||||
description = "Google Stoage location to provision resources in"
|
||||
default = "EU" # Multi-region, Europe
|
||||
}
|
||||
|
||||
variable "dns_ttl" {
|
||||
type = number
|
||||
description = "DNS TTL to use for records"
|
||||
default = 3600
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user