From 5f3035e2125295aeea1ba59c3062399040803a72 Mon Sep 17 00:00:00 2001 From: mmuniraju4444 <11813475+mmuniraju4444@users.noreply.github.com> Date: Sun, 7 Jun 2020 22:25:49 +0530 Subject: [PATCH] Add NodeJs and Golang --- .env.example | 3 ++ .gitignore | 1 + GoLang/.env.example | 1 + GoLang/.gitignore | 1 + GoLang/Dockerfile | 4 +++ Nginx/.gitignore | 3 +- Nginx/conf/{app.conf => example.conf} | 23 +++++++++++++++ NodeJs/.env.example | 3 ++ NodeJs/.gitignore | 1 + NodeJs/Dockerfile | 4 +++ Supervisor/config/supervisord.pid | 1 + docker-compose.yml.example | 42 +++++++++++++++++++++++++++ 12 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 GoLang/.env.example create mode 100644 GoLang/.gitignore create mode 100644 GoLang/Dockerfile rename Nginx/conf/{app.conf => example.conf} (77%) create mode 100644 NodeJs/.env.example create mode 100644 NodeJs/.gitignore create mode 100644 NodeJs/Dockerfile create mode 100644 Supervisor/config/supervisord.pid diff --git a/.env.example b/.env.example index aed7337..bdd7547 100644 --- a/.env.example +++ b/.env.example @@ -10,6 +10,8 @@ CADVISOR_VER=latest COMPOSER_VER=1.8.5 SONARQUBE_VER=7.1 BROWSERLESS_VER=latest +NODEJS_VER=12.16.3 +GOLANG_VER=1.13.7 ########### END CONTAINER VERSIONS ########## ########### INSTALL PHP EXTENSION ########### @@ -32,4 +34,5 @@ HOST2=example2.com HOST3=example3.com HOST4=example4.com HOST5=example5.com +HOST6=example6.com ############# END EXTRA HOST ############ diff --git a/.gitignore b/.gitignore index 3896dae..fe8d770 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /docker-compose.yml /.idea /.idea/* +.DS_Store diff --git a/GoLang/.env.example b/GoLang/.env.example new file mode 100644 index 0000000..d88c593 --- /dev/null +++ b/GoLang/.env.example @@ -0,0 +1 @@ +GOPATH=/go \ No newline at end of file diff --git a/GoLang/.gitignore b/GoLang/.gitignore new file mode 100644 index 0000000..4cb512e --- /dev/null +++ b/GoLang/.gitignore @@ -0,0 +1 @@ +/.env \ No newline at end of file diff --git a/GoLang/Dockerfile b/GoLang/Dockerfile new file mode 100644 index 0000000..8d9fb28 --- /dev/null +++ b/GoLang/Dockerfile @@ -0,0 +1,4 @@ +ARG CONTAINER_VERSION=${CONTAINER_VERSION} +FROM golang:${CONTAINER_VERSION}-alpine3.11 + +WORKDIR /usr/src/app \ No newline at end of file diff --git a/Nginx/.gitignore b/Nginx/.gitignore index 4cb512e..2470d03 100644 --- a/Nginx/.gitignore +++ b/Nginx/.gitignore @@ -1 +1,2 @@ -/.env \ No newline at end of file +/.env +/conf/app.conf \ No newline at end of file diff --git a/Nginx/conf/app.conf b/Nginx/conf/example.conf similarity index 77% rename from Nginx/conf/app.conf rename to Nginx/conf/example.conf index 3d87b2d..2cc053f 100644 --- a/Nginx/conf/app.conf +++ b/Nginx/conf/example.conf @@ -75,3 +75,26 @@ server { proxy_cache_bypass $http_upgrade; } } + +server { + listen 80; + server_name mmtinyurl.local; + + location /api { + proxy_pass http://mmtinyurl-backend:8080/api; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + } + + location / { + proxy_pass http://mmtinyurl:3001; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + } +} diff --git a/NodeJs/.env.example b/NodeJs/.env.example new file mode 100644 index 0000000..35f2b4a --- /dev/null +++ b/NodeJs/.env.example @@ -0,0 +1,3 @@ +NODE_ENV=development +CHOKIDAR_USEPOLLING=true +PORT=3001 \ No newline at end of file diff --git a/NodeJs/.gitignore b/NodeJs/.gitignore new file mode 100644 index 0000000..4cb512e --- /dev/null +++ b/NodeJs/.gitignore @@ -0,0 +1 @@ +/.env \ No newline at end of file diff --git a/NodeJs/Dockerfile b/NodeJs/Dockerfile new file mode 100644 index 0000000..167038c --- /dev/null +++ b/NodeJs/Dockerfile @@ -0,0 +1,4 @@ +ARG CONTAINER_VERSION=${CONTAINER_VERSION} +FROM node:${CONTAINER_VERSION}-alpine3.11 +CMD npm start +#ENTRYPOINT ["npm", "start"] diff --git a/Supervisor/config/supervisord.pid b/Supervisor/config/supervisord.pid new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Supervisor/config/supervisord.pid @@ -0,0 +1 @@ +1 diff --git a/docker-compose.yml.example b/docker-compose.yml.example index 1e3949c..c7963d9 100644 --- a/docker-compose.yml.example +++ b/docker-compose.yml.example @@ -64,6 +64,7 @@ services: - "${HOST3}:${HOST_IP}" - "${HOST4}:${HOST_IP}" - "${HOST5}:${HOST_IP}" + - "${HOST6}:${HOST_IP}" # CADVISOR cadvisor : @@ -106,6 +107,7 @@ services: - "${HOST3}:${HOST_IP}" - "${HOST4}:${HOST_IP}" - "${HOST5}:${HOST_IP}" + - "${HOST6}:${HOST_IP}" depends_on: - php-fpm - mariadb-master @@ -245,6 +247,7 @@ services: - "${HOST3}:${HOST_IP}" - "${HOST4}:${HOST_IP}" - "${HOST5}:${HOST_IP}" + - "${HOST6}:${HOST_IP}" volumes: - ./Source:/var/www/html - ./Supervisor/config:/etc/supervisor/config @@ -264,3 +267,42 @@ services: - "${HOST3}:${HOST_IP}" - "${HOST4}:${HOST_IP}" - "${HOST5}:${HOST_IP}" + - "${HOST6}:${HOST_IP}" + + # NodeJs + mmtinyurl: + build: + context: ./NodeJs + dockerfile: Dockerfile + args: + - CONTAINER_VERSION=${NODEJS_VER} + working_dir: /var/www/html/urlshortner + tty: true + command: "npm start" + volumes: + - ./Source:/var/www/html + env_file: + - ./NodeJs/.env + extra_hosts: + - "${HOST1}:${HOST_IP}" + - "${HOST2}:${HOST_IP}" + - "${HOST3}:${HOST_IP}" + - "${HOST4}:${HOST_IP}" + - "${HOST5}:${HOST_IP}" + - "${HOST6}:${HOST_IP}" + + # GoLang + mmtinyurl-backend: + build: + context: ./GoLang + dockerfile: Dockerfile + args: + - CONTAINER_VERSION=${GOLANG_VER} + volumes: + - ./Source/urlshortner-backend:/usr/src/app + command: "go run app.go" + tty: true + ports: + - 8084:8080 + env_file: + - ./GoLang/.env \ No newline at end of file