Skip to content

Commit

Permalink
Change the build process
Browse files Browse the repository at this point in the history
- remove setup.cfg and use a pyproject.toml
- refactor the docker files structure and process
  • Loading branch information
tudoramariei committed Oct 26, 2023
1 parent ea0516c commit c1a8613
Show file tree
Hide file tree
Showing 24 changed files with 156 additions and 256 deletions.
16 changes: 0 additions & 16 deletions .github/dependabot.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/api_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
paths:
- 'api/**.py'
- 'api/requirements*.*'
- 'api/Dockerfile'
- 'docker/dockerfiles/Dockerfile.backend*'
- 'docker-compose.yml'
- '.github/workflows/api_pipeline.yml'

Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
on:
push:
branches:
- 'main'
tags:
- 'v*'

name: Build Docker image

jobs:

build-backend-amd64:
name: backend/amd64
uses: code4romania/.github/.github/workflows/build-push-image.yml@main
with:
images: ghcr.io/code4romania/seismic-risc-backend
context: ./
dockerfile: ./docker/dockerfiles/Dockerfile.backend
registry: ghcr.io
secrets:
username: ${{ github.actor }}
token: ${{ secrets.GITHUB_TOKEN }}

build-frontend-amd64:
name: frontend/amd64
uses: code4romania/.github/.github/workflows/build-push-image.yml@main
with:
images: ghcr.io/code4romania/seismic-risc-frontend
context: ./client
dockerfile: ./docker/dockerfiles/Dockerfile.frontend
registry: ghcr.io
secrets:
username: ${{ github.actor }}
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/client_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
paths:
- 'client/**.js'
- 'client/package*.json'
- 'client/Dockerfile'
- 'docker/dockerfiles/Dockerfile.frontend*'
- 'docker-compose.yml'
- '.github/workflows/client_pipeline.yml'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
paths:
- 'client/**.js'
- 'client/package*.json'
- 'client/Dockerfile'
- 'docker/dockerfiles/Dockerfile.frontend*'
- 'docker-compose.yml'
- '.github/workflows/client_pipeline.yml'
- '.github/workflows/code-analysis-js.yml'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
paths:
- 'api/**.py'
- 'api/requirements*.*'
- 'api/Dockerfile'
- 'docker/dockerfiles/Dockerfile.backend*'
- 'docker-compose.yml'
- '.github/workflows/api_pipeline.yml'
- '.github/workflows/code-analysis-py.yml'
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/deploy_staging.yml

This file was deleted.

42 changes: 0 additions & 42 deletions .github/workflows/local_deployment_pipeline.yml

This file was deleted.

36 changes: 0 additions & 36 deletions api/Dockerfile.old

This file was deleted.

71 changes: 71 additions & 0 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[tool.ruff]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = ["E", "F"]
ignore = []

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
"migrations",
]

# Same as Black.
line-length = 120

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python 3.11.
target-version = "py311"

[tool.ruff.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

[tool.ruff.extend-per-file-ignores]
"settings/*.py" = ["F403", "F405"]
"*/__init__.py" = ["F401"]

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "backend.test_settings"

python_files = [
"test.py",
"test*.py",
"*test.py",
"*tests.py",
]
filterwarnings = [
"ignore:The django.utils.baseconv module is deprecated."
]

[tool.black]
line-length = 120
target-version = ["py311"]
extend-exclude = '''(
(.+/)?migrations/.+
)'''
2 changes: 1 addition & 1 deletion api/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ prompt-toolkit==3.0.39
# via ipython
psutil==5.9.6
# via -r requirements.txt
psycopg2==2.9.9
psycopg2-binary==2.9.9
# via -r requirements.txt
ptyprocess==0.7.0
# via pexpect
Expand Down
2 changes: 1 addition & 1 deletion api/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ djangorestframework==3.14.0
drf-spectacular==0.26.5

# database
psycopg2==2.9.9
psycopg2-binary==2.9.9
dj-database-url==2.1.0

# file handling
Expand Down
2 changes: 1 addition & 1 deletion api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pillow==10.0.1
# via -r requirements.in
psutil==5.9.6
# via -r requirements.in
psycopg2==2.9.9
psycopg2-binary==2.9.9
# via -r requirements.in
python-dateutil==2.8.2
# via
Expand Down
45 changes: 0 additions & 45 deletions api/setup.cfg

This file was deleted.

1 change: 0 additions & 1 deletion client/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
node_modules
Dockerfile
8 changes: 0 additions & 8 deletions deploy/pull.sh

This file was deleted.

5 changes: 2 additions & 3 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ services:
file: dk-cp.base.yml
service: api_base
build:
context: .
dockerfile: ./api/Dockerfile
context: ./
dockerfile: ./docker/dockerfiles/Dockerfile.backend
args:
- ENVIRONMENT=production
env_file:
Expand All @@ -31,7 +31,6 @@ services:
service: client_base
build:
context: ./client
dockerfile: ./Dockerfile
args:
- ENVIRONMENT=production
env_file:
Expand Down
Loading

0 comments on commit c1a8613

Please sign in to comment.