Skip to content

Commit f3641e6

Browse files
Merge pull request #9 from hivetown/feat/credentialsMangement
Feat/credentials mangement
2 parents eaf9b74 + d07d9b1 commit f3641e6

File tree

12 files changed

+29
-24
lines changed

12 files changed

+29
-24
lines changed

databases/db1/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ MYSQL_PASSWORD=mybackuppassword
33
DATABASE=hivetown
44

55
INSTANCE_NAME=vm-database-1
6-
INSTANCE_ZONE=eu-west4-a
6+
INSTANCE_ZONE=europe-west4-a
77
PEER_INSTANCE_NAME=vm-database-2
8-
PEER_INSTANCE_ZONE=eu-west4-b
8+
PEER_INSTANCE_ZONE=europe-west4-b
99
ALIAS_IP=10.0.128.10
1010

1111
BACKUP_USER=romul

databases/db1/keepalived/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ STATE=MASTER
77

88
# Takeover
99
INSTANCE_NAME=vm-database-1
10-
INSTANCE_ZONE=eu-west4-a
10+
INSTANCE_ZONE=europe-west4-a
1111
PEER_INSTANCE_NAME=vm-database-2
12-
PEER_INSTANCE_ZONE=eu-west4-b
12+
PEER_INSTANCE_ZONE=europe-west4-b
1313
ALIAS_IP=10.0.128.10

load-balancers/.env.example

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,9 @@ ZOOKEEPER_HOSTS=10.0.4.2:2181
44
# HaProxy
55
HAPROXY_STATS_USERNAME=admin
66
HAPROXY_STATS_PASSWORD=password
7+
HAPROXY_DATAPLANEAPI_USERNAME=dataplaneapiuser
78
HAPROXY_DATAPLANEAPI_PASSWORD=dataplaneapipassword
89

910
# Certbot
1011
CERTBOT_EMAIL=certs@hivetown.pt
1112
CERTBOT_DOMAINS=hivetown.pt,www.hivetown.pt
12-
13-
# Keepalived
14-
UNICAST_SRC_IP=10.0.0.3
15-
UNICAST_PEER=10.0.0.2
16-
AUTH_PASS=123456
17-
STATE=MASTER
18-
HVT_PUBLIC_IP=34.90.28.85
19-
INSTANCE_NAME=loadbalancer-1
20-
INSTANCE_ZONE=eu-west4-a

load-balancers/haproxy.template.cfg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ frontend hvt-frontend from hvt-defaults
2323
acl letsencrypt-acl path_beg /.well-known/acme-challenge/
2424
use_backend letsencrypt-backend if letsencrypt-acl
2525

26+
# Redirect to https if using http
2627
http-request redirect scheme https unless { ssl_fc }
2728

2829
stats enable
@@ -35,6 +36,7 @@ frontend hvt-frontend from hvt-defaults
3536

3637
default_backend hvt-web
3738

39+
# Proxy to letsencrypt backend
3840
backend letsencrypt-backend from hvt-defaults
3941
server certbot host.docker.internal:8888
4042

@@ -52,7 +54,7 @@ backend hvt-api from hvt-defaults
5254
http-request replace-path /api(/)?(.*) /\2
5355

5456
userlist dataplane_users
55-
user admin insecure-password ${HAPROXY_DATAPLANEAPI_PASSWORD}
57+
user ${HAPROXY_DATAPLANEAPI_USERNAME} insecure-password ${HAPROXY_DATAPLANEAPI_PASSWORD}
5658

5759
program api
5860
command /usr/bin/dataplaneapi --scheme http --host 0.0.0.0 --port 4444 --haproxy-bin /usr/local/sbin/haproxy --config-file /usr/local/etc/haproxy/haproxy.cfg --reload-cmd "kill -SIGUSR2 1" --reload-delay 5 --restart-cmd "kill -SIGUSR2 1" --userlist dataplane_users --write-timeout=120s --log-to=stdout --log-level=trace

load-balancers/keepalived/.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ UNICAST_SRC_IP=10.0.0.2
44
UNICAST_PEER=10.0.0.3
55
AUTH_PASS=123456
66
STATE=MASTER
7+
PRIORITY=100
78

89
# Takeover
910
HVT_PUBLIC_IP=34.90.28.85
1011
INSTANCE_NAME=loadbalancer-1
11-
INSTANCE_ZONE=eu-west4-a
12+
INSTANCE_ZONE=europe-west4-a

load-balancers/keepalived/keepalived.template.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ vrrp_instance floating_ip {
66
${UNICAST_PEER}
77
}
88
virtual_router_id 50
9-
priority 100
9+
priority ${PRIORITY}
1010
advert_int 1
1111
authentication {
1212
auth_type PASS

load-balancers/keepalived/takeover.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
# - $HVT_PUBLIC_IP: the public IP address
44
# - $INSTANCE_NAME: the name of the host instance
55
# - $INSTANCE_ZONE: the zone of the host instance
6-
# TODO! template em vez disto
7-
. .env
6+
. /etc/keepalived/.env
87

98
# Get the instance that holds the public IP address - the one that is currently ACTIVE
109
activeInstance=`gcloud compute instances list --project hivetown | grep $HVT_PUBLIC_IP`

load-balancers/service-discovery/src/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from RepeatTimer import RepeatTimer
77
from datetime import datetime
88

9-
haproxy = Haproxy(getenv("HAPROXY_ADDRESS"), getenv("HAPROXY_USERNAME"), getenv("HAPROXY_PASSWORD"))
9+
haproxy = Haproxy(getenv("HAPROXY_ADDRESS"), getenv("HAPROXY_DATAPLANEAPI_USERNAME"), getenv("HAPROXY_DATAPLANEAPI_PASSWORD"))
1010
def applyTransaction():
1111
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
1212

web-servers/api.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
PORT=3000
12
MIKRO_ORM_HOST=10.0.128.10
23
MIKRO_ORM_PORT=3306
34
MIKRO_ORM_USER=root
45
MIKRO_ORM_PASSWORD=hello
56
MIKRO_ORM_DB_NAME=hivetown
67
MIKRO_ORM_DEBUG=false
8+
STRIPE_KEY=stripe_key
9+
STRIPE_WEBHOOK=stripe_webhook_url
10+
FRONTEND_URL=https://hivetown.pt

web-servers/docker-compose.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ services:
1313
restart: unless-stopped
1414
image: "luckspt/hivetown-web:latest"
1515
ports:
16-
- "8081:8080"
17-
environment:
18-
- "PORT=8080"
16+
- "8081:80"
17+
env_file:
18+
- web.env
19+
depends_on:
20+
- api
1921
service-discovery:
2022
depends_on:
2123
- api

web-servers/service-discovery/Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@ RUN pip install -r requirements.txt
99
# Copy the application files
1010
COPY src/ .
1111

12-
ENV ZOOKEEPER_HOSTS 10.0.0.10:2181
13-
1412
CMD ["python", "-u", "/app/index.py"]

web-servers/web.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
VITE_API_URL='https://hivetown.pt/api'
2+
VITE_FIREBASE_API_KEY='an-example-api-key'
3+
VITE_FIREBASE_AUTH_DOMAIN='some-domain.firebaseapp.com'
4+
VITE_FIREBASE_PROJECT_ID='an-example-project-id'
5+
VITE_FIREBASE_STORAGE_BUCKET='some-domain.appspot.com'
6+
VITE_FIREBASE_MESSAGING_SENDER_ID='some-sender-id'
7+
VITE_FIREBASE_APP_ID='some-app-id'

0 commit comments

Comments
 (0)