Skip to content

Commit

Permalink
refactor: ♻️ change code structure to new version of testcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdihadeli committed Mar 11, 2023
1 parent a02bcd3 commit c5805c7
Show file tree
Hide file tree
Showing 54 changed files with 1,318 additions and 311 deletions.
162 changes: 162 additions & 0 deletions .bash_aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# This command is used a LOT both below and in daily life
alias k=kubectl

# Execute a kubectl command against all namespaces
alias kca='_kca(){ kubectl "$@" --all-namespaces; unset -f _kca; }; _kca'

# Apply a YML file
alias kaf='kubectl apply -f'

# Drop into an interactive terminal on a container
alias keti='kubectl exec -t -i'

# Manage configuration quickly to switch contexts between local, dev ad staging.
alias kcuc='kubectl config use-context'
alias kcsc='kubectl config set-context'
alias kcdc='kubectl config delete-context'
alias kccc='kubectl config current-context'

# List all contexts
alias kcgc='kubectl config get-contexts'

# General aliases
alias kdel='kubectl delete'
alias kdelf='kubectl delete -f'

# Pod management.
alias kgp='kubectl get pods'
alias kgpa='kubectl get pods --all-namespaces'
alias kgpw='kgp --watch'
alias kgpwide='kgp -o wide'
alias kep='kubectl edit pods'
alias kdp='kubectl describe pods'
alias kdelp='kubectl delete pods'
alias kgpall='kubectl get pods --all-namespaces -o wide'

# get pod by label: kgpl "app=myapp" -n myns
alias kgpl='kgp -l'

# get pod by namespace: kgpn kube-system"
alias kgpn='kgp -n'

# Service management.
alias kgs='kubectl get svc'
alias kgsa='kubectl get svc --all-namespaces'
alias kgsw='kgs --watch'
alias kgswide='kgs -o wide'
alias kes='kubectl edit svc'
alias kds='kubectl describe svc'
alias kdels='kubectl delete svc'

# Ingress management
alias kgi='kubectl get ingress'
alias kgia='kubectl get ingress --all-namespaces'
alias kei='kubectl edit ingress'
alias kdi='kubectl describe ingress'
alias kdeli='kubectl delete ingress'

# Namespace management
alias kgns='kubectl get namespaces'
alias kens='kubectl edit namespace'
alias kdns='kubectl describe namespace'
alias kdelns='kubectl delete namespace'
alias kcn='kubectl config set-context --current --namespace'

# ConfigMap management
alias kgcm='kubectl get configmaps'
alias kgcma='kubectl get configmaps --all-namespaces'
alias kecm='kubectl edit configmap'
alias kdcm='kubectl describe configmap'
alias kdelcm='kubectl delete configmap'

# Secret management
alias kgsec='kubectl get secret'
alias kgseca='kubectl get secret --all-namespaces'
alias kdsec='kubectl describe secret'
alias kdelsec='kubectl delete secret'

# Deployment management.
alias kgd='kubectl get deployment'
alias kgda='kubectl get deployment --all-namespaces'
alias kgdw='kgd --watch'
alias kgdwide='kgd -o wide'
alias ked='kubectl edit deployment'
alias kdd='kubectl describe deployment'
alias kdeld='kubectl delete deployment'
alias ksd='kubectl scale deployment'
alias krsd='kubectl rollout status deployment'

# Rollout management.
alias kgrs='kubectl get replicaset'
alias kdrs='kubectl describe replicaset'
alias kers='kubectl edit replicaset'
alias krh='kubectl rollout history'
alias kru='kubectl rollout undo'

# Statefulset management.
alias kgss='kubectl get statefulset'
alias kgssa='kubectl get statefulset --all-namespaces'
alias kgssw='kgss --watch'
alias kgsswide='kgss -o wide'
alias kess='kubectl edit statefulset'
alias kdss='kubectl describe statefulset'
alias kdelss='kubectl delete statefulset'
alias ksss='kubectl scale statefulset'
alias krsss='kubectl rollout status statefulset'

# Port forwarding
alias kpf="kubectl port-forward"

# Tools for accessing all information
alias kga='kubectl get all'
alias kgaa='kubectl get all --all-namespaces'

