Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
343a7a3
Complete rewrite of configuration
roschaefer Aug 13, 2018
159054f
Simplify Dockerfile and docker-compose.yml
roschaefer Aug 13, 2018
0fcf885
Provide the BUILD_COMMIT on the build server
roschaefer Aug 14, 2018
1da0906
Update base image of Dockerfile
roschaefer Aug 14, 2018
8a5b3a1
Give image a name as on build server
roschaefer Aug 14, 2018
ada1f5b
Provide a staging docker-compose.yml for WebApp
roschaefer Aug 14, 2018
3867418
Various fixes:
roschaefer Aug 19, 2018
7d4c13b
Prefix yarn scripts based on purpose in docker
roschaefer Aug 19, 2018
2433ff3
Remove docker-compose.override.yml
roschaefer Aug 19, 2018
3543185
Make docker-compose.staging.yml default override
roschaefer Aug 31, 2018
964f232
Remove custom code to read process.env at runtime
roschaefer Aug 31, 2018
b5058ed
Don't rebuild the app at runtime
roschaefer Aug 31, 2018
03a77bb
Pin versions of dependencies for stability
roschaefer Sep 19, 2018
5570729
Bugfix: Duplicate thumbor in docker-compose.yml
roschaefer Sep 19, 2018
47c7e35
Remove obsolete step in Dockerfile
roschaefer Sep 19, 2018
601a6f8
Whitelist BUILD_COMMIT, fix logout error
roschaefer Sep 19, 2018
656a35e
Bugfix: process.env in non-plugin raven-server
roschaefer Sep 19, 2018
e69f6a3
fixing docker build
appinteractive Sep 21, 2018
26346e5
Merge branch 'develop' into fix-docker-setup
Lulalaby Sep 22, 2018
b638dfa
Use docker bridge for dev setup
Sep 21, 2018
703fcde
Use global network of API docker-compose
roschaefer Sep 29, 2018
01054f4
Incorporate @ionphractal 's feedback thanks :+1:
roschaefer Oct 1, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ node_modules/
build/
npm-debug.log
Dockerfile
.env
docker-compose*.yml
.env-secrets
.env
18 changes: 18 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# WEBAPP
WEBAPP_HOST = localhost
WEBAPP_PORT = 3000
WEBAPP_BASE_URL = http://localhost:3000

# API
API_HOST = localhost
API_PORT = 3030

# METAAPI
EMBED_API_URL = http://localhost:3050

# 3rd party integrations
SENTRY_DNS_PUBLIC =
MAPBOX_TOKEN = pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.KZ8KK9l70omjXbEkkbHGsQ

# MAINTENANCE
MAINTENANCE =
35 changes: 0 additions & 35 deletions .env.tmp

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ npm-debug.log
/nbproject/private/
/nbproject/

# .env and .env-secrets
.env
.env-secrets

Expand Down
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
language: node_js
node_js:
- "8"
- "10"
services:
- docker
cache:
yarn: true
directories:
- node_modules

install:
# nothing
# install current version of yarn
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@appinteractive is this redundant?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it can be removed. Was caused by the unversionated bode image before.


jobs:
include:
- stage: Test and Build
script:
- yarn install --frozen-lockfile --non-interactive
- yarn test:env
- yarn test
- yarn run ci
- script:
- docker build -t humanconnection/frontend-nuxt .
- docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT -t humanconnection/frontend-nuxt .

after_success:
- if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_EVENT_TYPE == "push" ]; then
Expand Down
56 changes: 18 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,46 +1,26 @@
FROM node:8.9-alpine
LABEL Description="This image is used to start the hc-frontend-nuxt" Vendor="Human-Connection gGmbH" Version="1.0" Maintainer="Human-Connection gGmbH (developer@human-connection.org)"

