@australiawow/setup-dev-stack 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +19 -0
  2. package/setup-dev-stack.sh +139 -0
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@australiawow/setup-dev-stack",
3
+ "version": "1.0.0",
4
+ "description": "Automated Nginx/SSL/Docker Stack Orchestrator",
5
+ "main": "setup-dev-stack.sh",
6
+ "bin": {
7
+ "setup-dev-stack": "setup-dev-stack.sh"
8
+ },
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/nhague/setup-dev-stack.git"
15
+ },
16
+ "engines": {
17
+ "node": ">=10"
18
+ }
19
+ }
@@ -0,0 +1,139 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # --- Technical Specification ---
4
+ # Name: setup-dev-stack.sh
5
+ # Version: 7.0 (NPM/GitHub Edition)
6
+ # ----------------------------------------------------------------
7
+
8
+ # 1. Self-Elevate to sudo if not already
9
+ if [[ $EUID -ne 0 ]]; then
10
+ exec sudo "$0" "$@"
11
+ exit $?
12
+ fi
13
+
14
+ clear
15
+ echo "------------------------------------------------"
16
+ echo "🚀 SETUP-DEV-STACK: INTERACTIVE SETUP"
17
+ echo "------------------------------------------------"
18
+
19
+ # 2. Prompts
20
+ read -p "Enter Client Slug (e.g., companyx): " CLIENT
21
+ read -p "Enter Domain (e.g., companyx.com): " DOMAIN
22
+
23
+ CURRENT_DIR=$(pwd)
24
+ echo "Current folder: $CURRENT_DIR"
25
+ read -p "Is this the project root? (y/n): " IS_CURRENT
26
+
27
+ if [[ "$IS_CURRENT" == "y" || "$IS_CURRENT" == "Y" ]]; then
28
+ PROJECT_DIR=$CURRENT_DIR
29
+ else
30
+ read -p "Enter full path to project: " PROJECT_DIR
31
+ fi
32
+
33
+ # 3. Variables (Constants for your specific stack)
34
+ H_PORT=8081
35
+ K_PORT=8080
36
+ PG_PORT=5050
37
+ KONG_PORT=8000
38
+ MINIO_PORT=9000
39
+
40
+ # 4. Dependency Sync
41
+ echo "Step 1/5: Syncing Native Dependencies..."
42
+ for tool in nginx mkcert; do
43
+ command -v $tool >/dev/null 2>&1 || brew install $tool
44
+ done
45
+ mkcert -install >/dev/null 2>&1
46
+
47
+ # 5. SSL Automation
48
+ echo "Step 2/5: Automating SSL Trust..."
49
+ CERT_DIR="$HOME/certs/$CLIENT"
50
+ mkdir -p "$CERT_DIR"
51
+ mkcert -cert-file "$CERT_DIR/cert.pem" -key-file "$CERT_DIR/key.pem" \
52
+ "$DOMAIN" "*.$DOMAIN" "localhost" "127.0.0.1" >/dev/null 2>&1
53
+
54
+ # 6. DNS Spoofing
55
+ echo "Step 3/5: Updating /etc/hosts..."
56
+ sed -i '' "/$DOMAIN/d" /etc/hosts
57
+ echo "127.0.0.1 api.$DOMAIN auth.$DOMAIN console.$DOMAIN db-admin.$DOMAIN app.$DOMAIN $DOMAIN" >> /etc/hosts
58
+
59
+ # 7. Nginx Logic
60
+ echo "Step 4/5: Configuring Nginx Gateway..."
61
+ NGINX_SERVERS="/opt/homebrew/etc/nginx/servers"
62
+ cat <<EOF > "$NGINX_SERVERS/$CLIENT.conf"
63
+ server {
64
+ listen 443 ssl;
65
+ server_name api.$DOMAIN;
66
+ ssl_certificate $CERT_DIR/cert.pem;
67
+ ssl_certificate_key $CERT_DIR/key.pem;
68
+
69
+ location /graphql {
70
+ proxy_pass http://localhost:$H_PORT/v1/graphql;
71
+ proxy_http_version 1.1;
72
+ proxy_set_header Upgrade \$http_upgrade;
73
+ proxy_set_header Connection "upgrade";
74
+ proxy_set_header Host \$host;
75
+ }
76
+
77
+ location /auth {
78
+ proxy_pass http://localhost:$K_PORT/auth;
79
+ proxy_set_header Host \$host;
80
+ proxy_buffer_size 128k;
81
+ proxy_buffers 4 256k;
82
+ }
83
+
84
+ location /files {
85
+ proxy_pass http://localhost:$MINIO_PORT;
86
+ proxy_set_header Host \$host;
87
+ }
88
+
89
+ location / {
90
+ proxy_pass http://localhost:$KONG_PORT;
91
+ proxy_set_header Host \$host;
92
+ proxy_set_header X-Real-IP \$remote_addr;
93
+ proxy_set_header X-Forwarded-Proto \$scheme;
94
+ }
95
+ }
96
+
97
+ server {
98
+ listen 443 ssl;
99
+ server_name auth.$DOMAIN;
100
+ ssl_certificate $CERT_DIR/cert.pem;
101
+ ssl_certificate_key $CERT_DIR/key.pem;
102
+ location / {
103
+ proxy_pass http://localhost:$K_PORT;
104
+ proxy_set_header Host \$host;
105
+ proxy_buffer_size 128k;
106
+ proxy_buffers 4 256k;
107
+ }
108
+ }
109
+ EOF
110
+
111
+ # 8. Docker Bridge
112
+ echo "Step 5/5: Generating Docker Override..."
113
+ cat <<EOF > "$PROJECT_DIR/docker-compose.override.yml"
114
+ version: '3.8'
115
+ services:
116
+ hasura:
117
+ extra_hosts:
118
+ - "api.$DOMAIN:host.docker.internal"
119
+ - "auth.$DOMAIN:host.docker.internal"
120
+ auth-webhook:
121
+ extra_hosts:
122
+ - "auth.$DOMAIN:host.docker.internal"
123
+ kong:
124
+ extra_hosts:
125
+ - "api.$DOMAIN:host.docker.internal"
126
+ - "auth.$DOMAIN:host.docker.internal"
127
+ EOF
128
+
129
+ # Reset Ownership
130
+ REAL_USER=${SUDO_USER:-$(whoami)}
131
+ chown "$REAL_USER" "$PROJECT_DIR/docker-compose.override.yml"
132
+ chown -R "$REAL_USER" "$CERT_DIR"
133
+
134
+ # 9. Reload
135
+ /opt/homebrew/bin/nginx -t && sudo /opt/homebrew/bin/brew services restart nginx
136
+
137
+ echo "------------------------------------------------"
138
+ echo "✅ SETUP SUCCESSFUL: $DOMAIN"
139
+ echo "------------------------------------------------"