-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Roman-Zhirovskis/newname
creat diffrents ways of docker/pre-commit/actions
- Loading branch information
Showing
7 changed files
with
261 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
FROM python:3.11-slim-buster | ||
|
||
ENV \ | ||
# python: | ||
PYTHONFAULTHANDLER=1 \ | ||
PYTHONUNBUFFERED=1 \ | ||
PYTHONHASHSEED=random \ | ||
# pip: | ||
PIP_NO_CACHE_DIR=off \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=on \ | ||
PIP_DEFAULT_TIMEOUT=100 | ||
|
||
# System deps: | ||
RUN apt-get update && \ | ||
apt-get install --no-install-recommends -y \ | ||
build-essential \ | ||
gettext \ | ||
libpq-dev \ | ||
wget && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy only requirements, to cache them in docker layer | ||
WORKDIR /app | ||
COPY ./requirements.txt /app/ | ||
|
||
# Project initialization: | ||
RUN pip install -r requirements.txt | ||
|
||
# Creating folders, and files for a project: | ||
COPY . /app | ||
|
||
# Setting up proper permissions: | ||
|
||
RUN mkdir -p /app/media /app/static | ||
|
||
WORKDIR backend | ||
|
||
CMD python manage.py collectstatic --noinput && python manage.py migrate && \ | ||
gunicorn -b 0.0.0.0:8000 --log-level info --access-logfile - config.wsgi:application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM python:3.11 as requirements-stage | ||
|
||
WORKDIR /tmp | ||
|
||
RUN pip install poetry | ||
|
||
COPY ./pyproject.toml ./poetry.lock* /tmp/ | ||
|
||
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes | ||
|
||
FROM python:3.11 | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=requirements-stage /tmp/requirements.txt /code/requirements.txt | ||
|
||
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | ||
|
||
COPY . /app | ||
|
||
CMD ["uvicorn", "src.main:app", "--reload", "--host", "0.0.0.0", "--port", "8000", "--log-level", "debug" , "--use-colors"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
version: "3.9" | ||
|
||
#for fastapi | ||
services: | ||
web: | ||
build: . | ||
restart: always | ||
container_name: app-back | ||
env_file: | ||
- .env | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
|
||
#postgreSql | ||
db: | ||
container_name: db | ||
image: postgres:15.3-alpine | ||
env_file: | ||
- .env | ||
healthcheck: | ||
test: pg_isready -d ${POSTGRES_DB} -U ${POSTGRES_USER} | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
volumes: | ||
- pg_data:/var/lib/postgresql/data | ||
|
||
version: '3' | ||
|
||
#mongoDB | ||
services: | ||
mongodb: | ||
image: mongo | ||
container_name: my-mongodb | ||
restart: always | ||
volumes: | ||
- ./data:/data/db | ||
ports: | ||
- 27017:27017 | ||
#rabbitmq | ||
rabbitmq: | ||
image: rabbitmq:3.11-management | ||
container_name: users-service-rabbitmq | ||
expose: | ||
- 5672 | ||
- 15672 | ||
env_file: | ||
- .env.prod | ||
healthcheck: | ||
test: rabbitmq-diagnostics -q ping | ||
interval: 30s | ||
timeout: 30s | ||
retries: 3 | ||
|
||
#redis | ||
redis: | ||
restart: always | ||
command: /bin/sh -c "redis-server --requirepass $$REDIS_LOCAL_PASSWORD" | ||
image: redis:7.0.5-alpine | ||
env_file: | ||
- .env.prod | ||
expose: | ||
- 6379 | ||
healthcheck: | ||
test: [ "CMD", "redis-cli", "ping" ] | ||
interval: 1s | ||
timeout: 3s | ||
retries: 30 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
version: "3.9" | ||
|
||
services: | ||
web_users_tests: | ||
build: ./ | ||
env_file: | ||
- .env.tests | ||
restart: "no" | ||
command: > | ||
sh -c "python manage.py test" | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
rabbitmq: | ||
condition: service_healthy | ||
redis: | ||
condition: service_healthy | ||
db: | ||
extends: | ||
file: docker-compose.yml | ||
service: db | ||
container_name: users-service-db-tests | ||
env_file: | ||
- .env.tests | ||
rabbitmq: | ||
image: rabbitmq:3.11-management | ||
container_name: users-service-rabbitmq | ||
expose: | ||
- 5672 | ||
- 15672 | ||
env_file: | ||
- .env.tests | ||
healthcheck: | ||
test: rabbitmq-diagnostics -q ping | ||
interval: 30s | ||
timeout: 30s | ||
retries: 3 | ||
redis: | ||
restart: always | ||
command: /bin/sh -c "redis-server --requirepass $$REDIS_LOCAL_PASSWORD" | ||
image: redis:7.0.5-alpine | ||
expose: | ||
- 6379 | ||
env_file: | ||
- .env.tests | ||
healthcheck: | ||
test: [ "CMD", "redis-cli", "ping" ] | ||
interval: 1s | ||
timeout: 3s | ||
retries: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Users CI/CD | ||
|
||
on: | ||
push: | ||
branches: [ "users" ] | ||
pull_request: | ||
branches: ["users" ] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install python | ||
uses: actions/setup-python@v3 | ||
|
||
- run: pip install pre-commit | ||
- run: pre-commit --version | ||
|
||
- run: | | ||
cd backend/users && pre-commit install | ||
- run: | | ||
cd backend/users && pre-commit run --all-files | ||
- name: Run test in docker-compose | ||
run: | | ||
cd backend/users/ && docker-compose -f docker-compose.tests.yml \ | ||
up \ | ||
--build \ | ||
--abort-on-container-exit \ | ||
--exit-code-from web_users_tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
files: 'backend/users*' | ||
repos: | ||
- repo: https://github.com/antonbabenko/pre-commit-terraform | ||
rev: v1.74.1 | ||
hooks: | ||
- id: terraform_fmt | ||
args: [--args=-write=true] | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 23.3.0 | ||
hooks: | ||
- id: black | ||
args: [--skip-string-normalization, --line-length=100, backend/users] | ||
language_version: python3 | ||
|
||
- repo: https://github.com/timothycrosley/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
args: [--profile=black] | ||
|
||
- repo: https://github.com/asottile/add-trailing-comma | ||
rev: v2.4.0 | ||
hooks: | ||
- id: add-trailing-comma | ||
|
||
- repo: https://github.com/pycqa/flake8.git | ||
rev: 6.0.0 | ||
hooks: | ||
- id: flake8 | ||
args: [--config, backend/users/.flake8] | ||
additional_dependencies: [ | ||
"flake8-bugbear", | ||
"flake8-builtins", | ||
"pep8-naming", | ||
"flake8-commas", | ||
"flake8-quotes", | ||
"flake8-todo", | ||
"flake8-django", | ||
"flake8-cognitive-complexity" | ||
] |