TT#43813 update Dockerfile

* update README.md
* replace screen with tmux with custom config
* pre-commit:
  - add requirements-txt-fixer
  - add python reorder imports
    helps to keep imports tidy
  - add eslint to check and format javascript
* configure black via pyproject.toml
* update gitignore

Change-Id: I86a8ad4a01203f3d592ff6c2ff0052b5e491a1e1
changes/47/37647/17
Victor Seva 5 years ago
parent ce0aa7897c
commit 0ed960e079
No known key found for this signature in database
GPG Key ID: B1589889727198E0

@ -0,0 +1,22 @@
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"jquery": true
},
"extends": [
"eslint:recommended",
"jquery"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"camelcase": "off"
}
}

3
.gitignore vendored

@ -1,4 +1,7 @@
*~
node_modules/
*.pyc
db.sqlite3
install.log
reports
src

@ -2,12 +2,25 @@ default_language_version:
# force all unspecified python hooks to run python3
python: python3
repos:
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.9.0
hooks:
- id: reorder-python-imports
exclude: migrations/
args: ["--py37-plus"]
- repo: https://github.com/psf/black
rev: stable
args: -t py37
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: flake8
- id: requirements-txt-fixer
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v6.8.0
hooks:
- id: eslint
args: ['--fix']
additional_dependencies:
- eslint-config-jquery

@ -0,0 +1,91 @@
#set-option -g default-shell /bin/zsh
# Use Ctrl-a, like Screen
set -g prefix C-a
unbind C-b
# Start counting from 1 for windows and panes
set -g base-index 1
set -g pane-base-index 1
bind C-a send-prefix
bind | split-window -h
bind - split-window -v
bind e detach
bind x kill-pane
bind & kill-window
set-option -g allow-rename off
#vim moves
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind r source-file ~/.tmux.conf \; display "Configuration reloaded!"
#Toogle
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
#set -g mouse-select-pane on
#set -g mouse-resize-pane on
#set -g mouse-select-pane on
#set -g mode-mouse on
set -g monitor-activity off
set -g visual-activity off
bind-key * list-clients
setw -g automatic-rename
set-option -g set-titles on
set -g history-limit 10000
set -g status-keys vi
set -g mode-keys vi
set -sg escape-time 0
unbind q
bind q confirm kill-session
bind Q confirm kill-server
unbind d
bind -r d resize-pane -D 5
bind -r u resize-pane -U 5
#set -g status-utf8 on
set -g status-right "#S:#I.#P"
set -g status-justify left
set-option -g status-position top
if-shell "if [[ `tmux -V | cut -d' ' -f2` -lt 2.0 ]]; then true; else false; fi" \
'set -g status-utf8 on; \
set -g mouse-select-pane on; \
set -g mouse-resize-pane on; \
set -g mouse-select-pane on; \
set -g mode-mouse on;'
#
## THEME
##
#
## Colors make life better
set -g default-terminal "screen-256color"
#
set -g status-fg colour253 # lightgrey
set -g status-bg colour234 # darkgrey
## Status bar info
#set -g status-utf8 on
set -g status-left "#[fg=red]($SERVER)⚡ [#I]"
set -g status-right "[#I] #[fg=yellow]#S:#I:#P #[fg=green]%H:%M %d-%h"
set -g status-justify left
set-option -g status-position top

@ -42,28 +42,34 @@ shell: venv_prod
###################################
run_dev:
run_dev: venv_dev
IP=$(shell ip a show dev eth0 scope global | grep inet | awk '{print $$2}' | cut -d/ -f1); \
source $(VAR_DIR)/venv_dev/bin/activate && \
./manage.py runserver_plus $$IP:8000 --settings="repoapi.settings.dev"
worker_dev:
worker_dev: venv_dev
source $(VAR_DIR)/venv_dev/bin/activate && \
DJANGO_SETTINGS_MODULE=repoapi.settings.dev \
$(VAR_DIR)/venv_dev/bin/celery -A repoapi worker \
--loglevel=info
monitor_dev:
monitor_dev: venv_dev
IP=$(shell ip a show dev eth0 scope global | grep inet | awk '{print $$2}' | cut -d/ -f1); \
source $(VAR_DIR)/venv_dev/bin/activate && \
DJANGO_SETTINGS_MODULE=repoapi.settings.dev \
$(VAR_DIR)/venv_dev/bin/celery -A repoapi flower \
--address=$$IP --port=5555 --settings="repoapi.settings.dev"
makemigrations_dev:
makemigrations_dev: venv_dev
source $(VAR_DIR)/venv_dev/bin/activate && \
./manage.py makemigrations --settings="repoapi.settings.dev"
migrate_dev:
migrate_dev: venv_dev
source $(VAR_DIR)/venv_dev/bin/activate && \
./manage.py migrate --settings="repoapi.settings.dev"
shell_dev:
shell_dev: venv_dev
source $(VAR_DIR)/venv_dev/bin/activate && \
./manage.py shell --settings="repoapi.settings.dev"
###################################

