File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11.idea /
2- randoms /
2+ randoms /
3+ deployment /
4+ .vagrant /
Original file line number Diff line number Diff line change 1+ Vagrant . configure ( "2" ) do |config |
2+ config . vm . box = "hashicorp/bionic64"
3+
4+ config . vm . synced_folder "." , "/home/vagrant/app"
5+
6+ config . vm . provision :shell , path : "vagrant_setup_dep.sh"
7+
8+ config . vm . provision :shell , inline : <<-SHELL
9+ sudo su - vagrant -c "cd /home/vagrant/app && make docker-up"
10+ SHELL
11+
12+ config . vm . network "forwarded_port" , guest : 8007 , host : 8004
13+ end
Original file line number Diff line number Diff line change @@ -54,8 +54,7 @@ services:
5454 networks :
5555 - buzz_network
5656
57- api :
58- container_name : buzz
57+ api_1 :
5958 restart : always
6059 build :
6160 context : .
@@ -79,6 +78,42 @@ services:
7978 networks :
8079 - buzz_network
8180
81+ api_2 :
82+ restart : always
83+ build :
84+ context : .
85+ dockerfile : Dockerfile
86+ ports :
87+ - " 8004:8004"
88+ depends_on :
89+ - mysql_db
90+ - mysql_db_go_migrate
91+ - redis
92+ environment :
93+ - BUZZ_HTTP_HOST=0.0.0.0
94+ - BUZZ_HTTP_PORT=8003
95+ - BUZZ_DEBUG=true
96+ - BUZZ_DATABASE_URL=mysql://user:password@mysql_db:3306/buzz
97+ - BUZZ_REDIS_URL=redis://redis:6379
98+ - BUZZ_JWT_KEY=wTkjqFUqqDpUGinAJqHZ
99+ - BUZZ_PASSWORD_HASHER_SALT=wTkjqFUqqDpUGinAJqHZ
100+ - BUZZ_FAKE_USER_PASSWORD=password123
101+ - BUZZ_SEED_USERS=true
102+ networks :
103+ - buzz_network
104+
105+ load_balancer :
106+ image : nginx:alpine
107+ depends_on :
108+ - api_1
109+ - api_2
110+ ports :
111+ - " 8007:80"
112+ volumes :
113+ - ./nginx/load_balancer.conf:/etc/nginx/conf.d/default.conf:ro
114+ networks :
115+ - buzz_network
116+
82117volumes :
83118 mysql-data :
84119 driver : local
Original file line number Diff line number Diff line change 1+ upstream backend_app {
2+ server api_1:8003;
3+ server api_2:8004;
4+ }
5+
6+ server {
7+ listen 80;
8+ server_name buzz.app;
9+
10+ location / {
11+ proxy_pass http://backend_app;
12+ proxy_set_header Host $host;
13+ proxy_set_header X-Real-IP $remote_addr;
14+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -e
4+
5+ # Update package lists
6+ sudo apt-get update -y
7+
8+ # Install required packages
9+ sudo apt-get install -y \
10+ apt-transport-https \
11+ ca-certificates \
12+ curl \
13+ gnupg \
14+ lsb-release \
15+ make
16+
17+ # Add Docker’s official GPG key
18+ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor \
19+ -o /usr/share/keyrings/docker-archive-keyring.gpg
20+
21+ # Set up the stable repository
22+ echo \
23+ " deb [arch=$( dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \
24+ https://download.docker.com/linux/ubuntu \
25+ $( lsb_release -cs) \
26+ stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
27+
28+ # Install Docker Engine
29+ sudo apt-get update -y
30+ sudo apt-get install -y docker-ce docker-ce-cli containerd.io
31+
32+ # Install Docker Compose plugin (official CLI plugin approach)
33+ sudo apt-get install -y docker-compose-plugin
34+
35+ # Optionally add the 'vagrant' user to the 'docker' group for non-root docker usage
36+ sudo usermod -aG docker vagrant
37+
38+ echo " Docker and Docker Compose installed successfully!"
You can’t perform that action at this time.
0 commit comments