-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated the dockerfile, docker compose and cd files to reflect the do…
…cker changes
- Loading branch information
1 parent
3426b34
commit 7f96b2a
Showing
14 changed files
with
360 additions
and
70 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 |
---|---|---|
@@ -1,35 +1,40 @@ | ||
name: Dev Branch Deployment | ||
|
||
name: Dev cd pipeline | ||
on: | ||
workflow_run: | ||
workflows: ["CI"] | ||
types: | ||
- completed | ||
branches: [dev] | ||
push: | ||
branches: [devops] | ||
|
||
jobs: | ||
on-success: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use SSH Action | ||
- name: Build image | ||
run: docker build -t anchor-python-bp-dev:latest -f Dockerfile . | ||
|
||
- name: Save image | ||
run: docker save anchor-python-bp-dev:latest | gzip > dev.tar.gz | ||
|
||
- name: Copy image to server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
source: "dev.tar.gz" | ||
target: "/home/${{ secrets.USERNAME }}/boilerplate-python/dev_source_code" | ||
|
||
- name: Deploy image on server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
script: | | ||
cd python/dev_source_code/ | ||
git pull origin dev | ||
source .venv/bin/activate | ||
pip install -r requirements.txt | ||
alembic upgrade head | ||
cd /home/${{ secrets.USERNAME }}/boilerplate-python/dev_source_code | ||
git pull origin devops | ||
docker load --input dev.tar.gz | ||
docker compose -f docker-compose.yml up -d | ||
rm -f dev.tar.gz | ||
on-failure: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | ||
steps: | ||
- run: echo 'The triggering workflow failed' |
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,35 @@ | ||
name: Dev Branch Deployment | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["CI"] | ||
types: | ||
- completed | ||
branches: [dev] | ||
|
||
jobs: | ||
on-success: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use SSH Action | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
script: | | ||
cd python/dev_source_code/ | ||
git pull origin dev | ||
source .venv/bin/activate | ||
pip install -r requirements.txt | ||
alembic upgrade head | ||
|
||
on-failure: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | ||
steps: | ||
- run: echo 'The triggering workflow failed' |
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 |
---|---|---|
@@ -1,35 +1,39 @@ | ||
name: Prod Branch Deployment | ||
|
||
name: Prod cd pipeline | ||
on: | ||
workflow_run: | ||
workflows: ["CI"] | ||
types: | ||
- completed | ||
branches: [main] | ||
push: | ||
branches: [dev] | ||
|
||
jobs: | ||
on-success: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use SSH Action | ||
- name: Build image | ||
run: docker build -t anchor-python-bp-prod:latest -f docker/prod/Dockerfile . | ||
|
||
- name: Save image | ||
run: docker save anchor-python-bp-prod:latest | gzip > prod.tar.gz | ||
|
||
- name: Copy image to server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
source: "prod.tar.gz" | ||
target: "/home/${{ secrets.USERNAME }}/boilerplate-python/prod_source_code/docker/prod" | ||
|
||
- name: Deploy image on server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
script: | | ||
cd python/prod_source_code/ | ||
cd /home/${{ secrets.USERNAME }}/boilerplate-python/prod_source_code/docker/prod | ||
git pull origin main | ||
source .venv/bin/activate | ||
pip install -r requirements.txt | ||
alembic upgrade head | ||
on-failure: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | ||
steps: | ||
- run: echo 'The triggering workflow failed' | ||
docker load --input prod.tar.gz | ||
docker compose -f docker-compose.yml up -d | ||
rm -f prod.tar.gz |
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,35 @@ | ||
name: Prod Branch Deployment | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["CI"] | ||
types: | ||
- completed | ||
branches: [main] | ||
|
||
jobs: | ||
on-success: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use SSH Action | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
script: | | ||
cd python/prod_source_code/ | ||
git pull origin main | ||
source .venv/bin/activate | ||
pip install -r requirements.txt | ||
alembic upgrade head | ||
|
||
on-failure: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | ||
steps: | ||
- run: echo 'The triggering workflow failed' |
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 |
---|---|---|
@@ -1,35 +1,39 @@ | ||
name: Staging Branch Deployment | ||
|
||
name: Staging cd pipeline | ||
on: | ||
workflow_run: | ||
workflows: ["CI"] | ||
types: | ||
- completed | ||
push: | ||
branches: [staging] | ||
|
||
jobs: | ||
on-success: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use SSH Action | ||
- name: Build image | ||
run: docker build -t anchor-python-bp-staging:latest -f docker/staging/Dockerfile . | ||
|
||
- name: Save image | ||
run: docker save anchor-python-bp-staging:latest | gzip > staging.tar.gz | ||
|
||
- name: Copy image to server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
source: "staging.tar.gz" | ||
target: "/home/${{ secrets.USERNAME }}/boilerplate-python/staging_source_code/docker/staging" | ||
|
||
- name: Deploy image on server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
script: | | ||
cd python/staging_source_code/ | ||
cd /home/${{ secrets.USERNAME }}/boilerplate-python/staging_source_code/docker/staging | ||
git pull origin staging | ||
source .venv/bin/activate | ||
pip install -r requirements.txt | ||
alembic upgrade head | ||
on-failure: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | ||
steps: | ||
- run: echo 'The triggering workflow failed' | ||
docker load --input staging.tar.gz | ||
docker compose -f docker-compose.yml up -d | ||
rm -f staging.tar.gz |
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,35 @@ | ||
name: Staging Branch Deployment | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["CI"] | ||
types: | ||
- completed | ||
branches: [staging] | ||
|
||
jobs: | ||
on-success: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use SSH Action | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
script: | | ||
cd python/staging_source_code/ | ||
git pull origin staging | ||
source .venv/bin/activate | ||
pip install -r requirements.txt | ||
alembic upgrade head | ||
|
||
on-failure: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | ||
steps: | ||
- run: echo 'The triggering workflow failed' |
File renamed without changes.
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,50 @@ | ||
name: Test | ||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, closed] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
postgres: | ||
image: postgres:latest | ||
env: | ||
POSTGRES_USER: "username" | ||
POSTGRES_PASSWORD: "password" | ||
POSTGRES_DB: "test" | ||
ports: | ||
- 5432:5432 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.12" | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Install dependencies | ||
run: | | ||
pip install -r requirements.txt | ||
- name: Copy env file | ||
run: cp .env.sample .env | ||
|
||
- name: Run migrations | ||
run: | | ||
alembic upgrade head | ||
- name: Run tests | ||
run: | | ||
PYTHONPATH=. pytest |
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
Oops, something went wrong.