@ -19,47 +19,80 @@ On your desktop, install pre-commit tool
[pre-commit](https://pre-commit.com/)
-------------------------------------
* apt install build-essential python3-dev python3-virtualenvwrapper virtualenvwrapper
* sudo apt install build-essential python3-dev python3-virtualenvwrapper virtualenvwrapper npm
* sudo npm install -g eslint
* npm install eslint-config-jquery
* mkvirtualenv repos-scritps --python=python3
* pip3 install pre-commit
* pre-commit install
Inside the repoapi-stretch container run:
virtualenv
----------
Inside the repoapi-buster container run:
$ export VAR_DIR=/tmp/repoapi
$ make venv_dev
$ source ${VAR_DIR}/venv_dev/bin/activate
```
$ make venv_dev
$ source /var/lib/repoapi/venv_dev/bin/activate
(venv_dev)$
```
Create DB
=========
---------
To ensure `db.sqlite3` exists as needed:
(repoapi)$ ./manage.py migrate --settings="repoapi.settings.dev"
```
(venv_dev)$ ./manage.py migrate --settings="repoapi.settings.dev"
```
or
```
$ make migrate_dev
```
Create superuser
================
----------------
(repoapi)$ ./manage.py createsuperuser --settings="repoapi.settings.dev"
```
(venv_dev)$ ./manage.py createsuperuser --settings="repoapi.settings.dev"
```
Run test server
================
Tmux
----
If you want to run it on a specific IP, use:
Use tmux inside repoapi-buster container so you can execute both dev server and worker
Run dev server
--------------
(repoapi)$ IP=172.17.0.3 # adjust as needed
(repoapi)$ ./manage.py runserver_plus $IP:8000 --settings="repoapi.settings.dev"
If you want to run it on a specific IP, use:
```
(venv_dev)$ IP=172.17.0.3 # adjust as needed
(venv_dev)$ ./manage.py runserver_plus $IP:8000 --settings="repoapi.settings.dev"
```
or just:
```
$ make run_dev
```
Run dev worker
--------------
(repoapi)$ make run_dev
```
$ make worker_dev
```
Tests
=====
-----
(repoapi)$ ./manage.py test
```
(venv_dev)$ ./manage.py test
```
Reports
=======
-------
(repoapi)$ ./manage.py jenkins
```
(venv_dev)$ ./manage.py jenkins
```

@ -0,0 +1,9 @@
[tool.black]
line-length = 79
py37 = true
exclude = '''
/(
migrations
| __pycache__
)/
'''

@ -1,17 +1,18 @@
celery
Django==1.11.28
django-extensions
yuicompressor
django-assets
django-celery-beat
django-celery-results
django-extensions
django-filter
django-jsonify
django-rest-swagger
djangorestframework>=3.6,<3.7
drfapikey
django-rest-swagger
flower
markdown
django-filter
python-debian
PyYAML
six>=1.9
webassets
celery
django-celery-beat
django-celery-results
flower
django-jsonify
python-debian
yuicompressor

@ -5,18 +5,18 @@ FROM docker.mgm.sipwise.com/sipwise-buster:latest
# is updated with the current date. It will force refresh of all
# of the base images and things like `apt-get update` won't be using
# old cached versions when the Dockerfile is built.
ENV REFRESHED_AT 2020-02-20
ENV REFRESHED_AT 2020-02-21
RUN apt-get update
RUN apt-get install --assume-yes python3 python3-dev \
python3-pip python3-virtualenv virtualenv sqlite3 git screen
python3-pip python3-virtualenv virtualenv sqlite3 git tmux
# Get pip to download and install requirements:
ADD requirements/*.txt /tmp/
RUN pip3 install -r /tmp/test.txt
RUN echo './t/testrunner' >>/root/.bash_history
ADD .tmux.conf /root/.tmux.conf
RUN apt-get clean
WORKDIR /code/

Loading…
Cancel
Save