Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phase2 --------- partial 4 #76

Merged
merged 10 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion zubhub_backend/deploy_backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ cp -r zubhub/zubhub_backend/ zubhub_backend/
rm -rf zubhub/ zubhub_backend/.env.example
cd zubhub_backend
docker-compose down
docker-compose up -d --build
docker-compose -f ./docker-compose.prod.yml up -d --build
echo "Updated backend"
# EOT
124 changes: 124 additions & 0 deletions zubhub_backend/docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
version: "3.3"

services:
web:
env_file: .env
build:
context: .
dockerfile: ./Dockerfile
command: /start
restart: on-failure
environment:
- ENVIRONMENT=${ENVIRONMENT}
- SECRET_KEY:${SECRET_KEY}
- DEBUG:${DEBUG}
- POSTGRES_NAME=${POSTGRES_NAME}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_HOST=${POSTGRES_HOST}
- SENDGRID_API_KEY=${SENDGRID_API_KEY}
volumes:
- .:/zubhub_backend
ports:
- 8000
depends_on:
- db
- rabbitmq

db:
env_file: .env
image: postgres:11
restart: on-failure
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
volumes:
- postgres_data:/var/lib/postgresql/data/
ports:
- 5432

reverse-proxy:
image: valian/docker-nginx-auto-ssl:1.0.0
container_name: reverse-proxy
restart: on-failure
ports:
- 80:80
- 443:443
volumes:
- ./.ssl-data:/etc/resty-auto-ssl
environment:
ALLOWED_DOMAINS: "(api|www.api|rabbitmq|flower|prometheus).zubhub.unstructured.studio"
SITES:
"api.zubhub.unstructured.studio=web:8000;www.api.zubhub.unstructured.studio=web:8000;\
rabbitmq.zubhub.unstructured.studio=rabbitmq:15672;flower.zubhub.unstructured.studio=flower:5555;\
prometheus.zubhub.unstructured.studio=prometheus:9090"
FORCE_HTTPS: "true"
depends_on:
- web
- rabbitmq
- flower
- prometheus

rabbitmq:
env_file: .env
image: rabbitmq:3-management
restart: on-failure
ports:
- 5672
- 15672

celery_worker:
env_file: .env
build:
context: .
dockerfile: ./Dockerfile
image: zubhub_celery_worker
command: /start-celeryworker
restart: on-failure
volumes:
- .:/zubhub_backend
depends_on:
- rabbitmq
- db

flower:
env_file: .env
build:
context: .
dockerfile: ./Dockerfile
image: zubhub_celery_flower
ports:
- 5555
command: /start-flower
restart: on-failure
volumes:
- .:/zubhub_backend
depends_on:
- celery_worker
- rabbitmq
- db

prometheus:
image: prom/prometheus
ports:
- 9090
command:
- --config.file=/etc/prometheus/prometheus.yml
restart: on-failure
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
depends_on:
- cadvisor

cadvisor:
image: google/cadvisor
container_name: cadvisor
restart: on-failure
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro

volumes:
postgres_data:
.ssl-data:
23 changes: 0 additions & 23 deletions zubhub_backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,6 @@ services:
ports:
- 5432:5432

reverse-proxy:
image: valian/docker-nginx-auto-ssl:1.0.0
container_name: reverse-proxy
restart: on-failure
ports:
- 80:80
- 443:443
volumes:
- ./.ssl-data:/etc/resty-auto-ssl
environment:
ALLOWED_DOMAINS: "(api|www.api|rabbitmq|flower|prometheus).zubhub.unstructured.studio"
SITES:
"api.zubhub.unstructured.studio=web:8000;www.api.zubhub.unstructured.studio=web:8000;\
rabbitmq.zubhub.unstructured.studio=rabbitmq:15672;flower.zubhub.unstructured.studio=flower:5555;\
prometheus.zubhub.unstructured.studio=prometheus:9090"
FORCE_HTTPS: "true"
depends_on:
- web
- rabbitmq
- flower
- prometheus

rabbitmq:
env_file: .env
image: rabbitmq:3-management
Expand Down Expand Up @@ -121,4 +99,3 @@ services:

volumes:
postgres_data:
.ssl-data:
10 changes: 10 additions & 0 deletions zubhub_frontend/zubhub/.prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
printWidth: 80
tabWidth: 2
useTabs: false
semi: true
singleQuote: true
trailingComma: all
bracketSpacing: true
jsxBracketSameLine: false
arrowParens: avoid
requirePragma: false
4 changes: 2 additions & 2 deletions zubhub_frontend/zubhub/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ RUN npm run build
FROM nginx:stable-alpine
COPY --from=build /zubhub_frontend/build /usr/share/nginx/html
# new
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
COPY nginx/dev/default.conf /etc/nginx/conf.d/default.conf
EXPOSE 3000
CMD ["nginx", "-g", "daemon off;"]
18 changes: 18 additions & 0 deletions zubhub_frontend/zubhub/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# build environment
FROM node:13.12.0-alpine as build
WORKDIR /zubhub_frontend
ENV PATH /zubhub_frontend/node_modules/.bin:$PATH
COPY package.json ./
COPY package-lock.json ./
RUN npm ci --silent
RUN npm install react-scripts@3.4.1 -g --silent
COPY . ./
RUN npm run build