# Logs
alias kl='kubectl logs'
alias kl1h='kubectl logs --since 1h'
alias kl1m='kubectl logs --since 1m'
alias kl1s='kubectl logs --since 1s'
alias klf='kubectl logs -f'
alias klf1h='kubectl logs --since 1h -f'
alias klf1m='kubectl logs --since 1m -f'
alias klf1s='kubectl logs --since 1s -f'

# File copy
alias kcp='kubectl cp'

# Node Management
alias kgno='kubectl get nodes'
alias keno='kubectl edit node'
alias kdno='kubectl describe node'
alias kdelno='kubectl delete node'

# PVC management.
alias kgpvc='kubectl get pvc'
alias kgpvca='kubectl get pvc --all-namespaces'
alias kgpvcw='kgpvc --watch'
alias kepvc='kubectl edit pvc'
alias kdpvc='kubectl describe pvc'
alias kdelpvc='kubectl delete pvc'

# Service account management.
alias kdsa="kubectl describe sa"
alias kdelsa="kubectl delete sa"

# DaemonSet management.
alias kgds='kubectl get daemonset'
alias kgdsw='kgds --watch'
alias keds='kubectl edit daemonset'
alias kdds='kubectl describe daemonset'
alias kdelds='kubectl delete daemonset'

# CronJob management.
alias kgcj='kubectl get cronjob'
alias kecj='kubectl edit cronjob'
alias kdcj='kubectl describe cronjob'
alias kdelcj='kubectl delete cronjob'

