🎁 Default project template configuring backend and frontend through nginx in AWS EC2
- aws ec2
- reactjs
- django
- docker
- nginx
- docker-compose
- Get this project for work in your repository space
- Open the terminal on your laptop.
- Move your path to where you want.
- enter command,
git clone https://https://github.com/{Your workspace}/web-service-basic-template
- You need to install a few things.
- python3
- python3-pip
- django
- docker
- docker-compose
- nodejs
- npm, yarn
- If the installation is finished, type
docker-compose up-d --build
in the terminal. - Finally, you can enter the host of the project in your browser.
app$ mkdir db
app$ vi .env
# app/.env
MYSQL_ROOT_PASSWORD=password
MYSQL_DATABASE=dbname
MYSQL_ROOT_USER=rootusername
MYSQL_PASSWORD=password
# docker-compose.yml
backend:
...
depends_on:
- db
...
db:
container_name: db
image: mysql:latest
restart: always
ports:
- "3306:3306"
env_file: .env
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --lower_case_table_names=1
volumes:
- ./db/data:/var/lib/mysql
# app/backend/config$ vi env.py
SECRET_KEY = 'django secret_key'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '0.0.0.0',
'NAME': 'name',
'USER': 'username',
'PASSWORD': 'password',
'PORT': '3306',
'OPTIONS': {
'charset': 'utf8mb4'
}
}
}
from . import env
...
SECRET_KEY = env.SECRET_KEY
...
DATABASES = env.DATABASES
└── app/
├── frontend/
│ ├── Dockerfile
│ └── ...
├── nginx/
│ ├── Dockerfile
│ ├── nginx-proxy.conf
│ └── nginx.conf
└── backend/
│ ├── Dockerfile
│ ├── manage.py
│ ├── README.md
│ ├── requirements.txt
│ ├── apps/
│ │ ├── ...
│ │ └── items/
│ │ ├── __init__.py
│ │ ├── admin.py
│ │ ├── apps.py
│ │ ├── models.py
│ │ ├── ...
│ │ └── migrations/
│ │ └── ...
│ ├── config/
│ │ ├── asgi.py
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ ├── env.py
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ └── uwsgi.ini
├── README.md
├── .env
├── .gitignore
└── docker-compose.yml