# update unix packages
RUN apk update && apk upgrade
RUN apk add git
RUN rm -rf /var/cache/apk/*

# install global dependencies
RUN yarn global add pm2 envsub
FROM node:10-alpine
LABEL Description="This image builds and runs the Human-Connection Frontend" Vendor="Human-Connection gGmbH" Version="1.0" Maintainer="Human-Connection gGmbH (developer@human-connection.org)"

# expose the app port
EXPOSE 3000

# set environment variables
ENV HOST=0.0.0.0
ENV WEBAPP_HOST=0.0.0.0

ENTRYPOINT ["./entrypoint.sh"]

# create working directory
RUN mkdir -p /var/www/
WORKDIR /var/www/

# install app dependencies
COPY package.json /var/www/
COPY yarn.lock /var/www/
RUN yarn install --frozen-lockfile --non-interactive

# copy the code to the docker image
COPY . /var/www/
# optional git commit hash
ARG BUILD_COMMIT
ENV BUILD_COMMIT=$BUILD_COMMIT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing parts should always go lower to increase cache efficienty at build time.

ENV NODE_ENV=production

# set execution rights on scripts and run the build script
RUN chmod +x entrypoint.sh
RUN chmod +x scripts/on-build.sh
RUN chmod +x scripts/on-start.sh
RUN sh scripts/on-build.sh
RUN mkdir -p /WebApp/
WORKDIR /WebApp/
# --no-cache: download package index on-the-fly, no need to cleanup afterwards
# --virtual: bundle packages, remove whole bundle at once, when done
RUN apk --no-cache --virtual build-dependencies add git python make g++
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roschaefer What about security updates? Dont we need them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also why do you need phython, make and g++?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was having troubles to build other dependencies. Surprisingly. I haven't researched the issue but as far as I remember that was related to the newer node version of this docker container. 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with node:8-alpine it does work, with node:alpine not


# buld application
# ENV NODE_ENV=production #we seam to have issues with the production flag on install && build
RUN yarn build
RUN yarn global add pm2

ENV NODE_ENV=production
COPY package.json /WebApp/
COPY yarn.lock /WebApp/
RUN yarn install --production=false --frozen-lockfile --non-interactive

# only keep production dependencies
# RUN yarn install --frozen-lockfile --non-interactive
COPY . /WebApp/
RUN ["yarn", "run", "build"]
CMD ["pm2", "start", "node", "build/main.js", "-n", "frontend", "-i", "2", "--attach"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use yarn start:pm2?

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ Connect with other developers over [Discord](https://discord.gg/NgVpvx9)<br />

## License
Copyright (c) 2018 [Human-Connection.org](https://human-connection.org)<br />
Licensed under the [MIT](https://github.com/Human-Connection/WebApp/blob/develop/LICENSE.md) license.<br />
Licensed under the [MIT](https://github.com/Human-Connection/WebApp/blob/develop/LICENSE.md) license.<br />
11 changes: 11 additions & 0 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3.5'

services:
webapp:
environment:
- NODE_ENV=development
volumes:
- .:/WebApp/
- /WebApp/node_modules
command: yarn run dev
tty: true
12 changes: 12 additions & 0 deletions docker-compose.staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.5'

services:
webapp:
environment:
- NODE_ENV=development # this is just `development` so https will not be enforced
- MAINTENANCE=${MAINTENANCE}
- SENTRY_DNS_PUBLIC=${SENTRY_DNS_PUBLIC}
- EMBED_API_URL=${EMBED_API_URL}
# these secrets should only be accessible on the server:
- SENTRY_DNS_PRIVATE=${SENTRY_DNS_PRIVATE}
- EMBED_API_TOKEN=${EMBED_API_TOKEN}
34 changes: 21 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
version: '2'
version: '3.5'

services:
frontend:
build: .
environment:
WEBAPP_HOST: localhost
WEBAPP_PORT: 3000
WEBAPP_BASE_URL: http://localhost:3000
API_HOST: http://localhost
API_PORT: 3030
MAPBOX_TOKEN:
stdin_open: true
tty: true
webapp:
image: humanconnection/frontend-nuxt:edge
ports:
- 3000:3000/tcp
- "3000:3000"
build:
context: .
args:
BUILD_COMMIT: ${BUILD_COMMIT}
networks:
- hc-network
environment:
- WEBAPP_HOST=webapp
- WEBAPP_BASE_URL=http://localhost:3000
- API_HOST=api.127.0.0.1.xip.io
- WEBAPP_PORT=3000
- API_PORT=3030
- MAPBOX_TOKEN=pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.KZ8KK9l70omjXbEkkbHGsQ

networks:
hc-network:
name: hc-network
12 changes: 0 additions & 12 deletions entrypoint.sh

This file was deleted.

2 changes: 1 addition & 1 deletion layouts/blank.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
title: 'loading...'
}
if (process.env.NODE_ENV === 'development') {
if (this.$env.NODE_ENV === 'development') {
head.script = [
{ src: 'https://cdn.jsdelivr.net/npm/tota11y@0.1.6/build/tota11y.min.js' }
]
Expand Down
2 changes: 1 addition & 1 deletion layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
title: 'loading...'
}
if (process.env.NODE_ENV === 'development') {
if (this.$env.NODE_ENV === 'development') {
head.script = [
{ src: 'https://cdn.jsdelivr.net/npm/tota11y@0.1.6/build/tota11y.min.js' }
]
Expand Down
2 changes: 1 addition & 1 deletion layouts/error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
},
mounted () {
if (process.env.NODE_ENV === 'development') {
if (this.$env.NODE_ENV === 'development') {
console.error(this.error.message)
}

Expand Down
4 changes: 2 additions & 2 deletions middleware/authenticated.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isEmpty } from 'lodash'

export default async ({ store, route, redirect }) => {
let publicPages = process.env.publicPages
export default async ({ store, env, route, redirect }) => {
let publicPages = env.publicPages
publicPages.push('auth-logout')
// only affect non public pages
if (publicPages.indexOf(route.name) >= 0) {
Expand Down
20 changes: 16 additions & 4 deletions nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
require('dotenv').config()
const path = require('path')
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',
'MAINTENANCE'
]

module.exports = {
env: {
Expand Down Expand Up @@ -93,7 +105,6 @@ module.exports = {
}
},
plugins: [
{src: '~/plugins/env.js'},
{src: '~/plugins/debug.js', ssr: false},
{src: '~/plugins/raven-client.js', ssr: false},
{src: '~/plugins/api.js'},
Expand All @@ -112,8 +123,9 @@ module.exports = {
{src: '~/plugins/open-page-in-modal.js', ssr: false}
],
modules: [
'cookie-universal-nuxt',
'@nuxtjs/dotenv'
['@nuxtjs/dotenv', { only: envWhitelist }],
['nuxt-env', { keys: envWhitelist }],
'cookie-universal-nuxt'
// '@nuxtjs/pwa'
],
router: {
Expand Down
25 changes: 10 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,20 @@
],
"engines": {
"node": ">= 8.9.0",
"yarn": ">= 1.3.0"
"yarn": ">= 1.8.0"
},
"scripts": {
"dev": "yarn dev:env && backpack dev",
"dev:local": "sh scripts/run-local.sh",
"dev:debug": "yarn dev:env && backpack dev --inspect-brk=9229",
"dev:env": "sh scripts/on-dev.sh",
"build": "yarn build:env && nuxt build && backpack build",
"build:env": "sh scripts/on-build.sh",
"start": "yarn start:env && node build/main.js",
"start:pm2": "yarn start:env && pm2 start node build/main.js -n frontend -i 2 --attach",
"start:env": "sh scripts/on-start.sh",
"refresh": "rm -rf node_modules && yarn install && npm run dev",
"ci": "yarn run eslint && yarn run test",
"clean": "rm -rf build/*",
"dev": "backpack dev",
"dev:debug": "backpack dev --inspect=0.0.0.0:9229",
"build": "nuxt build && backpack build",
"start": "node build/main.js",
"precommit": "yarn eslint",
"eslint": "eslint --ext .js,.vue .",
"styleguide": "vue-styleguidist server",
"styleguide:build": "vue-styleguidist build",
"test": "ava",
"test:env": "sh scripts/on-dev.sh",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov"
Expand All @@ -52,7 +47,7 @@
"@feathersjs/client": "^3.5.3",
"@feathersjs/feathers": "^3.1.7",
"@feathersjs/socketio": "^3.2.2",
"@nuxtjs/dotenv": "~1.1.0",
"@nuxtjs/dotenv": "^1.1.1",
"@nuxtjs/pwa": "~2.0.5",
"axios": "^0.18.0",
"babel-eslint": "~8.2.5",
Expand All @@ -70,7 +65,6 @@
"css-loader": "~0.28.10",
"csv-parse": "~2.5.0",
"emitter-js": "~2.0.1",
"envsub": "~3.1.0",
"express": "~4.16.2",
"express-healthcheck": "~0.1.0",
"express-locale": "~1.0.5",
Expand All @@ -85,7 +79,8 @@
"lodash": "~4.17.11",
"mapbox-gl": "~0.45.0",
"moment": "^2.22.2",
"nuxt": "~1.4.0",
"nuxt": "^1.4.2",
"nuxt-env": "^0.0.3",
"parchment": "^1.1.4",
"quill": "^1.3.6",
"quill-delta": "^3.6.2",
Expand Down
Loading