Added nginx configuration and finished deployment guide
This commit is contained in:
parent
7befb8c0c0
commit
0909212ca0
21
README.md
21
README.md
@ -35,10 +35,10 @@ If you are a regular user, you can visit [QuestionForm.dmitriy.icu](https://ques
|
||||
git clone https://github.com/Dm1tr1y147/questionForm.git
|
||||
```
|
||||
|
||||
2. For now you can run it without https with a command below, but if you want to run it with https, skip this to 3 step:
|
||||
2. Copy and fill in .env file:
|
||||
|
||||
```bash
|
||||
docker-compose -f docker-compose -f docker-compose.dev.yml up -d
|
||||
cp .env.example .env && vim .env
|
||||
```
|
||||
|
||||
3. Build the container:
|
||||
@ -53,4 +53,19 @@ docker-compose build
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
To check logs you can use docker-compose logs
|
||||
5. Connect to backend container and push migrations with prisma migrate:
|
||||
|
||||
```bash
|
||||
docker-compose exec backend sh
|
||||
// inside container
|
||||
yarn prisma migrate up --experimental
|
||||
exit
|
||||
```
|
||||
|
||||
6. If you don't have separate nginx container to host the site, you can use docker-compose file in `nginx` directory of this repository or change volumes paths to expose built frontend outside the container and specify `ports` property in `backend` service to expose backend application into host. The first method is recommended as for it is more flexible and secure.
|
||||
|
||||
```bash
|
||||
cd nginx
|
||||
vim conf/main.conf
|
||||
docker-compose up -d
|
||||
```
|
||||
|
2
backend
2
backend
@ -1 +1 @@
|
||||
Subproject commit bc060904371878e5bacd0141f93ca87cb5b6db44
|
||||
Subproject commit c09a66c6ddd6141b049aea47bc948c18498eeb88
|
21
nginx/conf/main.conf
Normal file
21
nginx/conf/main.conf
Normal file
@ -0,0 +1,21 @@
|
||||
upstream backend {
|
||||
server backend:4000;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
server_name example.com; // replayce example.com with your domain name
|
||||
|
||||
location ~ ^/(graphql) {
|
||||
proxy_pass http://backend;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $host;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location / {
|
||||
root /var/www/questionform/frontend;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
21
nginx/docker-compose.yml
Normal file
21
nginx/docker-compose.yml
Normal file
@ -0,0 +1,21 @@
|
||||
version: '3'
|
||||
networks:
|
||||
web:
|
||||
external: true
|
||||
|
||||
services:
|
||||
nginx:
|
||||
restart: unless-stopped
|
||||
image: nginx:1.15-alpine
|
||||
networks:
|
||||
- web
|
||||
volumes:
|
||||
- questionForm_frontend-build-folder:/var/www/questionform/frontend
|
||||
- ./conf:/etc/nginx/conf.d
|
||||
ports:
|
||||
- 80:80
|
||||
|
||||
volumes:
|
||||
questionForm_frontend-build-folder:
|
||||
external:
|
||||
name: questionform_frontend-build-folder
|
Loading…
x
Reference in New Issue
Block a user