summary
- create folder on server as: repo-
-dev.git - initialize git repo: git init –bare
- create folder on local machine
- get files from remote repo: git clone ssh://git@olkn.myvnc.com/repo-
-dev.git - add files to staging: git add -A
- commit changes to repo: git commit -m “
“ - push changes to remote repo: git push origin
git
config
- git config –global user.name “olkn”
- git config –global user.email “olkn@gmail.com”
- git remote add olkn ssh://olkn.myvnc.com/git/repo-python-development
- git config –global pull.rebase true
- git config –global color.ui auto
- git config –global core.editor vim
- .gitignore to list all files that should not be included in git repo
initialise git repo
git init
git init –bare : if the repo is on a server and no working tree is necessary (should end in .git)
stage
Staging adds file to a stage prepared for later commit
- git add -A
- git stage .
commit
All files in staging were added/committed to the repo
git commit -m “Comment for commit”
password less login
ssh-keygen -t rsa -b 4096 -C “
ssh-add .ssh/id-rsa
ssh-copy-id -i .ssh/id-rsa
initialise git repo
mkdir
cd
git init –bare –shared
add files to repo
git add -A
git commit -m “
add remote repo
git remote add live ssh://
git push live
docker
docker build -t
docker images : list all available docker images in the system
docker run -it
docker run -d -p 5000:5000
docker ps : show all running docker container
docker start/stop
docker-compose up -d : start docker environment detached
docker-composer down : stop all containers
docker-composer ps : list all running containers
docker-composer build : build images from scratch
docke-compose logs
python
project folder
— docker-compose.yml
–|– app (program sources we are working on)
—-|– Dockerfile
—-|– requirements.txt
—-|– src
——-|– python.py
–|– db (data base server and config, if any)
—–|– password.txt
–|– web (web server and config, if any)
docker composer file
ersion: "3.7"
services:
db:
image: mysql:8.0.19
command: '--default-authentication-plugin=mysql_native_password'
restart: always
secrets:
- db-password
volumes:
- db-data:/var/lib/mysql
networks:
- backend-network
environment:
- MYSQL_DATABASE=example
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db-password
app:
build: app
restart: always
secrets:
- db-password
networks:
- backend-network
- frontend-network
volumes:
- ./app/src:/code
ports: (debugger ports for flask inside the container)
- 5678:5678
web:
build: web
restart: always
ports:
- 80:80
networks:
- frontend-network
volumes:
db-data:
secrets:
db-password:
file: db/password.txt
networks:
backend-network:
frontend-network:
docker-file
# set base image (host OS)
FROM python:3.8
# set the working directory in the container
WORKDIR /code
# copy the dependencies file to the working directory
COPY requirements.txt .
# install dependencies
RUN pip install -r requirements.txt
# copy the content of the local src directory to the working directory
COPY src/ .
# command to run on container start
CMD [ "python", "./server.py" ]
laravel
laravel with sail
- install docker compose
- install composer: wget https://getcomposer.org/installer
initialize a new project
curl -s https://laravel.build/project-name?with=mysql,selenium,mailhog |bash
configuration
edit .env
docker composer file
docker-compose.yml
docker-file
programming
python
laravel
alternative
python
- python3 -m venv
- source
/bin/activate
git
- git init . (executed in
folder of course - create .gitignore with contents (*.pyc and __pycache__)
README
create a file README with project description and usage instructions
markdown format (README.md) would be a good choice for the formatting
git commit
- git add .gitignore README.md
- git add *
- git comit -m “initial release”
skeleton
file structure
- folder docs – program documentation (spinx)
- folder src/app – source code of the application
- folder tests – unit test files
- .gitignore – see above
- requirements.txt – pip requirements file
- README.md – see above
- TODO.md – open issues to implement
- LICENSE – ???
- setup.py – see below
program skeleton
structure with functions, classes, modules, etc but with docstrings only as the contents will follow later with the implementation
create the main file, e.g.
""" descriptive text"""
import sys
"""definition of constants"""
URL = "https://olkn.myvnc.com"
def main():
""" main entry point for the program """
pass
"""definition of functions"""
def get_url(url):
"""describe function"""
pass
if __name__ == '__main__'
sys.exit(main())
requirements
list all the requirements in a file: pip freeze requirements.txt