generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added actions and docker_compose files
- Loading branch information
1 parent
42d4ecc
commit 03b33d3
Showing
10 changed files
with
270 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Postgres_Deploy | ||
on: workflow_dispatch | ||
|
||
env: | ||
DBS: "${{ vars.DEV_DB }},${{ vars.PROD_DB }}" | ||
POSTGRES_USER: ${{ vars.POSTGRES_USER }} | ||
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | ||
DATABASE: ${{ vars.POSTGRES_DB }} | ||
|
||
PGADMIN_DEFAULT_EMAIL: ${{ vars.DEV_PGADMIN_DEFAULT_EMAIL }} | ||
PGADMIN_DEFAULT_PASSWORD: ${{ secrets.DEV_PGADMIN_DEFAULT_PASSWORD }} | ||
|
||
jobs: | ||
deploy: | ||
runs-on: self-hosted | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Docker compouse DOWN old containers | ||
run: docker compose -f docker-compose.db.yml down -v | ||
- name: Docker compouse UP new containers | ||
run: docker compose -f docker-compose.db.yml up -d --build | ||
- name: Clean up old docker resources | ||
run: | | ||
docker container prune -f | ||
docker image prune -f |
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,31 @@ | ||
name: Django CD DEV | ||
on: workflow_dispatch | ||
|
||
env: | ||
DEBUG: ${{ vars.DEV_DEBUG }} | ||
SECRET_KEY: ${{ secrets.DEV_SECRET_KEY }} | ||
ENGINE: ${{ vars.ENGINE }} | ||
HOST: ${{ vars.POSTGRES_HOST }} | ||
PORT: ${{ vars.POSTGRES_PORT }} | ||
DB: ${{ vars.DEV_DB }} | ||
USER: ${{ vars.POSTGRES_USER }} | ||
PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | ||
DATABASE: ${{ vars.POSTGRES_DB }} | ||
|
||
jobs: | ||
deploy: | ||
runs-on: self-hosted | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Docker compouse DOWN old containers | ||
run: docker compose -f docker-compose.dev.yml down -v | ||
- name: Docker compouse UP new containers | ||
run: docker compose -f docker-compose.dev.yml up -d --build | ||
- name: Docker compouse MIGRATE models | ||
run: docker compose -f docker-compose.dev.yml exec web-dev python manage.py migrate --noinput | ||
- name: Clean up old docker resources | ||
run: | | ||
docker container prune -f | ||
docker image prune -f |
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,31 @@ | ||
name: Django CD PROD | ||
on: workflow_dispatch | ||
|
||
env: | ||
DEBUG: ${{ vars.PROD_DEBUG }} | ||
SECRET_KEY: ${{ secrets.PROD_SECRET_KEY }} | ||
ENGINE: ${{ vars.ENGINE }} | ||
HOST: ${{ vars.POSTGRES_HOST }} | ||
PORT: ${{ vars.POSTGRES_PORT }} | ||
DB: ${{ vars.PROD_DB }} | ||
USER: ${{ vars.POSTGRES_USER }} | ||
PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | ||
DATABASE: ${{ vars.POSTGRES_DB }} | ||
|
||
jobs: | ||
deploy: | ||
runs-on: self-hosted | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Docker compouse DOWN old containers | ||
run: docker compose -f docker-compose.prod.yml down -v | ||
- name: Docker compouse UP new containers | ||
run: docker compose -f docker-compose.prod.yml up -d --build | ||
- name: Docker compouse MIGRATE models | ||
run: docker compose -f docker-compose.prod.yml exec web-prod python manage.py migrate --noinput | ||
- name: Clean up old docker resources | ||
run: | | ||
docker container prune -f | ||
docker image prune -f |
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,55 @@ | ||
name: Django CI | ||
on: | ||
workflow_dispatch | ||
# push: | ||
# branches: ["main"] | ||
# pull_request: | ||
# branches: ["main"] | ||
env: | ||
DEBUG: ${{ vars.DEV_DEBUG }} | ||
SECRET_KEY: ${{ secrets.DEV_SECRET_KEY }} | ||
ENGINE: ${{ vars.ENGINE }} | ||
HOST: 127.0.0.1 | ||
PORT: ${{ vars.POSTGRES_PORT }} | ||
NAME: ${{ vars.DEV_DB }} | ||
USER: ${{ vars.POSTGRES_USER }} | ||
PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | ||
DB: db | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
max-parallel: 4 | ||
matrix: | ||
python-version: ["3.10"] | ||
services: | ||
postgres: | ||
image: postgres:14 | ||
env: | ||
POSTGRES_DB: db | ||
POSTGRES_USER: ${{ vars.POSTGRES_USER }} | ||
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | ||
ports: | ||
- 5432:5432 | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Dependencies | ||
run: | | ||
pip install --upgrade pip | ||
pip install -r ./requirements.txt | ||
- name: Run migrations | ||
run: python manage.py migrate | ||
- name: Run Tests | ||
run: python manage.py test | ||
|
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,19 @@ | ||
name: Frontend_Deploy | ||
on: workflow_dispatch | ||
|
||
|
||
jobs: | ||
deploy: | ||
runs-on: self-hosted | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Docker compouse DOWN old containers | ||
run: docker compose -f FrontEnd/docker-compose.yml down -v | ||
- name: Docker compouse UP new containers | ||
run: docker compose -f FrontEnd/docker-compose.yml up -d --build | ||
- name: Clean up old docker resources | ||
run: | | ||
docker container prune -f | ||
docker image prune -f |
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,18 @@ | ||
name: Nginx_Deploy | ||
on: workflow_dispatch | ||
|
||
jobs: | ||
deploy: | ||
runs-on: self-hosted | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Docker compouse DOWN old containers | ||
run: docker compose -f docker-compose.nginx.yml down -v | ||
- name: Docker compouse UP new containers | ||
run: docker compose -f docker-compose.nginx.yml up -d --build | ||
- name: Clean up old docker resources | ||
run: | | ||
docker container prune -f | ||
docker image prune -f |
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,34 @@ | ||
version: "3.8" | ||
|
||
services: | ||
db: | ||
image: postgres:14 | ||
container_name: db | ||
restart: always | ||
volumes: | ||
- ./configs/postgres:/docker-entrypoint-initdb.d | ||
- db_data:/var/lib/postgresql/data | ||
|
||
ports: | ||
- 5432:5432 | ||
environment: | ||
POSTGRES_MULTIPLE_DATABASES: ${DBS} | ||
POSTGRES_USER: ${POSTGRES_USER} | ||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} | ||
|
||
pgadmin: | ||
image: dpage/pgadmin4 | ||
restart: always | ||
ports: | ||
- 5050:80 | ||
environment: | ||
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL} | ||
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD} | ||
volumes: | ||
- pgadmin_data:/var/lib/pgadmin/data | ||
depends_on: | ||
- db | ||
|
||
volumes: | ||
db_data: | ||
pgadmin_data: |
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,23 @@ | ||
version: '3.9' | ||
|
||
services: | ||
web-dev: | ||
build: . | ||
container_name: web-dev | ||
restart: on-failure | ||
command: python manage.py runserver 0.0.0.0:8000 | ||
volumes: | ||
- ./:/Forum | ||
ports: | ||
- 8001:8000 | ||
environment: | ||
- DEBUG=${DEBUG} | ||
- SECRET_KEY=${SECRET_KEY} | ||
- ENGINE=${ENGINE} | ||
- HOST=${HOST} | ||
- PORT=${PORT} | ||
- DB=${DB} | ||
- USER=${USER} | ||
- PASSWORD=${PASSWORD} | ||
- DATABASE=${DATABASE} | ||
|
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,9 @@ | ||
version: '3.9' | ||
|
||
services: | ||
nginx: | ||
build: ./configs/nginx | ||
container_name: nginx | ||
ports: | ||
- 80:80 | ||
- 81:81 |
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,23 @@ | ||
version: '3.9' | ||
|
||
services: | ||
web-prod: | ||
build: . | ||
container_name: web-prod | ||
restart: on-failure | ||
command: python manage.py runserver 0.0.0.0:8000 | ||
volumes: | ||
- ./:/Forum | ||
ports: | ||
- 8000:8000 | ||
environment: | ||
- DEBUG=${DEBUG} | ||
- SECRET_KEY=${SECRET_KEY} | ||
- ENGINE=${ENGINE} | ||
- HOST=${HOST} | ||
- PORT=${PORT} | ||
- DB=${DB} | ||
- USER=${USER} | ||
- PASSWORD=${PASSWORD} | ||
- DATABASE=${DATABASE} | ||
|