diff --git a/TODO.md b/TODO.md index ea5c22a..942f657 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,3 @@ # TODO -sign up user -add want without discogs +get mcrates.au up diff --git a/client/src/actions.ts b/client/src/actions.ts index 4352ac3..761ec53 100644 --- a/client/src/actions.ts +++ b/client/src/actions.ts @@ -15,7 +15,7 @@ declare module 'axios' { } const api = axios.create({ - baseURL: 'http://localhost:41337', + baseURL: '/api', withCredentials: true }); diff --git a/docker-compose.MCRATES.yaml b/docker-compose.MCRATES.yaml new file mode 100644 index 0000000..8ebc064 --- /dev/null +++ b/docker-compose.MCRATES.yaml @@ -0,0 +1,35 @@ +version: "3.3" + +services: + pg: + image: postgres:latest + environment: + POSTGRES_USER: 'mcrates' + POSTGRES_DB: 'mcrates' + POSTGRES_PASSWORD: 'digdeep' + volumes: + - "./db:/var/lib/postgresql/data" + + api: + image: node:16 + working_dir: /opt/mcrates/api + entrypoint: npm start + environment: + DATABASE_URL: 'postgresql://mcrates:digdeep@pg:5432/mcrates?schema=public' + volumes: + - "./api:/opt/mcrates/api" + + client: + image: node:16 + working_dir: /opt/mcrates/client + entrypoint: npm start + volumes: + - "./client:/opt/mcrates/client" + + nginx: + image: nginx:latest + volumes: + - './nginx/localhost.nginx.conf:/etc/nginx/conf.d/default.conf' + - '/etc/letsencrypt' + ports: + - '80:80' diff --git a/docker-compose.test.yaml b/docker-compose.TEST.yaml similarity index 100% rename from docker-compose.test.yaml rename to docker-compose.TEST.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml index 783dcc4..7350cf1 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -12,32 +12,37 @@ services: volumes: - "./db:/var/lib/postgresql/data" - pg-test: - image: postgres:latest - environment: - POSTGRES_USER: 'mcrates' - POSTGRES_DB: 'test' - POSTGRES_PASSWORD: 'digdeep' - ports: - - '55432:5432' - - # api: - # image: node:16 - # working_dir: /opt/mcrates/api - # entrypoint: npm start + # pg-test: + # image: postgres:latest # environment: - # DATABASE_URL: 'postgresql://mcrates:digdeep@pg:5432/mcrates?schema=public' + # POSTGRES_USER: 'mcrates' + # POSTGRES_DB: 'test'# POSTGRES_PASSWORD: 'digdeep' # ports: - # - '41337:41337' - # volumes: - # - "./api:/opt/mcrates/api" + # - '55432:5432' - # client: - # image: node:16 - # working_dir: /opt/mcrates/client - # entrypoint: npm start - # ports: - # - '8080:8080' - # volumes: - # - "./client:/opt/mcrates/client" + api: + image: node:16 + working_dir: /opt/mcrates/api + entrypoint: npm start + environment: + DATABASE_URL: 'postgresql://mcrates:digdeep@pg:5432/mcrates?schema=public' + ports: + - '41337:41337' + volumes: + - "./api:/opt/mcrates/api" + client: + image: node:16 + working_dir: /opt/mcrates/client + entrypoint: npm start + ports: + - '8080:8080' + volumes: + - "./client:/opt/mcrates/client" + + nginx: + image: nginx:latest + volumes: + - './nginx/localhost.nginx.conf:/etc/nginx/conf.d/default.conf' + ports: + - '80:80' diff --git a/nginx/localhost.nginx.conf b/nginx/localhost.nginx.conf new file mode 100644 index 0000000..d315e3e --- /dev/null +++ b/nginx/localhost.nginx.conf @@ -0,0 +1,37 @@ +upstream mcrates_api { + server api:41337; +} + +upstream mcrates_client { + server client:8080; +} + +# upstream mcrates_ws { +# server 127.0.0.1:40055; +# } + +map $http_upgrade $connection_upgrade { + default upgrade; + '' close; +} + +server { + location / { + proxy_pass http://mcrates_client; + proxy_read_timeout 600s; + } + + # location /api/ws { + # proxy_pass http://mcrates_ws; + # proxy_http_version 1.1; + # proxy_set_header Upgrade $http_upgrade; + # proxy_set_header Connection $connection_upgrade; + # proxy_read_timeout 600s; + # } + + location /api/ { + # trailing slash means api will receive url WITHOUT /api + proxy_pass http://mcrates_api/; + proxy_read_timeout 600s; + } +} \ No newline at end of file diff --git a/etc/matescrates.au.nginx.conf b/nginx/matescrates.au.nginx.conf similarity index 64% rename from etc/matescrates.au.nginx.conf rename to nginx/matescrates.au.nginx.conf index 8743308..3fad037 100644 --- a/etc/matescrates.au.nginx.conf +++ b/nginx/matescrates.au.nginx.conf @@ -1,11 +1,15 @@ -upstream mcrates_http { - server 127.0.0.1:40080; +upstream mcrates_api { + server api:41337; } -upstream mcrates_ws { - server 127.0.0.1:40055; +upstream mcrates_client { + server client:8080; } +# upstream mcrates_ws { +# server 127.0.0.1:40055; +# } + map $http_upgrade $connection_upgrade { default upgrade; '' close; @@ -22,21 +26,21 @@ server { gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml; location / { - root /srv/mcrates/current; - index index.html; - try_files $uri $uri/ index.html; - } - - location /api/ws { - proxy_pass http://mcrates_ws; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; + proxy_pass http://mcrates_client; proxy_read_timeout 600s; } + # location /api/ws { + # proxy_pass http://mcrates_ws; + # proxy_http_version 1.1; + # proxy_set_header Upgrade $http_upgrade; + # proxy_set_header Connection $connection_upgrade; + # proxy_read_timeout 600s; + # } + location /api/ { - proxy_pass http://mcrates_http; + # trailing slash means api will receive url WITHOUT /api + proxy_pass http://mcrates_api/; proxy_read_timeout 600s; }