diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..f363d4044 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +.vscode/ + +styleguide/node_modules/ +node_modules/ +npm-debug.log + +Dockerfile +docker-compose*.yml + +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..d0d0e28dd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM node:10-alpine +LABEL Description="This image builds and runs the Human-Connection Web Application Frontend" Vendor="Human-Connection gGmbH" Version="0.0.1" Maintainer="Human-Connection gGmbH (developer@human-connection.org)" + +# expose the app port +EXPOSE 3000 + +ARG WORKDIR=/HC-WebApp +RUN mkdir -p $WORKDIR +WORKDIR $WORKDIR + +# See: https://github.com/nodejs/docker-node/pull/367#issuecomment-430807898 +RUN apk --no-cache add git + +COPY styleguide/ ./styleguide +RUN cd styleguide && yarn install --production=false --frozen-lockfile --non-interactive --ignore-engines + +COPY package.json . +COPY yarn.lock . +RUN yarn install --production=false --frozen-lockfile --non-interactive --ignore-engines + +COPY . . +RUN ["yarn", "run", "build"] +CMD ["yarn", "run", "start"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..f6ce6ff93 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,25 @@ +version: '3.7' + +services: + webapp: + build: + context: . + ports: + - 3000:3000 + - 8080:8080 + networks: + - hc-network + volumes: + - .:/HC-WebApp + - node_modules:/HC-WebApp/node_modules + command: yarn run dev + environment: + - HOST=0.0.0.0 + - BACKEND_URL=http://backend.127.0.0.1.xip.io:4000 + +networks: + hc-network: + name: hc-network + +volumes: + node_modules: diff --git a/nuxt.config.js b/nuxt.config.js index 99726e447..59588a8ee 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -1,18 +1,11 @@ const pkg = require('./package') const envWhitelist = [ - 'BUILD_COMMIT', 'NODE_ENV', - 'WEBAPP_HOST', - 'WEBAPP_PORT', - 'WEBAPP_BASE_URL', - 'API_HOST', - 'API_PORT', - 'EMBED_API_URL', - 'SENTRY_DNS_PUBLIC', - 'MAPBOX_TOKEN', + 'BACKEND_URL', 'MAINTENANCE' ] + module.exports = { mode: 'universal', @@ -136,27 +129,7 @@ module.exports = { // }, // required clientConfigs: { - default: { - // required - httpEndpoint: 'http://localhost:4000', - // optional - // See https://www.apollographql.com/docs/link/links/http.html#options - httpLinkOptions: { - credentials: 'same-origin' - }, - credentials: true, - - // You can use `wss` for secure connection (recommended in production) - // Use `null` to disable subscriptions - // wsEndpoint: 'ws://localhost:4000', // optional - // LocalStorage token - tokenName: 'apollo-token', // optional - // Enable Automatic Query persisting with Apollo Engine - persisting: false, // Optional - // Use websockets for everything (no HTTP) - // You need to pass a `wsEndpoint` for this to work - websocketsOnly: false // Optional - } + default: '~/plugins/apollo-config.js', } }, diff --git a/plugins/apollo-config.js b/plugins/apollo-config.js new file mode 100644 index 000000000..866d3ee92 --- /dev/null +++ b/plugins/apollo-config.js @@ -0,0 +1,13 @@ +export default function({ app }) { + const backendUrl = app.$env.BACKEND_URL || 'http://localhost:4000' + return { + httpEndpoint: backendUrl, + httpLinkOptions: { + credentials: 'same-origin' + }, + credentials: true, + tokenName: 'apollo-token', + persisting: false, + websocketsOnly: false + } +}