Skip to content

Commit 1ec1030

Browse files
Merge branch 'deployment' into develop
2 parents 2974e6b + bb4ce57 commit 1ec1030

53 files changed

Lines changed: 350 additions & 104 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: CI Pipeline
2+
on: [ push ]
3+
4+
jobs:
5+
build:
6+
name: Build & Test
7+
runs-on: self-hosted
8+
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v4
12+
13+
- name: Install Go
14+
uses: actions/setup-go@v5
15+
with:
16+
go-version: 1.22.7
17+
18+
- name: Build
19+
run: go build ./cmd/app/
20+
21+
- name: Test
22+
run: go test -v ./...
23+
24+
lint:
25+
name: Lint
26+
runs-on: self-hosted
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Install Go
33+
uses: actions/setup-go@v5
34+
with:
35+
go-version: 1.22.7
36+
37+
- name: golangci-lint
38+
uses: golangci/golangci-lint-action@v6
39+
with:
40+
version: v1.58
41+
args: --timeout=10m
42+
skip-cache: true
43+
44+
concurrency:
45+
group: ${{ github.workflow }}-${{ github.ref }}
46+
cancel-in-progress: true

.github/workflows/publish.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Docker Image Publish
2+
on: [ push, workflow_dispatch ]
3+
4+
jobs:
5+
push_to_registry:
6+
runs-on: self-hosted
7+
steps:
8+
- name: Checkout
9+
uses: actions/checkout@v4
10+
11+
- name: Login to DockerHub
12+
uses: docker/login-action@v3
13+
with:
14+
username: ${{ secrets.DOCKER_USERNAME }}
15+
password: ${{ secrets.DOCKER_PASSWORD }}
16+
17+
- name: Extract metadata
18+
id: meta
19+
uses: docker/metadata-action@v5
20+
with:
21+
images: uncensored/buzz
22+
23+
- name: Setup QEMU
24+
uses: docker/setup-qemu-action@v3
25+
26+
- name: Setup Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Build & Push Docker image
30+
id: push
31+
uses: docker/build-push-action@v3
32+
with:
33+
context: .
34+
file: ./Dockerfile
35+
push: true
36+
tags: ${{ steps.meta.outputs.tags }}
37+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.idea/
2-
randoms/
2+
randoms/
3+
deployment/
4+
.vagrant/

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
docker-up:
2+
docker compose up
3+
4+
start-db:
5+
docker compose up mysql_db
6+
7+
migrate-up:
8+
docker compose up mysql_db_go_migrate
9+
10+
fmt:
11+
# run gofumpt two times because it's buggy and need 2 pass
12+
@find . -type f -name '*.go' ! -path '*/.cookiecutter/*' ! -path './vendor/*' | xargs gofumpt -l -w
13+
@find . -type f -name '*.go' ! -path '*/.cookiecutter/*' ! -path './vendor/*' | xargs gofumpt -l -w

Vagrantfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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

cmd/app/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package main
33
import (
44
"context"
55
"fmt"
6-
"github.com/Uncensored-Developer/buzz/internal/server"
76
"os"
7+
8+
"github.com/Uncensored-Developer/buzz/internal/server"
89
)
910

1011
func main() {

cmd/migrate/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package main
22

33
import (
4+
"log"
5+
46
"github.com/Uncensored-Developer/buzz/pkg/config"
57
"github.com/Uncensored-Developer/buzz/pkg/logger"
68
"github.com/Uncensored-Developer/buzz/pkg/migrate"
79
"go.uber.org/zap"
8-
"log"
910
)
1011

1112
func main() {

docker-compose.yaml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff 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+
82117
volumes:
83118
mysql-data:
84119
driver: local

golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
linters:
2+
disable:
3+
- errcheck

internal/datastore/uow.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package datastore
33
import (
44
"context"
55
"database/sql"
6+
67
data2 "github.com/Uncensored-Developer/buzz/internal/matches/data"
78
"github.com/Uncensored-Developer/buzz/internal/users/data"
89
"github.com/uptrace/bun"

0 commit comments

Comments
 (0)