Skip to content

Commit

Permalink
added dockerfile for backend and frontend.
Browse files Browse the repository at this point in the history
added docker-compose for development stage.
  • Loading branch information
nguyenducduy committed Aug 7, 2020
1 parent ff9d59b commit 1cadeeb
Show file tree
Hide file tree
Showing 15 changed files with 107 additions and 107 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,7 @@ ENV/
.ropeproject

# Project upload dir
src/app/upload/**
src/app/upload/**

# db docker folder
db
51 changes: 51 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: '3.7'
services:
db:
image: 'mysql:8.0.19'
volumes:
- './db/data:/var/lib/mysql'
command: '--default-authentication-plugin=mysql_native_password'
restart: always
secrets:
- db-password
networks:
- backend-network
environment:
- MYSQL_DATABASE=graphue
- MYSQL_USER=root
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db-password
api:
build:
context: ./src
target: develop-stage
container_name: api
restart: always
ports:
- '5000:5000'
volumes:
- './src/:/src'
command: /bin/sh -c "FLASK_ENV=development python manage.py"
networks:
- backend-network
- frontend-network
ui:
build:
context: ./src/template
target: develop-stage
container_name: ui
restart: always
ports:
- '8080:8080'
volumes:
- './src/template:/template'
command: /bin/sh -c "yarn serve"
networks:
- frontend-network
volumes:
db: null
secrets:
db-password:
file: db/password.txt
networks:
backend-network: null
frontend-network: null
71 changes: 0 additions & 71 deletions nginx/default.conf

This file was deleted.

1 change: 0 additions & 1 deletion scripts/start_app.sh

This file was deleted.

2 changes: 2 additions & 0 deletions src/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
template
__pycache__/
1 change: 1 addition & 0 deletions src/.flaskenv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FLASK_APP=manage.py
20 changes: 20 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# develop stage
FROM python:3.6 as develop-stage
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
WORKDIR /src
COPY requirements.txt ./
RUN pip install -r requirements.txt
ADD . .

# build stage
FROM python:3.6 as build-stage
WORKDIR /src
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY . .

# Production stage
FROM python:3.6 as production-stage
EXPOSE 5000
CMD gunicorn -b 0.0.0.0:5000 --worker-class eventlet -w 3 manage:app --max-requests 10000 --timeout 5 --keep-alive 5 --log-level info -e FLASK_ENV=production
2 changes: 1 addition & 1 deletion src/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ def cat_to_json(item):
log = logging.getLogger(__name__)
log.info(
'----- Serving SOCKET-IO at {} -----'.format(app.config['BASE_URI']))
socketio.run(app, debug=True)
socketio.run(app, host='0.0.0.0', port=5000, debug=True)
1 change: 0 additions & 1 deletion src/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,5 @@ tzlocal==2.1
Unidecode==1.1.1
uritemplate==3.0.1
urllib3==1.25.9
uWSGI==2.0.19.1
Werkzeug==0.16.1
zipp==3.1.0
1 change: 1 addition & 0 deletions src/template/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
20 changes: 20 additions & 0 deletions src/template/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# develop stage
FROM node:12.14.0-alpine as develop-stage
WORKDIR /template
COPY package*.json ./
RUN yarn
ADD . .

# build stage
FROM node:12.14.0-alpine as build-stage
WORKDIR /template
COPY package*.json ./
RUN yarn
COPY . .
RUN yarn build

# Production stage
FROM nginx:1.16.1-alpine as production-stage
COPY --from=build-stage /template/dist /usr/share/nginx/html
EXPOSE 80
CMD [ "nginx", "-g", "daemon off;"]
3 changes: 1 addition & 2 deletions src/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"lodash": "^4.17.19",
"moment": "^2.27.0",
"moment-timezone": "^0.5.31",
"pouchdb": "^7.2.1",
"query-string": "^6.13.1",
"socket.io-client": "^2.3.0",
"tailwindcss": "^1.4.6",
Expand Down Expand Up @@ -58,7 +57,7 @@
"@vue/cli-plugin-router": "^4.4.0",
"@vue/cli-plugin-typescript": "^4.4.0",
"@vue/cli-plugin-vuex": "^4.4.0",
"@vue/cli-service": "^4.4.0",
"@vue/cli-service": "^4.4.6",
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/eslint-config-typescript": "^5.0.2",
"babel-plugin-import": "^1.13.0",
Expand Down
22 changes: 5 additions & 17 deletions src/template/src/views/Admin/Login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
}
]"
>
<a-icon
slot="prefix"
type="user"
style="color: rgba(0,0,0,.25);"
/>
<a-icon slot="prefix" type="user" style="color: rgba(0,0,0,.25);" />
</a-input>
</a-form-item>
<a-form-item :label="$t('views.login.Password')">
Expand All @@ -46,34 +42,26 @@
}
]"
>
<a-icon
slot="prefix"
type="lock"
style="color: rgba(0,0,0,.25);"
/>
<a-icon slot="prefix" type="lock" style="color: rgba(0,0,0,.25);" />
</a-input>
</a-form-item>
<div class="text-right">
<a-button type="link">
{{ $t("views.login.ForgotPassword") }}
</a-button>
<a-button type="link">{{ $t("views.login.ForgotPassword") }}</a-button>
</div>
<div class="form-actions">
<a-button
type="primary"
htmlType="submit"
class="login-form-button width-150"
:loading="loading"
>{{ $t("views.login.SignIn") }}</a-button
>
>{{ $t("views.login.SignIn") }}</a-button>
<a-button
class="float-right"
type="dashed"
icon="google"
:loading="loading"
@click.prevent="onGoogleSignin('google')"
>{{ $t("views.login.SignInWithGoogle") }}</a-button
>
>{{ $t("views.login.SignInWithGoogle") }}</a-button>
</div>
</a-form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/template/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@
resolved "https://registry.yarnpkg.com/@vue/cli-plugin-vuex/-/cli-plugin-vuex-4.4.6.tgz#44b596f0d5236e0a2ce1aa4757bda5207c230be0"
integrity sha512-Ho0YzUivn8BLPqFoFypntR8CMTEXYYHVr0GdnZW99XL+DbGw75f+tJfnrV9UFHDTfvZt7uewKiXDMlrzQ0l3Ug==

"@vue/cli-service@^4.4.0":
"@vue/cli-service@^4.4.6":
version "4.4.6"
resolved "https://registry.yarnpkg.com/@vue/cli-service/-/cli-service-4.4.6.tgz#83ca058d081eb145bbc1ae2fe8069d2d9ddf7e18"
integrity sha512-k5OFGh2NnvRymCyq9DfBiNJvECUuun3pl5KMm3557IZyA5E5csv+RHoSW3dX8HHe0zXq18g52VswP1llvR9POw==
Expand Down
12 changes: 0 additions & 12 deletions src/uwsgi.ini

This file was deleted.

0 comments on commit 1cadeeb

Please sign in to comment.