17 Commits

Author SHA1 Message Date
66d68701c2 Revert "В репе конфиг не нужен"
Some checks failed
continuous-integration/drone/push Build is failing
Все пошло не так

This reverts commit 0ba3b5f037.
2021-11-01 05:13:35 +03:00
94a626e7f1 Не будем пробрасывать конфиг (а нужно ли его вытаскивать наружу?)
All checks were successful
continuous-integration/drone/push Build is passing
2021-11-01 05:07:50 +03:00
0ba3b5f037 В репе конфиг не нужен
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone Build is failing
2021-11-01 05:02:12 +03:00
7544e3c447 Добавил конфигурацию самого приложения
Some checks failed
continuous-integration/drone/push Build is failing
2021-11-01 04:58:13 +03:00
96790be6f7 Вернул метрики
All checks were successful
continuous-integration/drone/push Build is passing
2021-11-01 04:46:07 +03:00
89dcffa6bb Merge pull request 'prometheus-monitoring' (#3) from prometheus-monitoring into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: http://git.lulzette.ru/lulzette/pycms/pulls/3
2021-11-01 04:40:18 +03:00
4f736f763e Нет, надо вот так
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is failing
2021-11-01 04:38:54 +03:00
f84994999a Добавил остановку текущих контейнеров
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2021-11-01 04:36:41 +03:00
74cd6c6d4b Revert "Добавил простую метрику"
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is passing
Тут этого быть не должно 0_0

This reverts commit 54139d6f76.
2021-11-01 04:30:27 +03:00
49f981708a Добавил шагов
All checks were successful
continuous-integration/drone/push Build is passing
2021-11-01 04:28:02 +03:00
54139d6f76 Добавил простую метрику
All checks were successful
continuous-integration/drone/push Build is passing
2021-10-31 02:24:54 +03:00
4ab80616a6 Добавил название проекта
All checks were successful
continuous-integration/drone/push Build is passing
2021-10-19 10:32:58 +00:00
04905c59db Merge pull request 'Настроил сборку в drone' (#2) from drone into master
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone Build is passing
Reviewed-on: http://git.lulzette.ru/lulzette/pycms/pulls/2
2021-10-19 05:29:56 +03:00
c4602b9d4e change runner
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2021-10-19 02:26:08 +00:00
2f5867028e fix
Some checks reported errors
continuous-integration/drone/push Build is failing
continuous-integration/drone Build was killed
2021-10-19 02:16:18 +00:00
1aa4be2e47 Drone
Some checks reported errors
continuous-integration/drone/push Build encountered an error
2021-10-19 02:14:31 +00:00
3aa77129ec Кое-какие тесты 2021-10-19 00:53:17 +00:00
5 changed files with 62 additions and 43 deletions

22
.drone.yml Normal file
View File

@@ -0,0 +1,22 @@
kind: pipeline
type: exec
name: build
steps:
- name: build
commands:
- docker-compose -p pycms build
- name: test
commands:
- docker-compose -p pycms up --build --abort-on-container-exit
- name: push
commands:
- docker-compose -p pycms push
- name: run
commands:
- docker-compose -p pycms down
- docker-compose -p pycms up -d

View File

@@ -1,39 +0,0 @@
# This file is a template, and might need editing before it works on your project.
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml
# This is a sample GitLab CI/CD configuration file that should run without any modifications.
# It demonstrates a basic 3 stage CI/CD pipeline. Instead of real tests or scripts,
# it uses echo commands to simulate the pipeline execution.
#
# A pipeline is composed of independent jobs that run scripts, grouped into stages.
# Stages run in sequential order, but jobs within stages run in parallel.
#
# For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages
stages: # List of stages for jobs, and their order of execution
- build
- test
- deploy
build-job: # This job runs in the build stage, which runs first.
stage: build
script:
- echo "Compiling the code..."
- docker build .
- echo "Compile complete."
test-job: # This job also runs in the test stage.
stage: test # It can run at the same time as unit-test-job (in parallel).
script:
- echo "Linting code... This will take about 10 seconds."
- docker-compose up --build --abort-on-container-exit
- echo "No lint issues found."
deploy-job: # This job runs in the deploy stage.
stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
script:
- echo "Deploying application..."
- echo "Application successfully deployed."

View File

@@ -4,9 +4,13 @@ services:
build: .
ports:
- 8080:8080
volumes:
- ./config.ini:/app/config.ini
depends_on:
- db
db:
image: mongo
tests:
build: .
command: bash ./test.sh
depends_on:
- db
- server

24
main.py
View File

@@ -44,11 +44,15 @@ class Config:
self.createConfig(config)
db = config['DB']
self.host = db['host']
self.port = int(db['port'])
self.dbname = db['name']
app = config['App']
self.apphost = app['host']
self.appport = int(app['port'])
self.appdebug = bool(app['debug'])
def createConfig(self, config):
"""
Create config file
@@ -59,6 +63,12 @@ class Config:
db['port'] = '27017'
db['name'] = 'pycms'
config['App'] = {}
app = config['App']
app['port'] = '8080'
app['debug'] = 'True'
app['host'] = '0.0.0.0'
with open('config.ini', 'w') as cfgfile:
config.write(cfgfile)
@@ -104,6 +114,16 @@ class Back():
return bool(posts.delete_one({'name': name}).deleted_count)
class Metrics:
def alive():
return str("alive 1")
@route('/metrics')
def metrics():
return Metrics.alive()
@route('/post/<name>')
def post(name):
'''
@@ -148,4 +168,4 @@ if __name__ == '__main__':
print("Configured")
back = Back()
posts = cfg.posts
run(host='0.0.0.0', port=8080, reloader=True, debug=True)
run(host=cfg.apphost, port=cfg.appport, reloader=cfg.appdebug, debug=cfg.appdebug)

12
test.sh Normal file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
curl_cmd='curl -s -w "%{http_code}" -o /dev/null'
url='server:8080'
$curl_cmd -X POST $url/admin/post/test -F 'body=testpage' && echo ": Create success" || echo ': create fail'
$curl_cmd $url/post/test && echo ": get Success" || echo ': get fail'
$curl_cmd -X POST $url/admin/post/test -F 'body=testpage2' && echo ": Update success" || echo ': update fail'
$curl_cmd -X DELETE $url/admin/post/test && echo ": delete success" || echo ': delete fail'
$curl_cmd $url/metrics && echo ": metrics available" || echo ': metrics unavailable'