Skip to content

Commit 70b539b

Browse files
committed
Add frontend setting to docker-compose
1 parent 95c01b2 commit 70b539b

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed

docker-compose.prod.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@ services:
1717
depends_on:
1818
- postgres
1919

20+
frontend:
21+
build: ./frontend
22+
volumes:
23+
- www:/app/dist
24+
2025
nginx:
2126
build: ./nginx
2227
volumes:
2328
- static_volume:/home/app/web/staticfiles
29+
- www:/var/www/html:ro
2430
ports:
2531
- 1337:80
2632
depends_on:
@@ -40,3 +46,4 @@ services:
4046
volumes:
4147
postgres_data:
4248
static_volume:
49+
www:

frontend/.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
**/bundle/
2+
**/node_modules/
3+
**/webpack-stats.json
4+
5+
**/.env
6+
**/coverage/

frontend/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM node:13.1.0
2+
3+
# set work directory
4+
WORKDIR /app
5+
6+
# set environment variables
7+
# ENV PYTHONDONTWRITEBYTECODE 1
8+
9+
# copy project
10+
COPY . /app/
11+
12+
# install dependencies
13+
RUN npm install -g npm@latest
14+
RUN npm install
15+
16+
# build project
17+
RUN npm run build
18+
RUN ls -l

frontend/services/api.service.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import axios from 'axios'
22
const baseURL = 'http://127.0.0.1:8000/v1' // Todo: change URL by development/staging/production.
3+
// const baseURL = '/v1'
34

45
class ApiService {
56
constructor() {

nginx/nginx.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ server {
22
listen 80;
33
charset utf-8;
44

5+
location / {
6+
root /var/www/html;
7+
try_files $uri $uri/ /index.html;
8+
}
9+
510
location /v1/ {
611
proxy_pass http://backend:8000/v1/;
712
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

0 commit comments

Comments
 (0)