# Job management.
alias kgj='kubectl get job'
alias kej='kubectl edit job'
alias kdj='kubectl describe job'
alias kdelj='kubectl delete job'
42 changes: 6 additions & 36 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,12 @@
"label": "docker-build-dev: catalogs",
"command": "docker build --target final -f ${workspaceFolder}/src/Services/Catalogs/dev.Dockerfile --tag catalogs:dev ${workspaceFolder}", //--no-cache
"type": "shell",
"dependsOn": [
"build: catalogs"
],
"problemMatcher": []
},
{
"label": "docker-build-prod: catalogs",
"command": "docker build --target final -f ${workspaceFolder}/src/Services/Catalogs/Dockerfile --tag catalogs:prod ${workspaceFolder}", //--no-cache
"type": "shell",
"dependsOn": [
"build: catalogs"
],
"problemMatcher": []
},
//https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container
Expand All @@ -95,9 +89,6 @@
"label": "docker-build-base: catalogs",
"command": "docker build --target base -f ${workspaceFolder}/src/Services/Catalogs/dev.Dockerfile --tag catalogs:base ${workspaceFolder}",
"type": "shell",
"dependsOn": [
"build: catalogs"
],
"problemMatcher": []
},
// for see data inner container `docker exec -it catalogs-debug`
Expand Down Expand Up @@ -260,9 +251,6 @@
"label": "docker-build-dev: customers",
"command": "docker build --target final -f ${workspaceFolder}/src/Services/Customers/dev.Dockerfile --tag customers:dev ${workspaceFolder}", //--no-cache
"type": "shell",
"dependsOn": [
"build: customers"
],
"problemMatcher": []
},
//https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container
Expand All @@ -281,9 +269,6 @@
"label": "docker-build-base: customers",
"command": "docker build --target base -f ${workspaceFolder}/src/Services/Customers/dev.Dockerfile --tag customers:base ${workspaceFolder}",
"type": "shell",
"dependsOn": [
"build: customers"
],
"problemMatcher": []
},
// for see data inner container `docker exec -it customers-debug`
Expand Down Expand Up @@ -437,9 +422,6 @@
"label": "docker-build-dev: identity",
"command": "docker build --target final -f ${workspaceFolder}/src/Services/Identity/dev.Dockerfile --tag identity:dev ${workspaceFolder}", //--no-cache
"type": "shell",
"dependsOn": [
"build: identity"
],
"problemMatcher": []
},
//https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container
Expand All @@ -461,9 +443,6 @@
"label": "docker-build-base: identity",
"command": "docker build --target base -f ${workspaceFolder}/src/Services/Identity/dev.Dockerfile --tag identity:base ${workspaceFolder}",
"type": "shell",
"dependsOn": [
"build: identity"
],
"problemMatcher": []
},
// for see data inner container `docker exec -it identity-debug`
Expand Down Expand Up @@ -617,9 +596,6 @@
"label": "docker-build-dev: orders",
"command": "docker build --target final -f ${workspaceFolder}/src/Services/Orders/dev.Dockerfile --tag orders:dev ${workspaceFolder}", //--no-cache
"type": "shell",
"dependsOn": [
"build: orders"
],
"problemMatcher": []
},
//https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container
Expand All @@ -638,9 +614,6 @@
"label": "docker-build-base: orders",
"command": "docker build --target base -f ${workspaceFolder}/src/Services/Orders/dev.Dockerfile --tag orders:base ${workspaceFolder}",
"type": "shell",
"dependsOn": [
"build: orders"
],
"problemMatcher": []
},
// for see data inner container `docker exec -it orders-debug`
Expand Down Expand Up @@ -795,9 +768,6 @@
"label": "docker-build-dev: gateway",
"command": "docker build --target final -f ${workspaceFolder}/src/ApiGateway/dev.Dockerfile --tag gateway:dev ${workspaceFolder}", //--no-cache
"type": "shell",
"dependsOn": [
"build: gateway"
],
"problemMatcher": []
},
//https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container
Expand All @@ -816,9 +786,6 @@
"label": "docker-build-base: gateway",
"command": "docker build --target base -f ${workspaceFolder}/src/ApiGateway/dev.Dockerfile --tag gateway:base ${workspaceFolder}",
"type": "shell",
"dependsOn": [
"build: gateway"
],
"problemMatcher": []
},
// for see data inner container `docker exec -it gateway-debug`
Expand Down Expand Up @@ -928,7 +895,8 @@
// https://docs.docker.com/compose/reference/#use--f-to-specify-name-and-path-of-one-or-more-compose-files
// https://docs.docker.com/compose/extends/
// to remove containers we use `docker-compose down`
"command": "docker-compose -f ${workspaceFolder}/deployments/docker-compose/docker-compose.services.yaml -f ${workspaceFolder}/deployments/docker-compose/docker-compose.services.debug.yaml up -d",
//https://docs.docker.com/compose/environment-variables/set-environment-variables/#substitute-with---env-file
"command": "docker-compose -f ${workspaceFolder}/deployments/docker-compose/docker-compose.services.yaml -f ${workspaceFolder}/deployments/docker-compose/docker-compose.services.debug.yaml --env-file ${workspaceFolder}/deployments/docker-compose/.env --env-file ${workspaceFolder}/deployments/docker-compose/.env.dev up -d",
"problemMatcher": [],
"presentation": {
"reveal": "always",
Expand Down Expand Up @@ -975,7 +943,8 @@
// https://docs.docker.com/compose/reference/#use--f-to-specify-name-and-path-of-one-or-more-compose-files
// https://docs.docker.com/compose/extends/
// to remove containers we use `docker-compose down`
"command": "docker-compose -f ${workspaceFolder}/deployments/docker-compose/docker-compose.services.yaml -f ${workspaceFolder}/deployments/docker-compose/docker-compose.services.dev.yaml up",
//https://docs.docker.com/compose/environment-variables/set-environment-variables/#substitute-with---env-file
"command": "docker-compose -f ${workspaceFolder}/deployments/docker-compose/docker-compose.services.yaml -f ${workspaceFolder}/deployments/docker-compose/docker-compose.services.dev.yaml --env-file ${workspaceFolder}/deployments/docker-compose/.env --env-file ${workspaceFolder}/deployments/docker-compose/.env.dev up",
"problemMatcher": [],
"presentation": {
"reveal": "always",
Expand Down Expand Up @@ -1005,7 +974,8 @@
// https://docs.docker.com/compose/reference/#use--f-to-specify-name-and-path-of-one-or-more-compose-files
// https://docs.docker.com/compose/extends/
// to remove containers we use `docker-compose down`
"command": "docker-compose -f ${workspaceFolder}/deployments/docker-compose/docker-compose.services.yaml up",
//https://docs.docker.com/compose/environment-variables/set-environment-variables/#substitute-with---env-file
"command": "docker-compose -f ${workspaceFolder}/deployments/docker-compose/docker-compose.services.yaml --env-file ${workspaceFolder}/deployments/docker-compose/.env --env-file ${workspaceFolder}/deployments/docker-compose/.env.prod up",
"problemMatcher": [],
"presentation": {
"reveal": "always",
Expand Down
22 changes: 21 additions & 1 deletion deployments/docker-compose/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# This needs to be configured by each developer based on their platform, we also ask people to tell git to ignore changes to the file by running `git update-index --assume-unchanged .env`
# https://docs.docker.com/compose/environment-variables/env-file/

TAG=latest
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
Expand All @@ -16,11 +18,29 @@ ORDERS_HTTPs_SVC_PORT=5001
IDENTITY_HTTP_SVC_PORT=7000
IDENTITY_HTTPS_SVC_PORT=7001
ASPNETCORE_ENVIRONMENT=docker
DOTNET_PATH=C:\Program Files\dotnet
REGISTRY=ghcr.io
PROJECT_NAME=mehdihadeli/ecommerce-microservices
#https://docs.docker.com/compose/environment-variables/set-environment-variables/#substitute-from-the-shell
#https://github.com/docker/compose/issues/5089
#https://docs.docker.com/compose/environment-variables/env-file/#parameter-expansion
HOME=${HOME}
DEV_CERT_PASSWORD=${DEV_CERT_PASSWORD:-123456}
ConfigurationFolder=config-files/
GRAFANA_PORT=3000
GRAFANA_HOST_PORT=3000
PROMETHEUS_PORT=9090
PROMETHEUS_HOST_PORT=9090
KIBANA_PORT=5601
KIBANA_HOST_PORT=5601
ELASTIC_PORT=9200
ELASTIC_HOST_PORT=9200
EVENTSTORE_PORT=2113
EVENTSTORE_HOST_PORT=2113
POSTGRES_PORT=5432
POSTGRES_HOST_PORT=5432
RABBITMQ_PORT=5672
RABBITMQ_HOST_PORT=5672
RABBITMQ_API_PORT=15672
RABBITMQ_HOST_API_PORT=15672
MONGO_PORT=27017
MONGO_HOST_PORT=27017
5 changes: 5 additions & 0 deletions deployments/docker-compose/.env.catalogs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#https://docs.docker.com/compose/environment-variables/set-environment-variables/#use-the-env_file-attribute
# https://levelup.gitconnected.com/docker-environment-variables-appsettings-json-net-bdac052bf3db

PostgresOptions__ConnectionString=Server=postgres;Port=5432;Database=ECommerce.Services.Catalogs;User Id=postgres;Password=postgres;Include Error Detail=true
PostgresOptions__UseInMemory=false
5 changes: 5 additions & 0 deletions deployments/docker-compose/.env.customers
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#https://docs.docker.com/compose/environment-variables/set-environment-variables/#use-the-env_file-attribute
# https://levelup.gitconnected.com/docker-environment-variables-appsettings-json-net-bdac052bf3db

PostgresOptions__ConnectionString=Server=postgres;Port=5432;Database=ECommerce.Services.Customers;User Id=postgres;Password=postgres;Include Error Detail=true
PostgresOptions__UseInMemory=false
2 changes: 2 additions & 0 deletions deployments/docker-compose/.env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#https://docs.docker.com/compose/environment-variables/set-environment-variables/#substitute-with---env-file
#https://docs.docker.com/compose/environment-variables/env-file/
5 changes: 5 additions & 0 deletions deployments/docker-compose/.env.identity
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#https://docs.docker.com/compose/environment-variables/set-environment-variables/#use-the-env_file-attribute
# https://levelup.gitconnected.com/docker-environment-variables-appsettings-json-net-bdac052bf3db

PostgresOptions__ConnectionString=Server=postgres;Port=5432;Database=ECommerce.Services.Identity;User Id=postgres;Password=postgres;Include Error Detail=true
PostgresOptions__UseInMemory=false
2 changes: 2 additions & 0 deletions deployments/docker-compose/.env.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#https://docs.docker.com/compose/environment-variables/set-environment-variables/#substitute-with---env-file
#https://docs.docker.com/compose/environment-variables/env-file/
2 changes: 0 additions & 2 deletions deployments/docker-compose/catalogs.env

This file was deleted.

2 changes: 0 additions & 2 deletions deployments/docker-compose/customers.env

This file was deleted.

0 comments on commit c5805c7

Please sign in to comment.