# production environment
FROM nginx:stable-alpine
COPY --from=build /zubhub_frontend/build /usr/share/nginx/html
# new
COPY nginx/prod/default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
13 changes: 12 additions & 1 deletion zubhub_frontend/zubhub/deploy_frontend.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
#! /bin/bash

echo "copying .env file and ssl folder"
mv zubhub_frontend/zubhub/.env zubhub/zubhub_frontend/zubhub/.env
mv zubhub_frontend/zubhub/.ssl-data zubhub/zubhub_frontend/zubhub/
echo "done copying .env file and ssl folder"

echo "removing unneccessary files and folders"
rm -rf zubhub_frontend
cp -r zubhub/zubhub_frontend/ zubhub_frontend/
rm -rf zubhub/ zubhub_frontend/zubhub/.env.example
rm -rf zubhub/ zubhub_frontend/zubhub/Dockerfile
rm -rf zubhub/ zubhub_frontend/zubhub/docker-compose.yml
rm -rf zubhub/ zubhub_frontend/zubhub/nginx/dev
echo "done removing unneccessary files and folders"

cd zubhub_frontend/zubhub/

echo "stopping and rebuilding the containers"
docker-compose down
docker-compose up -d --build
docker-compose -f ./docker-compose.prod.yml up -d --build
echo "Updated frontend"
# EOT
32 changes: 32 additions & 0 deletions zubhub_frontend/zubhub/docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: "3.3"

services:
zubhub_frontend:
container_name: zubhub_frontend
build:
context: .
dockerfile: Dockerfile.prod
volumes:
- ./nginx/prod/default.conf:/etc/nginx/conf.d/default.conf
restart: on-failure
ports:
- "80"

reverse-proxy:
image: valian/docker-nginx-auto-ssl:1.0.0
container_name: reverse-proxy
restart: on-failure
ports:
- 80:80
- 443:443
volumes:
- ./.ssl-data:/etc/resty-auto-ssl
environment:
ALLOWED_DOMAINS: "(zubhub|www.zubhub).unstructured.studio"
SITES: "zubhub.unstructured.studio=zubhub_frontend;www.zubhub.unstructured.studio=zubhub_frontend"
FORCE_HTTPS: "true"
depends_on:
- zubhub_frontend

volumes:
.ssl-data:
23 changes: 2 additions & 21 deletions zubhub_frontend/zubhub/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,7 @@ services:
context: .
dockerfile: Dockerfile
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
- ./nginx/dev/default.conf:/etc/nginx/conf.d/default.conf
restart: on-failure
ports:
- "8080:80"

reverse-proxy:
image: valian/docker-nginx-auto-ssl:1.0.0
container_name: reverse-proxy
restart: on-failure
ports:
- 80:80
- 443:443
volumes:
- ./.ssl-data:/etc/resty-auto-ssl
environment:
ALLOWED_DOMAINS: "(zubhub|www.zubhub).unstructured.studio"
SITES: "zubhub.unstructured.studio=zubhub_frontend;www.zubhub.unstructured.studio=zubhub_frontend"
FORCE_HTTPS: "true"
depends_on:
- zubhub_frontend

volumes:
.ssl-data:
- "3000:3000"
33 changes: 33 additions & 0 deletions zubhub_frontend/zubhub/nginx/dev/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
map $sent_http_content_type $expires {
default off;
text/html epoch;
text/css max;
application/javascript max;
~image/ max;
}
server {
listen 3000;
server_name localhost;

gzip on;
gzip_min_length 1000;
gzip_buffers 4 32k;
gzip_proxied any;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;
gzip_vary on;
gzip_disable “MSIE [1–6]\.(?!.*SV1)”;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}

error_page 500 502 503 504 /50x.html;

location = /50x.html {
root /usr/share/nginx/html;
}
}
6 changes: 6 additions & 0 deletions zubhub_frontend/zubhub/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion zubhub_frontend/zubhub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@testing-library/react": "^11.1.2",
"@testing-library/user-event": "^12.2.2",
"aws-sdk": "^2.813.0",
"classnames": "^2.2.6",
"date-fns": "^2.16.1",
"formik": "^2.2.5",
"nanoid": "^3.1.20",
Expand All @@ -32,7 +33,8 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"pretty": "prettier --config ./.prettierrc.yaml --write \"src/**/*.{js,jsx}\""
},
"eslintConfig": {
"extends": [
Expand All @@ -51,5 +53,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"prettier": "2.2.1"
}
}
Loading