migrate from express to nginx proxy pt.1
This commit is contained in:
parent
6bc5a52a37
commit
707f9aaa9b
@ -3,4 +3,5 @@ npm-debug.log
|
|||||||
yarn.lock
|
yarn.lock
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
*.log
|
*.log
|
||||||
.git
|
.git
|
||||||
|
build
|
||||||
21
Dockerfile
21
Dockerfile
@ -1,17 +1,22 @@
|
|||||||
FROM node:14-alpine as build
|
FROM node:14-alpine as builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package.json /app/package.json
|
COPY package.json /app/
|
||||||
|
|
||||||
RUN npm install
|
RUN npm install --only=prod
|
||||||
|
|
||||||
RUN npm install -g cross-env dotenv-cli
|
|
||||||
|
|
||||||
COPY . /app
|
COPY . /app
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run build:client
|
||||||
|
|
||||||
EXPOSE 3001
|
|
||||||
|
|
||||||
CMD ["node", "build/server.js"]
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
COPY --from=builder /app/build /usr/share/nginx/html
|
||||||
|
|
||||||
|
COPY --from=builder /app/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
ENTRYPOINT ["nginx", "-g", "daemon off;"]
|
||||||
@ -1,32 +1,34 @@
|
|||||||
version: '3.3'
|
version: '3.3'
|
||||||
services:
|
services:
|
||||||
calcapp:
|
client:
|
||||||
container_name: calcapp
|
|
||||||
build: ./EvoCalculator
|
build: ./EvoCalculator
|
||||||
ports:
|
|
||||||
- '3001:3001'
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- calccore
|
- core
|
||||||
restart: always
|
|
||||||
networks:
|
networks:
|
||||||
vpcbr:
|
- calc_network
|
||||||
ipv4_address: 10.5.0.4
|
links:
|
||||||
|
- core
|
||||||
|
|
||||||
calccore:
|
core:
|
||||||
container_name: calccore
|
|
||||||
build: ./EvoCalculator.Core
|
build: ./EvoCalculator.Core
|
||||||
ports:
|
|
||||||
- '5000:5000'
|
|
||||||
restart: always
|
|
||||||
networks:
|
networks:
|
||||||
vpcbr:
|
- calc_network
|
||||||
ipv4_address: 10.5.0.5
|
|
||||||
|
proxy:
|
||||||
|
restart: always
|
||||||
|
build: ./EvoCalculator.Proxy
|
||||||
|
ports:
|
||||||
|
- '4000:80'
|
||||||
|
networks:
|
||||||
|
- web
|
||||||
|
- calc_network
|
||||||
|
depends_on:
|
||||||
|
- client
|
||||||
|
links:
|
||||||
|
- client
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
vpcbr:
|
calc_network:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
ipam:
|
|
||||||
config:
|
|
||||||
- subnet: 10.5.0.0/16
|
|
||||||
web:
|
web:
|
||||||
external: true
|
external: true
|
||||||
|
|||||||
8
nginx.conf
Normal file
8
nginx.conf
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
server {
|
||||||
|
listen 3000;
|
||||||
|
location / {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html index.htm;
|
||||||
|
try_files $uri $uri/ /index.html =404;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -27,7 +27,6 @@ export default class {
|
|||||||
axios
|
axios
|
||||||
.post<IGetCalculationResponse>(
|
.post<IGetCalculationResponse>(
|
||||||
getServerUrl(
|
getServerUrl(
|
||||||
'/proxy',
|
|
||||||
CORE_PROXY_URL,
|
CORE_PROXY_URL,
|
||||||
'/api',
|
'/api',
|
||||||
'/v1',
|
'/v1',
|
||||||
|
|||||||
@ -3,6 +3,6 @@ import { getServerUrl } from 'client/common/urls';
|
|||||||
import { CRM_PROXY_URL } from 'core/constants/urls';
|
import { CRM_PROXY_URL } from 'core/constants/urls';
|
||||||
|
|
||||||
export default new ApolloClient({
|
export default new ApolloClient({
|
||||||
uri: getServerUrl('/proxy', CRM_PROXY_URL),
|
uri: getServerUrl(CRM_PROXY_URL),
|
||||||
cache: new InMemoryCache(),
|
cache: new InMemoryCache(),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,5 +9,5 @@ export const CRM_PROXY_URL = '/crmgraphql';
|
|||||||
export const CORE_URL =
|
export const CORE_URL =
|
||||||
process.env.NODE_ENV === 'development'
|
process.env.NODE_ENV === 'development'
|
||||||
? 'http://localhost:5000'
|
? 'http://localhost:5000'
|
||||||
: 'http://calccore:5000';
|
: 'http://core:5000';
|
||||||
export const CORE_PROXY_URL = '/core';
|
export const CORE_PROXY_URL = '/core';
|
||||||
|
|||||||
Reference in New Issue
Block a user