diff --git a/.dockerignore b/.dockerignore index b5337d4..b95ee2f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,4 +3,5 @@ npm-debug.log yarn.lock yarn-error.log *.log -.git \ No newline at end of file +.git +build \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 64ea759..37b198f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,22 @@ -FROM node:14-alpine as build +FROM node:14-alpine as builder WORKDIR /app -COPY package.json /app/package.json +COPY package.json /app/ -RUN npm install - -RUN npm install -g cross-env dotenv-cli +RUN npm install --only=prod COPY . /app -RUN npm run build +RUN npm run build:client -EXPOSE 3001 -CMD ["node", "build/server.js"] \ No newline at end of file +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;"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index ec2a23a..cb3d8d0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,32 +1,34 @@ version: '3.3' services: - calcapp: - container_name: calcapp + client: build: ./EvoCalculator - ports: - - '3001:3001' depends_on: - - calccore - restart: always + - core networks: - vpcbr: - ipv4_address: 10.5.0.4 + - calc_network + links: + - core - calccore: - container_name: calccore + core: build: ./EvoCalculator.Core - ports: - - '5000:5000' - restart: always networks: - vpcbr: - ipv4_address: 10.5.0.5 + - calc_network + + proxy: + restart: always + build: ./EvoCalculator.Proxy + ports: + - '4000:80' + networks: + - web + - calc_network + depends_on: + - client + links: + - client networks: - vpcbr: + calc_network: driver: bridge - ipam: - config: - - subnet: 10.5.0.0/16 web: external: true diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..46d70ec --- /dev/null +++ b/nginx.conf @@ -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; + } +} \ No newline at end of file diff --git a/src/client/services/CalculationService/index.ts b/src/client/services/CalculationService/index.ts index 4ae1365..13d8b9b 100644 --- a/src/client/services/CalculationService/index.ts +++ b/src/client/services/CalculationService/index.ts @@ -27,7 +27,6 @@ export default class { axios .post( getServerUrl( - '/proxy', CORE_PROXY_URL, '/api', '/v1', diff --git a/src/client/services/CrmService/client.ts b/src/client/services/CrmService/client.ts index bd4343a..93e7c0f 100644 --- a/src/client/services/CrmService/client.ts +++ b/src/client/services/CrmService/client.ts @@ -3,6 +3,6 @@ import { getServerUrl } from 'client/common/urls'; import { CRM_PROXY_URL } from 'core/constants/urls'; export default new ApolloClient({ - uri: getServerUrl('/proxy', CRM_PROXY_URL), + uri: getServerUrl(CRM_PROXY_URL), cache: new InMemoryCache(), }); diff --git a/src/core/constants/urls.js b/src/core/constants/urls.js index da327ef..2917c75 100644 --- a/src/core/constants/urls.js +++ b/src/core/constants/urls.js @@ -9,5 +9,5 @@ export const CRM_PROXY_URL = '/crmgraphql'; export const CORE_URL = process.env.NODE_ENV === 'development' ? 'http://localhost:5000' - : 'http://calccore:5000'; + : 'http://core:5000'; export const CORE_PROXY_URL = '/core';