Skip to content

Commit

Permalink
Add a build image file and remove the old build process
Browse files Browse the repository at this point in the history
  • Loading branch information
tudoramariei committed Oct 25, 2023
1 parent ea0516c commit b4e17aa
Show file tree
Hide file tree
Showing 25 changed files with 214 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
64 changes: 64 additions & 0 deletions .github/workflows/build-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
on:
workflow_call:
inputs:
image:
required: true
type: string
branch:
default: main
type: string
context:
required: true
type: string
dockerfile:
required: true
type: string
platform:
required: true
type: string

name: Build Docker image template

jobs:
main:
name: build image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.image }}
tags: |
type=edge
type=edge,branch=${{ inputs.branch }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
platforms: ${{ inputs.platform }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
on:
push:
branches:
- 'main'
tags:
- 'v*'

name: Build Docker image

jobs:

build-backend-amd64:
name: backend/amd64
uses: ./.github/workflows/build-template.yml
with:
image: ghcr.io/code4romania/seismic-risc-backend
context: ./
dockerfile: ./docker/dockerfiles/Dockerfile.backend
platform: linux/amd64

build-frontend-amd64:
name: frontend/amd64
uses: ./.github/workflows/build-template.yml
with:
image: ghcr.io/code4romania/seismic-risc-frontend
context: ./client
dockerfile: ./docker/dockerfiles/Dockerfile.frontend
platform: linux/amd64
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.

Loading

0 comments on commit b4e17aa

Please sign in to comment.