diff --git a/deployment/human-connection/maintenance/Dockerfile b/deployment/human-connection/maintenance/Dockerfile deleted file mode 100644 index 4681356ab..000000000 --- a/deployment/human-connection/maintenance/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM nginx:alpine -COPY ./onourjourney.svg /usr/share/nginx/html/ -COPY ./maintenance.html /usr/share/nginx/html/index.html diff --git a/deployment/human-connection/maintenance/maintenance.html b/deployment/human-connection/maintenance/maintenance.html deleted file mode 100644 index 906286342..000000000 --- a/deployment/human-connection/maintenance/maintenance.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - -
-

- At the moment we are doing some scheduled maintenance, please try again - later. -

- Maintenance mode image -

- Any Questions or concerns, send an email to
- -

-
- diff --git a/deployment/human-connection/maintenance/onourjourney.svg b/deployment/human-connection/maintenance/onourjourney.svg deleted file mode 100644 index 0950b7532..000000000 --- a/deployment/human-connection/maintenance/onourjourney.svg +++ /dev/null @@ -1,360 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docker-compose.maintenance.yml b/docker-compose.maintenance.yml index c029ffb6b..52168c221 100644 --- a/docker-compose.maintenance.yml +++ b/docker-compose.maintenance.yml @@ -1,7 +1,7 @@ version: "3.4" services: - maintenance: + maintenance-worker: image: humanconnection/maintenance-worker:latest build: context: deployment/legacy-migration/maintenance-worker diff --git a/docker-compose.override.yml b/docker-compose.override.yml index d4b06fc7a..5ef013656 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -64,6 +64,15 @@ services: - 7474:7474 volumes: - neo4j-data:/data + maintenance: + image: humanconnection/maintenance:latest + build: + context: webapp + dockerfile: Dockerfile.maintenance + networks: + - hc-network + ports: + - 3503:80 volumes: webapp_node_modules: diff --git a/docker-compose.yml b/docker-compose.yml index 45e2cdfdf..e782adcfa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,6 @@ services: target: production ports: - 3000:3000 - - 8080:8080 networks: - hc-network environment: @@ -40,14 +39,6 @@ services: context: neo4j networks: - hc-network - maintenance: - image: humanconnection/maintenance:latest - build: - context: deployment/human-connection/maintenance - networks: - - hc-network - ports: - - 80:80 networks: hc-network: diff --git a/scripts/docker_push.sh b/scripts/docker_push.sh index fe644c52a..1677b0d3c 100755 --- a/scripts/docker_push.sh +++ b/scripts/docker_push.sh @@ -4,7 +4,7 @@ docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT --target production -t huma docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT --target production -t humanconnection/nitro-web:latest $TRAVIS_BUILD_DIR/webapp docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT -t humanconnection/neo4j:latest $TRAVIS_BUILD_DIR/neo4j docker build -t humanconnection/maintenance-worker:latest $TRAVIS_BUILD_DIR/deployment/legacy-migration/maintenance-worker -docker build -t humanconnection/maintenance:latest $TRAVIS_BUILD_DIR/deployment/human-connection/maintenance +docker build -t humanconnection/maintenance:latest $TRAVIS_BUILD_DIR/webapp/ -f $TRAVIS_BUILD_DIR/webapp/Dockerfile.maintenance docker push humanconnection/nitro-backend:latest docker push humanconnection/nitro-web:latest docker push humanconnection/neo4j:latest diff --git a/webapp/.dockerignore b/webapp/.dockerignore index b0980ccfc..b0b6a6d6f 100644 --- a/webapp/.dockerignore +++ b/webapp/.dockerignore @@ -16,3 +16,5 @@ README.md screenshot*.png lokalise.png .editorconfig + +maintenance/node_modules/ diff --git a/webapp/Dockerfile.maintenance b/webapp/Dockerfile.maintenance new file mode 100644 index 000000000..116016480 --- /dev/null +++ b/webapp/Dockerfile.maintenance @@ -0,0 +1,40 @@ +FROM node:12.10.0-alpine as build +LABEL Description="Web Frontend of the Social Network Human-Connection.org" Vendor="Human-Connection gGmbH" Version="0.0.1" Maintainer="Human-Connection gGmbH (developer@human-connection.org)" + +EXPOSE 3000 +CMD ["yarn", "run", "start"] + +# Expose the app port +ARG BUILD_COMMIT +ENV BUILD_COMMIT=$BUILD_COMMIT +ARG WORKDIR=/nitro-web +RUN mkdir -p $WORKDIR +WORKDIR $WORKDIR + +# See: https://github.com/nodejs/docker-node/pull/367#issuecomment-430807898 +RUN apk --no-cache add git + +COPY package.json yarn.lock ./ +RUN yarn install --production=false --frozen-lockfile --non-interactive + +COPY assets assets +COPY components/LocaleSwitch/ components/LocaleSwitch +COPY components/Dropdown.vue components/Dropdown.vue +COPY layouts/blank.vue layouts/blank.vue +COPY locales locales +COPY mixins mixins +COPY plugins/i18n.js plugins/v-tooltip.js plugins/styleguide.js plugins/ +COPY static static +COPY nuxt.config.js nuxt.config.js + +# this will also ovewrite the existing package.json +COPY maintenance/source ./ + + +RUN yarn run generate + + +FROM nginx:alpine +COPY --from=build ./nitro-web/dist/ /usr/share/nginx/html/ +RUN rm /etc/nginx/conf.d/default.conf +COPY maintenance/nginx/custom.conf /etc/nginx/conf.d/ diff --git a/webapp/locales/de.json b/webapp/locales/de.json index a28baa2f9..ca8cc71e4 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -1,4 +1,9 @@ { + "maintenance": { + "title": "Human Connection befindet sich in der Wartung", + "explanation": "Zurzeit führen wir einige geplante Wartungsarbeiten durch, bitte versuch es später erneut.", + "questions": "Bei Fragen oder Problemen erreichst du uns per E-Mail an" + }, "index": { "no-results": "Keine Beiträge gefunden.", "change-filter-settings": "Verändere die Filter-Einstellungen um mehr Ergebnisse zu erhalten." diff --git a/webapp/locales/en.json b/webapp/locales/en.json index e08f7bdad..1898f8c4d 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -1,4 +1,9 @@ { + "maintenance": { + "title": "Human Connection is under maintenance", + "explanation": "At the moment we are doing some scheduled maintenance, please try again later.", + "questions": "Any Questions or concerns, send an email to" + }, "index": { "no-results": "No contributions found.", "change-filter-settings": "Change your filter settings to get more results." diff --git a/webapp/maintenance/nginx/custom.conf b/webapp/maintenance/nginx/custom.conf new file mode 100644 index 000000000..c27f272f9 --- /dev/null +++ b/webapp/maintenance/nginx/custom.conf @@ -0,0 +1,19 @@ +server { + listen 80; + server_name localhost; + + root /usr/share/nginx/html; + index index.html; + + location ~* \.(?:css|js|map|jpe?g|gif|png|svg|woff|ico)$ { } + + location / { + if (-f $document_root/index.html) { + return 503; + } + } + error_page 503 @maintenance; + location @maintenance { + rewrite ^(.*)$ /index.html break; + } +} diff --git a/webapp/maintenance/source/nuxt.config.maintenance.js b/webapp/maintenance/source/nuxt.config.maintenance.js new file mode 100644 index 000000000..738178786 --- /dev/null +++ b/webapp/maintenance/source/nuxt.config.maintenance.js @@ -0,0 +1,58 @@ +import defaultConfig from './nuxt.config.js' + +const { + css, + styleResources, + env: { locales }, + manifest, +} = defaultConfig + +export default { + css, + styleResources, + env: { locales }, + manifest, + + head: { + title: 'Human Connection', + meta: [ + { + charset: 'utf-8', + }, + { + name: 'viewport', + content: 'width=device-width, initial-scale=1', + }, + { + hid: 'description', + name: 'description', + content: 'Maintenance page for Human Connection', + }, + ], + link: [ + { + rel: 'icon', + type: 'image/x-icon', + href: '/favicon.ico', + }, + ], + }, + + plugins: [ + { src: `~/plugins/styleguide.js`, ssr: true }, + { src: '~/plugins/i18n.js', ssr: true }, + { src: '~/plugins/v-tooltip.js', ssr: false }, + ], + + modules: ['cookie-universal-nuxt', '@nuxtjs/style-resources'], + + router: { + extendRoutes(routes, resolve) { + routes.push({ + name: 'maintenance', + path: '*', + component: resolve(__dirname, 'pages/index.vue'), + }) + }, + }, +} diff --git a/webapp/maintenance/source/package.json b/webapp/maintenance/source/package.json new file mode 100644 index 000000000..260a8d615 --- /dev/null +++ b/webapp/maintenance/source/package.json @@ -0,0 +1,16 @@ +{ + "name": "@human-connection/maintenance", + "version": "1.0.0", + "description": "Maintenance page for Human Connection", + "main": "index.js", + "repository": "https://github.com/Human-Connection/Human-Connection", + "author": "Robert Schäfer", + "license": "MIT", + "private": false, + "scripts": { + "dev": "yarn run nuxt -c nuxt.config.maintenance.js", + "build": "yarn run nuxt build -c nuxt.config.maintenance.js", + "start": "yarn run nuxt start -c nuxt.config.maintenance.js", + "generate": "yarn run nuxt generate -c nuxt.config.maintenance.js" + } +} diff --git a/webapp/maintenance/source/pages/index.vue b/webapp/maintenance/source/pages/index.vue new file mode 100644 index 000000000..c13182efa --- /dev/null +++ b/webapp/maintenance/source/pages/index.vue @@ -0,0 +1,48 @@ + + + diff --git a/webapp/maintenance/source/store/index.js b/webapp/maintenance/source/store/index.js new file mode 100644 index 000000000..e69de29bb diff --git a/webapp/nuxt.config.js b/webapp/nuxt.config.js index f4287da1c..cb7b64a82 100644 --- a/webapp/nuxt.config.js +++ b/webapp/nuxt.config.js @@ -1,5 +1,6 @@ +import path from 'path' const pkg = require('./package') -const envWhitelist = ['NODE_ENV', 'MAINTENANCE', 'MAPBOX_TOKEN'] +export const envWhitelist = ['NODE_ENV', 'MAPBOX_TOKEN'] const dev = process.env.NODE_ENV !== 'production' const styleguidePath = '../Nitro-Styleguide' @@ -15,7 +16,7 @@ const buildDir = process.env.NUXT_BUILD || '.nuxt' const additionalSentryConfig = {} if (process.env.COMMIT) additionalSentryConfig.release = process.env.COMMIT -module.exports = { +export default { buildDir, mode: 'universal', @@ -310,7 +311,6 @@ module.exports = { */ extend(config, ctx) { if (process.env.STYLEGUIDE_DEV) { - const path = require('path') config.resolve.alias['@@'] = path.resolve(__dirname, `${styleguidePath}/src/system`) config.module.rules.push({ resourceQuery: /blockType=docs/, diff --git a/webapp/package.json b/webapp/package.json index a5db37e72..b0a09d817 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -15,6 +15,7 @@ "storybook": "start-storybook -p 3002 -c storybook/", "build": "nuxt build", "start": "nuxt start", + "generate:maintenance": "nuxt generate -c nuxt.config.maintenance.js", "generate": "nuxt generate", "lint": "eslint --ext .js,.vue .", "precommit": "yarn lint", diff --git a/webapp/plugins/i18n.js b/webapp/plugins/i18n.js index b568ca39e..591387d00 100644 --- a/webapp/plugins/i18n.js +++ b/webapp/plugins/i18n.js @@ -7,7 +7,7 @@ import { isEmpty, find } from 'lodash' * and implement the user preference logic */ export default ({ app, req, cookie, store }) => { - const debug = app.$env.NODE_ENV !== 'production' + const debug = app.$env && app.$env.NODE_ENV !== 'production' const key = 'locale' const changeHandler = async mutation => {