Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev4 #26

Merged
merged 26 commits into from
Dec 20, 2023
Merged

Dev4 #26

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d7e827b
TP-c01_ci-cd: add Dockerfiles for nginx and microservices, add servic…
wonderf00l Dec 5, 2023
f8ec2a3
TP-c01_ci-cd: changed prometheus targets, servers addresses from loca…
wonderf00l Dec 5, 2023
f862979
TP-c01_ci-cd: add linter configuration
wonderf00l Dec 7, 2023
ea75fda
TP-c01_ci-cd: add named volumes for postgres and redis, add compose.p…
wonderf00l Dec 7, 2023
6c8a215
TP-c01_ci-cd: add workflows description, add configuration file for a…
wonderf00l Dec 7, 2023
7318fe6
TP-c01_ci-cd: add kafka healthcheck
wonderf00l Dec 8, 2023
eaa7ece
TP-c01_ci-cd: deleted nginx config from compose.yml, changed triggers…
wonderf00l Dec 8, 2023
8d07119
TP-c01_ci-cd: deleted dev3 from triggers
wonderf00l Dec 9, 2023
df49eed
TP-c01_ci-cd: changed triggers, add step
wonderf00l Dec 9, 2023
24e85bd
TP-6ec_easyjson: generated easyjson, changed serialization for user, …
wonderf00l Dec 13, 2023
ea2a4d0
TP-8da update: returned user from and to when deleting message
Gvidow Dec 17, 2023
5fcf9c3
Merge pull request #22 from go-park-mail-ru/TP-6ec_easyjson
Gvidow Dec 19, 2023
1c0e335
Merge branch 'dev4' into TP-c01_ci-cd
Gvidow Dec 19, 2023
d63df1b
Update websocket.go: delete unused package "os"
Gvidow Dec 19, 2023
cd3b116
Merge pull request #23 from go-park-mail-ru/TP-c01_ci-cd
Gvidow Dec 19, 2023
2d1c6d2
TP-6ec_easyjson: add rest easyjson
wonderf00l Dec 19, 2023
fab4cf5
Merge pull request #24 from go-park-mail-ru/TP-6ec_easyjson
wonderf00l Dec 19, 2023
febce68
dev4: removed pull request trigger for deploy workflow
wonderf00l Dec 19, 2023
e3d1477
dev4: replaced auth service host:port string with env variables, move…
wonderf00l Dec 19, 2023
0170995
TP-87a_filtration: add filtration of pin content
wonderf00l Dec 19, 2023
ff13346
TP-87a_filtration: add task with cloud api token provision, add '2023…
wonderf00l Dec 19, 2023
1b8f327
Merge pull request #25 from go-park-mail-ru/TP-87a_filtration
wonderf00l Dec 19, 2023
6311811
dev4: replaced google vision client with image filter interface
wonderf00l Dec 20, 2023
e4dc478
de4: changed deployment branch, add cloud api token to the .env file
wonderf00l Dec 20, 2023
cae7718
dev4: add images volume for main service container
wonderf00l Dec 20, 2023
e71947b
dev4: changed makefile variable, included all branches in CI
wonderf00l Dec 20, 2023
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
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Start pinspire CI

on:
workflow_dispatch: {}
push: {}
pull_request:
types: [opened, edited, reopened]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Get repository code
uses: actions/checkout@v4
- name: Test application
continue-on-error: true
run: go test ./...
lint:
runs-on: ubuntu-latest
steps:
- name: Get repository code
uses: actions/checkout@v4
- name: Lint application
run: make lint
build:
runs-on: ubuntu-latest
steps:
- name: Get repository code
uses: actions/checkout@v4
- name: Build application
run: make build_all
58 changes: 58 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Start Pinspire deployment

on:
workflow_dispatch: {}
push:
branches:
- main
- dev4

jobs:
build_images:
runs-on: ubuntu-latest
steps:
- name: get repository code
uses: actions/checkout@v4
- name: Login to DockerHub Registry
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Build docker images of services
run: |
docker build -t pinspireapp/main:latest -f deployments/Dockerfile.main . &
docker build -t pinspireapp/auth:latest -f deployments/Dockerfile.auth . &
docker build -t pinspireapp/realtime:latest -f deployments/Dockerfile.realtime . &
docker build -t pinspireapp/messenger:latest -f deployments/Dockerfile.messenger . &
for p in $(jobs -p); do wait "$p" || { echo "job $p failed" >&2; exit; }; done
- name: Push docker images
run: |
docker push pinspireapp/main:latest &
docker push pinspireapp/auth:latest &
docker push pinspireapp/realtime:latest &
docker push pinspireapp/messenger:latest &
for p in $(jobs -p); do wait "$p" || { echo "job $p failed" >&2; exit; }; done

