-
Notifications
You must be signed in to change notification settings - Fork 2
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 #13 from CyrilBaah/dev
Add Ops files
- Loading branch information
Showing
41 changed files
with
689 additions
and
60 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,71 @@ | ||
name: Pull Request Checker | ||
|
||
on: | ||
push: | ||
branches: [ main, staging ] | ||
pull_request: | ||
branches: [ dev, staging, main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
SECRET_KEY: ${{ secrets.SECRET_KEY }} | ||
TEST_DATABASE_PREFIX: test_ | ||
|
||
services: | ||
postgres: | ||
image: postgres:latest | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: github_actions | ||
ports: | ||
- 5432:5432 | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Run tests | ||
run: | | ||
python manage.py test | ||
# - name: Run Flake8 | ||
# run: | | ||
# flake8 | ||
|
||
- name: Run Black | ||
run: | | ||
black --check . | ||
- name: Run isort | ||
run: | | ||
isort --check-only . | ||
# - name: Generate coverage report | ||
# run: | | ||
# coverage run --source='.' manage.py test | ||
# coverage report -m | ||
|
||
# - name: Upload coverage report to Codecov | ||
# uses: codecov/[email protected] | ||
# with: | ||
# flags: unittests | ||
# fail_ci_if_error: true | ||
# name: codecov-report | ||
# files: coverage.xml | ||
# env: | ||
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
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,30 @@ | ||
FROM python:3.8-slim-buster | ||
|
||
# Python environment setup | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# Create and set working directory | ||
ENV PROJECT=/home/app | ||
|
||
RUN mkdir -p ${PROJECT} | ||
RUN mkdir -p ${PROJECT}/static | ||
WORKDIR ${PROJECT} | ||
|
||
# Packages required for setting up WSGI | ||
RUN apt-get update | ||
RUN apt-get install -y --no-install-recommends gcc libc-dev python3-dev | ||
|
||
# Copy and install requirements | ||
RUN pip install --upgrade pip | ||
COPY ./requirements.txt ${PROJECT}/requirements.txt | ||
RUN pip install -r ${PROJECT}/requirements.txt | ||
|
||
# Copy project to working directory | ||
COPY . ${PROJECT} | ||
|
||
EXPOSE 8000 | ||
|
||
RUN chmod +x ./entrypoint.sh | ||
ENTRYPOINT ["sh", "/home/app/entrypoint.sh"] | ||
|
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,111 @@ | ||
# Define variables | ||
CLUSTER_NAME := dev | ||
IMAGE_NAME := fitnesstracker | ||
CONTAINER_NAME := fitnesstracker | ||
PORT := 8000 | ||
|
||
.PHONY: create-cluster get-cluster set-context delete-cluster install-nginxingresscontroller get-nginxingress get-logs cluster-info get-nodes get-pods expose-frontend build run stop remove remove-image ps ps-all images exec clean help | ||
|
||
create-cluster: | ||
@echo "Creating Kind cluster..." | ||
kind create cluster --config config.yml --name $(CLUSTER_NAME) | ||
|
||
get-cluster: | ||
@echo "Getting Kind clusters..." | ||
kind get clusters | ||
|
||
set-context: | ||
@echo "Setting kubectl context to $(CLUSTER_NAME)..." | ||
kubectl config use-context kind-$(CLUSTER_NAME) | ||
|
||
delete-cluster: | ||
@echo "Deleting Kind cluster..." | ||
kind delete cluster --name $(CLUSTER_NAME) | ||
|
||
push-image: | ||
docker push cyrilbaah/fitnesstracker:latest | ||
|
||
install-nginxingresscontroller: | ||
@echo "Install NGINX Ingress Controller..." | ||
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/kind/deploy.yaml | ||
|
||
get-nginxingress: | ||
@echo "Get nginxingress pods..." | ||
kubectl get pods -n ingress-nginx -owide | ||
|
||
get-logs: | ||
@echo "Get pods for logs command..." | ||
@echo "$ kubectl logs -f <name-app-xxx>" | ||
|
||
cluster-info: | ||
@echo "Get cluster information..." | ||
kubectl cluster-info --context kind-$(CLUSTER_NAME) | ||
|
||
get-nodes: | ||
@echo "Get cluster nodes..." | ||
kubectl get nodes -owide | ||
|
||
get-pods: | ||
@echo "Get cluster pods..." | ||
kubectl get pods -owide | ||
|
||
expose-backend: | ||
@echo "Get port for backend..." | ||
kubectl port-forward svc/$(CONTAINER_NAME) -n default 8000:8000 | ||
|
||
build: | ||
docker build -t cyrilbaah/$(IMAGE_NAME) . | ||
|
||
run: | ||
docker run -d -p $(PORT):$(PORT) --name $(CONTAINER_NAME) $(IMAGE_NAME) | ||
|
||
stop: | ||
docker stop $(CONTAINER_NAME) | ||
|
||
remove: | ||
docker rm $(CONTAINER_NAME) | ||
|
||
remove-image: | ||
docker rmi $(IMAGE_NAME) | ||
|
||
ps: | ||
docker ps | ||
|
||
ps-all: | ||
docker ps -a | ||
|
||
images: | ||
docker images | ||
|
||
exec: | ||
docker exec -it $(CONTAINER_NAME) bash | ||
|
||
clean: | ||
docker stop $(shell docker ps -aq) || true | ||
docker rm $(shell docker ps -aq) || true | ||
docker rmi $(shell docker images -aq) || true | ||
|
||
help: | ||
@echo "Available targets:" | ||
@echo " create-cluster - Create the Kind cluster" | ||
@echo " get-cluster - List available Kind clusters" | ||
@echo " set-context - Set kubectl context to the Kind cluster" | ||
@echo " delete-cluster - Delete the Kind cluster" | ||
@echo " get-pods - List all pods" | ||
@echo " get-nodes - List all nodes" | ||
@echo " expose-backend - Makes backend app accessible" | ||
@echo " get-nginxingress - List all nginx ingress" | ||
@echo " get-logs - Get logs command" | ||
@echo " build - Build Docker image" | ||
@echo " run - Run Docker container in detached mode" | ||
@echo " stop - Stop Docker container" | ||
@echo " remove - Remove Docker container" | ||
@echo " remove-image - Remove Docker image" | ||
@echo " ps - View running containers" | ||
@echo " ps-all - View all containers (including stopped ones)" | ||
@echo " images - View Docker images" | ||
@echo " exec - Execute a command inside the running container" | ||
@echo " clean - Clean up (stop and remove) all containers and images" | ||
@echo " help - Display this help message" | ||
|
||
.DEFAULT_GOAL := help |
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
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,3 +0,0 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. | ||
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.