Provide an Installation with Docker

This commit is contained in:
Robert Schäfer 2018-10-20 01:41:19 +02:00
parent fda241ae11
commit 41ece7dce1
5 changed files with 74 additions and 30 deletions

10
.dockerignore Normal file
View File

@ -0,0 +1,10 @@
.vscode/
styleguide/node_modules/
node_modules/
npm-debug.log
Dockerfile
docker-compose*.yml
.env

23
Dockerfile Normal file
View File

@ -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"]

25
docker-compose.yml Normal file
View File

@ -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:

View File

@ -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',
}
},

13
plugins/apollo-config.js Normal file
View File

@ -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
}
}