deploy:
runs-on: ubuntu-latest
needs: build_images
steps:
- name: fetch changes
uses: appleboy/ssh-action@master
with:
host: pinspire.online
username: ${{ secrets.REMOTE_USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
cd ${{ secrets.PINSPIRE_BACKEND_PATH }}
sudo git switch dev4
sudo git pull
- name: deploy application
uses: appleboy/ssh-action@master
with:
host: pinspire.online
username: ${{ secrets.REMOTE_USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
cd ${{ secrets.PINSPIRE_BACKEND_PATH }}/deployments
sudo docker compose down main_service auth_service realtime_service messenger_service
sudo docker rmi pinspireapp/main:latest pinspireapp/auth:latest pinspireapp/realtime:latest pinspireapp/messenger:latest
sudo docker compose -f docker-compose.yml -f compose.prod.yml up -d

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ testdata/
cert/
.env
redis.conf
inventory
keyVision.json
script*
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
.PHONY: build run test test_with_coverage cleantest retest doc generate cover_all currcover
.PHONY: build_auth build_realtime build_messenger
.PHONY: build_auth build_realtime build_messenger build_all
.PHONY: .install-linter lint lint-fast

ENTRYPOINT=cmd/app/main.go
DOC_DIR=./docs
COV_OUT=coverage.out
COV_HTML=coverage.html
CURRCOVER=github.com/go-park-mail-ru/2023_2_OND_team/internal/pkg/delivery/http/v1

PROJECT_BIN = $(CURDIR)/bin
$(shell [ -f bin ] || mkdir -p $(PROJECT_BIN))
GOLANGCI_LINT = $(PROJECT_BIN)/golangci-lint

build:
go build -o bin/app cmd/app/*.go

Expand All @@ -19,6 +24,8 @@ build_realtime:
build_messenger:
go build -o bin/messenger cmd/messenger/*.go

build_all: build build_auth build_realtime build_messenger

run: build
./bin/app

Expand Down Expand Up @@ -51,3 +58,11 @@ currcover:
go test -cover -v -coverprofile=cover.out ${CURRCOVER}
go tool cover -html=cover.out -o cover.html

.install-linter:
[ -f $(PROJECT_BIN)/golangci-lint ] || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_BIN) v1.55.2

lint: .install-linter
$(GOLANGCI_LINT) run ./... --config=configs/.golangci.yml

lint-fast: .install-linter
$(GOLANGCI_LINT) run ./... --fast --config=configs/.golangci.yml
8 changes: 0 additions & 8 deletions cmd/app/config.go

This file was deleted.

7 changes: 7 additions & 0 deletions cmd/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"context"
"flag"
"fmt"
"os"

"github.com/go-park-mail-ru/2023_2_OND_team/internal/app"
"github.com/go-park-mail-ru/2023_2_OND_team/pkg/logger"
"github.com/joho/godotenv"
)

var (
Expand All @@ -27,6 +29,7 @@ var (
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html

func main() {
godotenv.Load()
flag.Parse()
ctxBase, cancel := context.WithCancel(context.Background())
defer cancel()
Expand All @@ -42,5 +45,9 @@ func main() {
}
defer log.Sync()

configFiles := app.ConfigFiles{
ServerConfigFile: "configs/config.yml",
AddrAuthServer: os.Getenv("AUTH_SERVICE_HOST") + ":" + os.Getenv("AUTH_SERVICE_PORT"), // "localhost:8085",
}
app.Run(ctxBase, log, configFiles)
}
2 changes: 1 addition & 1 deletion cmd/auth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package main
import "github.com/go-park-mail-ru/2023_2_OND_team/internal/app/auth"

var configAuth = auth.Config{
Addr: "localhost:8085",
Addr: "0.0.0.0:8085",
RedisFileConfig: "redis.conf",
}
4 changes: 3 additions & 1 deletion cmd/realtime/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import (
grpcMetrics "github.com/go-park-mail-ru/2023_2_OND_team/internal/pkg/metrics/grpc"
"github.com/go-park-mail-ru/2023_2_OND_team/internal/pkg/middleware/grpc/interceptor"
"github.com/go-park-mail-ru/2023_2_OND_team/pkg/logger"
"github.com/joho/godotenv"
)

const _address = "localhost:8090"
const _address = "0.0.0.0:8090"

func main() {
godotenv.Load()
log, err := logger.New()
if err != nil {
fmt.Println(err)
Expand Down
Loading
Loading