diff --git a/.gitignore b/.gitignore index fefec8b..ee48fdf 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ __pycache__/ *.py[cod] *$py.class -migrations/ \ No newline at end of file +migrations/ +.env \ No newline at end of file diff --git a/Sample.env b/Sample.env new file mode 100644 index 0000000..eb7885f --- /dev/null +++ b/Sample.env @@ -0,0 +1 @@ +KEY= \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..935de93 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,124 @@ +# docker-compose.deploy.yml +version: '3.8' + +volumes: + userdb_vol: + productdb_vol: + orderdb_vol: + +networks: + micro_network: +# external: + name: micro_network + +services: + user-api: + container_name: cuser-service + build: + context: user-service + ports: + - "5001:5001" + depends_on: + - user-db +# entrypoint: flask db init + networks: + - micro_network + restart: always + + user-db: + container_name: cuser_dbase + image: mysql:8 + ports: + - "32000:3306" + environment: + MYSQL_ROOT_PASSWORD: pfm_dc_2020 + MYSQL_DATABASE: user + MYSQL_USER: cloudacademy + MYSQL_PASSWORD: pfm_2020 + networks: + - micro_network + volumes: + - userdb_vol:/var/lib/mysql + + product-api: + container_name: cproduct-service + build: + context: product-service + ports: + - "5002:5002" + depends_on: + - product-db +# entrypoint: flask db init +# command: "flask db init && flask db migrate && flask db upgrade" + networks: + - micro_network + restart: always + + product-db: + container_name: cproduct_dbase + image: mysql:8 + ports: + - "32001:3306" + environment: + MYSQL_ROOT_PASSWORD: pfm_dc_2020 + MYSQL_DATABASE: product + MYSQL_USER: cloudacademy + MYSQL_PASSWORD: pfm_2020 + networks: + - micro_network + volumes: + - productdb_vol:/var/lib/mysql + + order-api: + container_name: corder-service + build: + context: order-service + ports: + - "5003:5003" +# entrypoint: flask db init +# command: "flask db init && flask db migrate && flask db upgrade" + depends_on: + - order-db + networks: + - micro_network + restart: always + + order-db: + container_name: corder_dbase + image: mysql:8 + ports: + - "32002:3306" + environment: + MYSQL_ROOT_PASSWORD: pfm_dc_2020 + MYSQL_DATABASE: order + MYSQL_USER: cloudacademy + MYSQL_PASSWORD: pfm_2020 + networks: + - micro_network + volumes: + - orderdb_vol:/var/lib/mysql + + frontend-app: + container_name: cfrontend-app + build: + context: frontend + ports: + - "5000:5000" + networks: + - micro_network + restart: always + + datadog: + container_name: datadog-agent + image: datadog/agent:latest + links: + - demo-server + environment: + - DD_API_KEY=${KEY} +# - DD_SITE="datadoghq.com" + networks: + - micro_network + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - /proc/:/host/proc/:ro + - /sys/fs/cgroup:/host/sys/fs/cgroup:ro \ No newline at end of file diff --git a/frontend/JenkinsFile.txt b/frontend/JenkinsFile.txt new file mode 100644 index 0000000..cab8a16 --- /dev/null +++ b/frontend/JenkinsFile.txt @@ -0,0 +1,54 @@ +pipeline { + agent any + environment { + //once you sign up for Docker hub, use that user_id here + registry = "ajitha1234/frontend" + //- update your credentials ID after creating credentials for connecting to Docker Hub + registryCredential = 'd425a730-28cb-4552-8505-9ed3beb008d5' + dockerImage = '' + } + + stages { + stage('build') { + steps { + checkout([$class: 'GitSCM', branches: [[name: '*/JenkinsFile']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/vinay-sj/python-flask-microservices.git']]]) + + } + } + + // Building Docker images + stage('Building image') { + steps { + echo "Working" + + } + } + + // Uploading Docker images into Docker Hub + stage('Upload Image') { + steps { + echo "Working" + + } + } + + // Stopping Docker containers for cleaner Docker run + stage('docker stop container') { + steps { + echo "Working" + + } + } + + + // Running Docker container, make sure port 8096 is opened in + stage('Docker Run') { + steps { + echo "Working" + + } + } + + } + +} diff --git a/frontend/docker-compose.yml b/frontend/docker-compose.yml index 33eb4a0..5975c12 100644 --- a/frontend/docker-compose.yml +++ b/frontend/docker-compose.yml @@ -3,8 +3,7 @@ version: '3.8' networks: micro_network: - external: - name: micro_network + name: micro_network services: frontend-app: