deployment
This commit is contained in:
parent
d76b8326a0
commit
e46aaa31bc
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
FROM alpine
|
||||||
|
ADD heruvym /
|
||||||
|
ENV APP_ADDR=:1488
|
||||||
|
ENV BB_MONGO_URI=mongodb://mongodb
|
||||||
|
ENV MINIO_ENDPOINT=minio:9001
|
||||||
|
RUN apk add --no-cache ca-certificates
|
||||||
|
CMD ["/heruvym"]
|
28
Makefile
Normal file
28
Makefile
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
GOCMD=go
|
||||||
|
GOBUILD=$(GOCMD) build
|
||||||
|
GOCLEAN=$(GOCMD) clean
|
||||||
|
GOTEST=$(GOCMD) test
|
||||||
|
RELEASE?=$(git tag)
|
||||||
|
COMMIT?=$(shell git rev-parse --short HEAD)
|
||||||
|
BUILD_TIME?=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
|
||||||
|
PROJECT?=bitbucket.org/skeri/heruvym
|
||||||
|
GOOS?=linux
|
||||||
|
GOARCH?=amd64
|
||||||
|
BINARY_NAME=heruvym
|
||||||
|
PORT?=1488
|
||||||
|
|
||||||
|
all: build run
|
||||||
|
clean:
|
||||||
|
$(GOCLEAN)
|
||||||
|
rm -f $(BINARY_NAME)
|
||||||
|
build: clean
|
||||||
|
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} $(GOBUILD) \
|
||||||
|
-ldflags "-s -w -X ${PROJECT}/version.Release=${RELEASE} \
|
||||||
|
-X ${PROJECT}/version.Commit=${COMMIT} -X ${PROJECT}/version.BuildTime=${BUILD_TIME}" \
|
||||||
|
-o ${BINARY_NAME}
|
||||||
|
container: build
|
||||||
|
docker build -t $(BINARY_NAME):$(RELEASE) .
|
||||||
|
#run: container
|
||||||
|
# docker stop $(BINARY_NAME):$(RELEASE) || true && docker rm $(BINARY_NAME):$(RELEASE)
|
||||||
|
test:
|
||||||
|
$(GOTEST) -v -race ./...
|
192
README.md
192
README.md
@ -1,45 +1,179 @@
|
|||||||
**Edit a file, create a new file, and clone from Bitbucket in under 2 minutes**
|
# Heruvym
|
||||||
|
|
||||||
When you're done, you can delete the content in this README and update the file with details for others getting started with your repository.
|
/create - метод для создания тикета.
|
||||||
|
Тело запроса
|
||||||
|
{
|
||||||
|
Title string `json:"Title"` // заголовок тикета
|
||||||
|
Message string `json:"Message"` // текст первого сообщения для начала тикета
|
||||||
|
}
|
||||||
|
|
||||||
*We recommend that you open this README in another tab as you perform the tasks below. You can [watch our video](https://youtu.be/0ocf7u76WSo) for a full demo of all the steps in this tutorial. Open the video in a new tab to avoid leaving Bitbucket.*
|
тело ответа
|
||||||
|
{
|
||||||
|
Ticket: {
|
||||||
|
ID string `bson:"_id"`
|
||||||
|
UserID string `bson:"UserID"`
|
||||||
|
SessionID string `bson:"SessionID"`
|
||||||
|
AnswererID string `bson:"AnswererID"`
|
||||||
|
|
||||||
---
|
State string `bson:"State"`
|
||||||
|
TopMessage: {
|
||||||
|
ID string `bson:"_id" json:"id"`
|
||||||
|
TicketID string `bson:"TicketID" json:"ticket_id"`
|
||||||
|
UserID string `bson:"UserID" json:"user_id"`
|
||||||
|
SessionID string `bson:"SessionID" json:"session_id"`
|
||||||
|
|
||||||
## Edit a file
|
Message string `bson:"Message" json:"message"`
|
||||||
|
Files []string `bson:"Files" json:"files"`
|
||||||
|
Shown map[string]int `bson:"Shown" json:"shown"`
|
||||||
|
|
||||||
You’ll start by editing this README file to learn how to edit a file in Bitbucket.
|
CreatedAt time.Time `bson:"CreatedAt" json:"created_at"`
|
||||||
|
}
|
||||||
|
|
||||||
1. Click **Source** on the left side.
|
Title string `bson:"Title"`
|
||||||
2. Click the README.md link from the list of files.
|
|
||||||
3. Click the **Edit** button.
|
|
||||||
4. Delete the following text: *Delete this line to make a change to the README from Bitbucket.*
|
|
||||||
5. After making your change, click **Commit** and then **Commit** again in the dialog. The commit page will open and you’ll see the change you just made.
|
|
||||||
6. Go back to the **Source** page.
|
|
||||||
|
|
||||||
---
|
CreatedAt time.Time `bson:"CreatedAt"`
|
||||||
|
UpdatedAt time.Time `bson:"UpdatedAt"`
|
||||||
|
|
||||||
## Create a file
|
Rate int `bson:"Rate"`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Next, you’ll add a new file to this repository.
|
/subscribe - sse метод для подписывания на изменения по всех тикетах доступных пользователю.
|
||||||
|
тело ответа
|
||||||
|
Ticket: {
|
||||||
|
ID string `bson:"_id"`
|
||||||
|
UserID string `bson:"UserID"`
|
||||||
|
SessionID string `bson:"SessionID"`
|
||||||
|
AnswererID string `bson:"AnswererID"`
|
||||||
|
|
||||||
1. Click the **New file** button at the top of the **Source** page.
|
State string `bson:"State"`
|
||||||
2. Give the file a filename of **contributors.txt**.
|
TopMessage: {
|
||||||
3. Enter your name in the empty file space.
|
ID string `bson:"_id" json:"id"`
|
||||||
4. Click **Commit** and then **Commit** again in the dialog.
|
TicketID string `bson:"TicketID" json:"ticket_id"`
|
||||||
5. Go back to the **Source** page.
|
UserID string `bson:"UserID" json:"user_id"`
|
||||||
|
SessionID string `bson:"SessionID" json:"session_id"`
|
||||||
|
|
||||||
Before you move on, go ahead and explore the repository. You've already seen the **Source** page, but check out the **Commits**, **Branches**, and **Settings** pages.
|
Message string `bson:"Message" json:"message"`
|
||||||
|
Files []string `bson:"Files" json:"files"`
|
||||||
|
Shown map[string]int `bson:"Shown" json:"shown"`
|
||||||
|
|
||||||
---
|
CreatedAt time.Time `bson:"CreatedAt" json:"created_at"`
|
||||||
|
}
|
||||||
|
|
||||||
## Clone a repository
|
Title string `bson:"Title"`
|
||||||
|
|
||||||
Use these steps to clone from SourceTree, our client for using the repository command-line free. Cloning allows you to work on your files locally. If you don't yet have SourceTree, [download and install first](https://www.sourcetreeapp.com/). If you prefer to clone from the command line, see [Clone a repository](https://confluence.atlassian.com/x/4whODQ).
|
CreatedAt time.Time `bson:"CreatedAt"`
|
||||||
|
UpdatedAt time.Time `bson:"UpdatedAt"`
|
||||||
|
|
||||||
1. You’ll see the clone button under the **Source** heading. Click that button.
|
Rate int `bson:"Rate"`
|
||||||
2. Now click **Check out in SourceTree**. You may need to create a SourceTree account or log in.
|
}
|
||||||
3. When you see the **Clone New** dialog in SourceTree, update the destination path and name if you’d like to and then click **Clone**.
|
|
||||||
4. Open the directory you just created to see your repository’s files.
|
|
||||||
|
|
||||||
Now that you're more familiar with your Bitbucket repository, go ahead and add a new file locally. You can [push your change back to Bitbucket with SourceTree](https://confluence.atlassian.com/x/iqyBMg), or you can [add, commit,](https://confluence.atlassian.com/x/8QhODQ) and [push from the command line](https://confluence.atlassian.com/x/NQ0zDQ).
|
/ticket/<ticketID> - sse метод для подписки на сообщения из одного тикета.
|
||||||
|
тело ответа
|
||||||
|
{
|
||||||
|
ID string `bson:"_id" json:"id"`
|
||||||
|
TicketID string `bson:"TicketID" json:"ticket_id"`
|
||||||
|
UserID string `bson:"UserID" json:"user_id"`
|
||||||
|
SessionID string `bson:"SessionID" json:"session_id"`
|
||||||
|
|
||||||
|
Message string `bson:"Message" json:"message"`
|
||||||
|
Files []string `bson:"Files" json:"files"`
|
||||||
|
Shown map[string]int `bson:"Shown" json:"shown"`
|
||||||
|
|
||||||
|
CreatedAt time.Time `bson:"CreatedAt" json:"created_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
/send - метод для отправки сообщения в тикета
|
||||||
|
Тело запроса:
|
||||||
|
{
|
||||||
|
Message string `json:"message"`
|
||||||
|
TicketID string `json:"ticket"`
|
||||||
|
Files []string `json:"files"`
|
||||||
|
Lang string `json:"lang"`
|
||||||
|
}
|
||||||
|
|
||||||
|
Ответ null
|
||||||
|
|
||||||
|
|
||||||
|
/getTickets - метод для получения тикетов с пагинацией
|
||||||
|
Тело запроса {
|
||||||
|
Amount int64 `json:"amt"`
|
||||||
|
Page int64 `json:"page"`
|
||||||
|
Search string `json:"srch"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
|
Ответ:
|
||||||
|
[{
|
||||||
|
ID string `bson:"_id"`
|
||||||
|
UserID string `bson:"UserID"`
|
||||||
|
SessionID string `bson:"SessionID"`
|
||||||
|
AnswererID string `bson:"AnswererID"`
|
||||||
|
|
||||||
|
State string `bson:"State"`
|
||||||
|
TopMessage: {
|
||||||
|
ID string `bson:"_id" json:"id"`
|
||||||
|
TicketID string `bson:"TicketID" json:"ticket_id"`
|
||||||
|
UserID string `bson:"UserID" json:"user_id"`
|
||||||
|
SessionID string `bson:"SessionID" json:"session_id"`
|
||||||
|
|
||||||
|
Message string `bson:"Message" json:"message"`
|
||||||
|
Files []string `bson:"Files" json:"files"`
|
||||||
|
Shown map[string]int `bson:"Shown" json:"shown"`
|
||||||
|
|
||||||
|
CreatedAt time.Time `bson:"CreatedAt" json:"created_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
Title string `bson:"Title"`
|
||||||
|
|
||||||
|
CreatedAt time.Time `bson:"CreatedAt"`
|
||||||
|
UpdatedAt time.Time `bson:"UpdatedAt"`
|
||||||
|
|
||||||
|
Rate int `bson:"Rate"`
|
||||||
|
}]
|
||||||
|
|
||||||
|
/getMessages - метод для получения сообщений конкретного тикета с пагинацией
|
||||||
|
тело запроса:
|
||||||
|
{
|
||||||
|
Amount int64 `json:"amt"`
|
||||||
|
Page int64 `json:"page"`
|
||||||
|
Search string `json:"srch"`
|
||||||
|
TicketID string `json:"ticket"`
|
||||||
|
}
|
||||||
|
Ответ:
|
||||||
|
[{
|
||||||
|
ID string `bson:"_id" json:"id"`
|
||||||
|
TicketID string `bson:"TicketID" json:"ticket_id"`
|
||||||
|
UserID string `bson:"UserID" json:"user_id"`
|
||||||
|
SessionID string `bson:"SessionID" json:"session_id"`
|
||||||
|
|
||||||
|
Message string `bson:"Message" json:"message"`
|
||||||
|
Files []string `bson:"Files" json:"files"`
|
||||||
|
Shown map[string]int `bson:"Shown" json:"shown"`
|
||||||
|
|
||||||
|
CreatedAt time.Time `bson:"CreatedAt" json:"created_at"`
|
||||||
|
}]
|
||||||
|
|
||||||
|
/pick - подхватывание сотрудником диалога
|
||||||
|
Запрос:
|
||||||
|
{
|
||||||
|
TicketID string `json:"ticket"`
|
||||||
|
}
|
||||||
|
|
||||||
|
/delegate - передача тикета другому сотруднику
|
||||||
|
Запрос: {
|
||||||
|
TicketID string `json:"ticket"`
|
||||||
|
AnswererID string `json:"answerer"`
|
||||||
|
}
|
||||||
|
|
||||||
|
/vote - метод для оценки полезности ответа
|
||||||
|
{
|
||||||
|
TicketID string `json:"ticket"`
|
||||||
|
Rate int `json:"rate"`
|
||||||
|
}
|
||||||
|
|
||||||
|
/close - метод для закрытия тикета
|
||||||
|
запрос:
|
||||||
|
{
|
||||||
|
TicketID string `json:"ticket"`
|
||||||
|
}
|
||||||
|
25
k8s/deployment.yml
Normal file
25
k8s/deployment.yml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
kind: Deployment
|
||||||
|
apiVersion: apps/v1
|
||||||
|
metadata:
|
||||||
|
name: heruvym
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: heruvym
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: heruvym
|
||||||
|
tier: backend
|
||||||
|
spec:
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: regcred
|
||||||
|
containers:
|
||||||
|
- name: heruvym
|
||||||
|
image: 192.168.193.205:31320/heruvym
|
||||||
|
imagePullPolicy: Always
|
||||||
|
ports:
|
||||||
|
- containerPort: 1488
|
||||||
|
name: http
|
||||||
|
restartPolicy: Always
|
11
k8s/service.yml
Normal file
11
k8s/service.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
kind: Service
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
name: heruvym
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 1488
|
||||||
|
targetPort: 1488
|
||||||
|
protocol: TCP
|
||||||
|
selector:
|
||||||
|
app: heruvym
|
@ -3,16 +3,16 @@ package model
|
|||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type Message struct {
|
type Message struct {
|
||||||
ID string `bson:"_id"`
|
ID string `bson:"_id" json:"id"`
|
||||||
TicketID string `bson:"TicketID"`
|
TicketID string `bson:"TicketID" json:"ticket_id"`
|
||||||
UserID string `bson:"UserID"`
|
UserID string `bson:"UserID" json:"user_id"`
|
||||||
SessionID string `bson:"SessionID"`
|
SessionID string `bson:"SessionID" json:"session_id"`
|
||||||
|
|
||||||
Message string `bson:"Messsage"`
|
Message string `bson:"Message" json:"message"`
|
||||||
Files []string `bson:"Files"`
|
Files []string `bson:"Files" json:"files"`
|
||||||
Shown map[string]int `bson:"Shown"`
|
Shown map[string]int `bson:"Shown" json:"shown"`
|
||||||
|
|
||||||
CreatedAt time.Time `bson:"CreatedAt"`
|
CreatedAt time.Time `bson:"CreatedAt" json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -23,18 +23,18 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Ticket struct {
|
type Ticket struct {
|
||||||
ID string `bson:"_id"`
|
ID string `bson:"_id" json:"id"`
|
||||||
UserID string `bson:"UserID"`
|
UserID string `bson:"UserID" json:"user"`
|
||||||
SessionID string `bson:"SessionID"`
|
SessionID string `bson:"SessionID" json:"sess"`
|
||||||
AnswererID string `bson:"AnswererID"`
|
AnswererID string `bson:"AnswererID" json:"ans"`
|
||||||
|
|
||||||
State string `bson:"State"`
|
State string `bson:"State" json:"state"`
|
||||||
TopMessage Message `bson:"TopMessage"`
|
TopMessage Message `bson:"TopMessage" json:"top_message"`
|
||||||
|
|
||||||
Title string `bson:"Title"`
|
Title string `bson:"Title" json:"title"`
|
||||||
|
|
||||||
CreatedAt time.Time `bson:"CreatedAt"`
|
CreatedAt time.Time `bson:"CreatedAt" json:"created_at"`
|
||||||
UpdatedAt time.Time `bson:"UpdatedAt"`
|
UpdatedAt time.Time `bson:"UpdatedAt" json:"updated_at"`
|
||||||
|
|
||||||
Rate int `bson:"Rate"`
|
Rate int `bson:"Rate" json:"rate"`
|
||||||
}
|
}
|
||||||
|
45
ops/deploy
Executable file
45
ops/deploy
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "################################################################"
|
||||||
|
echo "#### BUILDING APP"
|
||||||
|
echo "################################################################"
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
make build
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "################################################################"
|
||||||
|
echo "#### BUILDING DOCKER IMAGE"
|
||||||
|
echo "################################################################"
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
sudo docker build -t 192.168.193.205:31320/heruvym:latest .
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "################################################################"
|
||||||
|
echo "#### BUILDING PUSH IMAGE"
|
||||||
|
echo "################################################################"
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
sudo docker push 192.168.193.205:31320/heruvym
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "################################################################"
|
||||||
|
echo "#### RELOAD PODS"
|
||||||
|
echo "################################################################"
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
cd ./k8s; kubectl apply -f ./deployment.yml; kubectl apply -f service.yml
|
||||||
|
|
||||||
|
|
||||||
|
kubectl rollout restart deployment heruvym
|
Loading…
Reference in New Issue
Block a user