From 982e332214143af06ab89186ac10af10447fe40b Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Thu, 5 Mar 2020 21:47:47 +0300 Subject: [PATCH] :heavy_plus_sign: added docker --- .dockerignore | 9 +++++++++ Dockerfile | 13 +++++++++++++ docker-compose.yml | 8 ++++++++ lib/apollo.js | 2 +- next.config.js | 3 +++ 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..88d93b3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +/node_modules + +/.next/ + +/build + +npm-debug.log +yarn-debug.log* +yarn-error.log* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..524996f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM node:10 + +WORKDIR /usr/src/app + +COPY package*.json ./ + +RUN npm install + +COPY . . + +RUN npm run build + +CMD ["npm", "start"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9b17065 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +version: '3' +services: + app: + container_name: apollo-next-graphql + restart: always + build: . + ports: + - '3000:3000' \ No newline at end of file diff --git a/lib/apollo.js b/lib/apollo.js index 36a7660..e72d87b 100644 --- a/lib/apollo.js +++ b/lib/apollo.js @@ -3,7 +3,7 @@ import { HttpLink } from 'apollo-boost' const config = { link: new HttpLink({ - uri: 'http://localhost:3000/api/graphql', + uri: process.env.GRAPHQL_API_URI, opts: { credentials: 'same-origin' } diff --git a/next.config.js b/next.config.js index d6ef8db..5a3fc12 100644 --- a/next.config.js +++ b/next.config.js @@ -9,5 +9,8 @@ module.exports = withSass({ config.optimization.minimizer.push(new OptimizeCSSAssetsPlugin({})) return config + }, + env: { + GRAPHQL_API_URI: 'http://localhost:3000/api/graphql' } })