commit
36aefd2728
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
* @cwarck @qtm @verdel @nitive
|
37
.github/workflows/build-docker-image.yaml
vendored
Normal file
37
.github/workflows/build-docker-image.yaml
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: Docker image build
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
paths:
|
||||||
|
- app/**
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- app/**
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-images:
|
||||||
|
name: Build docker image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build test-app
|
||||||
|
run: make build
|
||||||
|
working-directory: app
|
||||||
|
|
||||||
|
- name: Login to Quay
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: quay.csssr.cloud
|
||||||
|
username: csssr+github_devops_test_app
|
||||||
|
password: ${{ secrets.QUAY_REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Publish test-app
|
||||||
|
run: make publish
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
working-directory: app
|
19
.github/workflows/lint-renovate.yaml
vendored
Normal file
19
.github/workflows/lint-renovate.yaml
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
name: Lint renovate configuration
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
paths:
|
||||||
|
- .renovaterc
|
||||||
|
- ".github/workflows/lint-renovate.yaml"
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- .renovaterc
|
||||||
|
- ".github/workflows/lint-renovate.yaml"
|
||||||
|
jobs:
|
||||||
|
validate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 3
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: suzuki-shunsuke/github-action-renovate-config-validator@v1.0.1
|
29
.renovaterc
Normal file
29
.renovaterc
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"extends": [
|
||||||
|
"config:recommended",
|
||||||
|
":disableRateLimiting",
|
||||||
|
":disableVulnerabilityAlerts"
|
||||||
|
],
|
||||||
|
"labels": [
|
||||||
|
"dependencies"
|
||||||
|
],
|
||||||
|
"postUpdateOptions": [
|
||||||
|
"gomodTidy",
|
||||||
|
"gomodUpdateImportPaths"
|
||||||
|
],
|
||||||
|
"reviewersFromCodeOwners": true,
|
||||||
|
"enabledManagers": [
|
||||||
|
"gomod",
|
||||||
|
"dockerfile",
|
||||||
|
"github-actions"
|
||||||
|
],
|
||||||
|
"packageRules": [
|
||||||
|
{
|
||||||
|
"matchDatasources": [
|
||||||
|
"golang-version"
|
||||||
|
],
|
||||||
|
"rangeStrategy": "bump"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
14
Makefile
14
Makefile
@ -1,11 +1,15 @@
|
|||||||
|
|
||||||
|
.PHONY: publish-app start-app deploy
|
||||||
|
|
||||||
|
HELM=$(shell which helm3 2>/dev/null || which helm)
|
||||||
BRANCH ?= master
|
BRANCH ?= master
|
||||||
|
|
||||||
build-app:
|
start-app:
|
||||||
docker build app --tag quay.csssr.cloud/csssr/test-app:$(BRANCH)
|
$(MAKE) -C app start
|
||||||
docker push quay.csssr.cloud/csssr/test-app:$(BRANCH)
|
|
||||||
|
|
||||||
HELM ?= helm3
|
publish-app:
|
||||||
|
$(MAKE) -C app build version=$(BRANCH)
|
||||||
|
$(MAKE) -C app publish version=$(BRANCH)
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
$(HELM) upgrade --install my-app-$(BRANCH) chart --set image.tag=$(BRANCH) --set ingress.host=$(BRANCH).my-app.com
|
$(HELM) upgrade --install my-app-$(BRANCH) chart --set image.tag=$(BRANCH) --set ingress.host=$(BRANCH).csssr.cloud
|
||||||
|
@ -22,12 +22,18 @@ curl http://my-app.com/image -o image.jpg
|
|||||||
- 100% uptime
|
- 100% uptime
|
||||||
- Возможность делать несколько релизов для разных веток в один неймспейс (для тестирования)
|
- Возможность делать несколько релизов для разных веток в один неймспейс (для тестирования)
|
||||||
|
|
||||||
|
## Локальный запуск приложения
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make start-app
|
||||||
|
```
|
||||||
|
|
||||||
## Деплой
|
## Деплой
|
||||||
|
|
||||||
Сборка
|
Сборка
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make build BRANCH=master
|
make publish-app BRANCH=master
|
||||||
```
|
```
|
||||||
|
|
||||||
Деплой helm чарта (используется helm 3)
|
Деплой helm чарта (используется helm 3)
|
||||||
|
36
app/.air.toml
Normal file
36
app/.air.toml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
root = '.'
|
||||||
|
tmp_dir = 'bin'
|
||||||
|
|
||||||
|
[build]
|
||||||
|
cmd = 'go build -o bin/app main.go'
|
||||||
|
bin = './bin/app'
|
||||||
|
full_bin = ''
|
||||||
|
args_bin = []
|
||||||
|
include_ext = ['go']
|
||||||
|
exclude_dir = ['bin', 'tests']
|
||||||
|
include_dir = []
|
||||||
|
exclude_file = []
|
||||||
|
exclude_regex = ['_test.go']
|
||||||
|
exclude_unchanged = false
|
||||||
|
follow_symlink = false
|
||||||
|
delay = 1000
|
||||||
|
stop_on_error = true
|
||||||
|
send_interrupt = false
|
||||||
|
kill_delay = 0
|
||||||
|
|
||||||
|
[color]
|
||||||
|
main = 'magenta'
|
||||||
|
watcher = 'cyan'
|
||||||
|
build = 'yellow'
|
||||||
|
runner = 'green'
|
||||||
|
app = ''
|
||||||
|
|
||||||
|
[log]
|
||||||
|
time = false
|
||||||
|
|
||||||
|
[misc]
|
||||||
|
clean_on_exit = true
|
||||||
|
|
||||||
|
[screen]
|
||||||
|
clear_on_rebuild = false
|
||||||
|
|
4
app/.dockerignore
Normal file
4
app/.dockerignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
*
|
||||||
|
!go.mod
|
||||||
|
!go.sum
|
||||||
|
!main.go
|
1
app/.gitignore
vendored
1
app/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
tmp-image
|
tmp-image
|
||||||
|
bin/
|
@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.14
|
FROM golang:1.22
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
17
app/Makefile
Normal file
17
app/Makefile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
.PHONY: start build publish
|
||||||
|
|
||||||
|
export GOBIN=${CURDIR}/bin
|
||||||
|
|
||||||
|
version ?= master
|
||||||
|
|
||||||
|
$(GOBIN)/air:
|
||||||
|
go install github.com/air-verse/air@latest
|
||||||
|
|
||||||
|
start: $(GOBIN)/air
|
||||||
|
air
|
||||||
|
|
||||||
|
build:
|
||||||
|
docker build . --tag quay.csssr.cloud/csssr/test-app:$(version)
|
||||||
|
|
||||||
|
publish:
|
||||||
|
docker push quay.csssr.cloud/csssr/test-app:$(version)
|
@ -1,5 +1,5 @@
|
|||||||
module github.com/CSSSR/my-app
|
module github.com/CSSSR/my-app
|
||||||
|
|
||||||
go 1.14
|
go 1.22
|
||||||
|
|
||||||
require github.com/logrusorgru/aurora v2.0.3+incompatible
|
require github.com/logrusorgru/aurora v2.0.3+incompatible
|
||||||
|
@ -2,7 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -36,12 +36,12 @@ func uploadFile(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
fileBytes, err := ioutil.ReadAll(file)
|
fileBytes, err := io.ReadAll(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error reading file %v", err)
|
log.Fatalf("Error reading file %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ioutil.WriteFile(config.ImagePath, fileBytes, os.FileMode(0600))
|
os.WriteFile(config.ImagePath, fileBytes, os.FileMode(0600))
|
||||||
|
|
||||||
log.Println(aurora.Cyan("Successfully Uploaded File"))
|
log.Println(aurora.Cyan("Successfully Uploaded File"))
|
||||||
fmt.Fprintf(w, "Successfully Uploaded File\n")
|
fmt.Fprintf(w, "Successfully Uploaded File\n")
|
||||||
|
@ -29,4 +29,4 @@ spec:
|
|||||||
volumes:
|
volumes:
|
||||||
- name: data
|
- name: data
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: my-app
|
claimName: {{ .Release.Name }}
|
||||||
|
@ -2,9 +2,8 @@ apiVersion: networking.k8s.io/v1
|
|||||||
kind: Ingress
|
kind: Ingress
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ .Release.Name }}
|
name: {{ .Release.Name }}
|
||||||
annotations:
|
|
||||||
kubernetes.io/ingress.class: nginx
|
|
||||||
spec:
|
spec:
|
||||||
|
ingressClassName: nginx
|
||||||
rules:
|
rules:
|
||||||
- host: {{ .Values.ingress.host }}
|
- host: {{ .Values.ingress.host }}
|
||||||
http:
|
http:
|
||||||
@ -13,6 +12,6 @@ spec:
|
|||||||
pathType: Prefix
|
pathType: Prefix
|
||||||
backend:
|
backend:
|
||||||
service:
|
service:
|
||||||
name: my-app
|
name: {{ .Release.Name }}
|
||||||
port:
|
port:
|
||||||
number: 80
|
number: 80
|
||||||
|
Loading…
Reference in New Issue
Block a user