Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# [START appengine_websockets_yaml]
runtime: nodejs
env: flex

# Use only a single instance, so that this local-memory-only chat app will work
# consistently with multiple users. To work across multiple instances, an
# extra-instance messaging system or data store would be needed.
manual_scaling:
instances: 1

# [START network]
network:
instance_tag: websocket
forwarded_ports:
- 65080
session_affinity: true
# [END network]
# [END appengine_websockets_yaml]
27 changes: 27 additions & 0 deletions docker/api/api.fifa.sauravmh.com.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
upstream socket-server-upstream {
ip_hash;
server http-api:8080;
server socketio-api:65080;
keepalive 16;
}

server {
listen 80;
server_name api.fifa.sauravmh.com;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /app;

location / {
proxy_pass http://localhost:8080/;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;

proxy_cache_bypass $http_upgrade;
proxy_hide_header X-Powered-By;
}
}
54 changes: 54 additions & 0 deletions docker/api/socker.fifa.sauravmh.com.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
upstream socket-server-upstream {
ip_hash;
server http-api:8080;
server socketio-api:65080;
keepalive 16;
}

server {
listen 443 ssl;
server_name api.mydomain.com;

include conf.d/error-pages.conf;
include conf.d/url-filter*.conf;

root /home/saurav/my_application;

location / {
proxy_pass http://localhost:3000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_hide_header X-Powered-By;
}

}

server {
listen 80;
index index.html;
server_name currently-viewing-app.dev;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /app;

location / {
try_files $uri /index.html;
}

location /socket.io/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;

proxy_pass http://socket-server-upstream/socket.io/;
proxy_redirect off;

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Empty file added shared/shared.tf
Empty file.
22 changes: 22 additions & 0 deletions terraform/dev/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions terraform/dev/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "3.5.0"
}
}
}

provider "google" {
project = var.project_name
region = var.region
zone = var.region_zone
credentials = file("${var.credentials_file_path}")
}

resource "google_compute_http_health_check" "default" {
name = "tf-www-basic-check"
request_path = "/"
check_interval_sec = 1
healthy_threshold = 1
unhealthy_threshold = 10
timeout_sec = 1
}

resource "google_compute_instance" "app_server" {
name = "fifa-server"
machine_type = "e2-small"
tags = ["ssh", "http-server", "https-server"]

metadata = {
user-data = module.container-server.cloud_config # 👈
}

service_account {
email = google_service_account.default.email
scopes = ["https://www.googleapis.com/auth/cloud-platform"]
}

boot_disk {
initialize_params {
image = data.google_compute_image.cos.self_link
}
}

network_interface {
subnetwork = var.subnet_name
subnetwork_project = var.project

access_config {
nat_ip = google_compute_address.static.address
}
}

scheduling {
automatic_restart = true
}

allow_stopping_for_update = true

lifecycle {
ignore_changes = [attached_disk]
}
}
21 changes: 21 additions & 0 deletions terraform/dev/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
variable "region" {
default = "asia-south1"
}

variable "region_zone" {
default = "asia-south1-c"
}

variable "project_name" {
description = "turn-multiplayer-game"
}

variable "credentials_file_path" {
description = "Path to the JSON file used to describe your account credentials"
default = "google-compute-engine-account.json"
}

variable "public_key_path" {
description = "Path to file containing public key"
default = "~/.ssh/gcloud_id_rsa.pub"
}