Skip to content

Commit c6ebf35

Browse files
committed
Merge branch 'fix-docker-setup' into register_module
2 parents 1e2e9db + 656a35e commit c6ebf35

28 files changed

+2177
-1549
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ node_modules/
55
build/
66
npm-debug.log
77
Dockerfile
8-
.env
8+
docker-compose*.yml
99
.env-secrets
10+
.env

.env.example

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# WEBAPP
2+
WEBAPP_HOST = localhost
3+
WEBAPP_PORT = 3000
4+
WEBAPP_BASE_URL = http://localhost:3000
5+
6+
# API
7+
API_HOST = localhost
8+
API_PORT = 3030
9+
10+
# METAAPI
11+
EMBED_API_URL = http://localhost:3050
12+
13+
# 3rd party integrations
14+
SENTRY_DNS_PUBLIC =
15+
MAPBOX_TOKEN = pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.KZ8KK9l70omjXbEkkbHGsQ
16+
17+
# MAINTENANCE
18+
MAINTENANCE =

.env.tmp

Lines changed: 0 additions & 35 deletions
This file was deleted.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ npm-debug.log
2727
/nbproject/private/
2828
/nbproject/
2929

30-
# .env and .env-secrets
3130
.env
3231
.env-secrets
3332

.travis.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
language: node_js
22
node_js:
3-
- "8"
3+
- "10"
44
services:
55
- docker
66
cache:
77
yarn: true
88
directories:
99
- node_modules
1010

11-
install:
12-
# nothing
11+
# install current version of yarn
12+
before_install:
13+
- curl -o- -L https://yarnpkg.com/install.sh | bash
14+
- export PATH="$HOME/.yarn/bin:$PATH"
1315

1416
jobs:
1517
include:
1618
- stage: Test and Build
1719
script:
1820
- yarn install --frozen-lockfile --non-interactive
19-
- yarn test:env
20-
- yarn test
21+
- yarn run ci
2122
- script:
22-
- docker build -t humanconnection/frontend-nuxt .
23+
- docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT -t humanconnection/frontend-nuxt .
2324

2425
after_success:
2526
- if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_EVENT_TYPE == "push" ]; then

Dockerfile

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,26 @@
1-
FROM node:8.9-alpine
2-
LABEL Description="This image is used to start the hc-frontend-nuxt" Vendor="Human-Connection gGmbH" Version="1.0" Maintainer="Human-Connection gGmbH ([email protected])"
3-
4-
# update unix packages
5-
RUN apk update && apk upgrade
6-
RUN apk add git
7-
RUN rm -rf /var/cache/apk/*
8-
9-
# install global dependencies
10-
RUN yarn global add pm2 envsub
1+
FROM node:10-alpine
2+
LABEL Description="This image builds and runs the Human-Connection Frontend" Vendor="Human-Connection gGmbH" Version="1.0" Maintainer="Human-Connection gGmbH ([email protected])"
113

124
# expose the app port
135
EXPOSE 3000
146

15-
# set environment variables
16-
ENV HOST=0.0.0.0
17-
ENV WEBAPP_HOST=0.0.0.0
18-
19-
ENTRYPOINT ["./entrypoint.sh"]
20-
21-
# create working directory
22-
RUN mkdir -p /var/www/
23-
WORKDIR /var/www/
24-
25-
# install app dependencies
26-
COPY package.json /var/www/
27-
COPY yarn.lock /var/www/
28-
RUN yarn install --frozen-lockfile --non-interactive
29-
30-
# copy the code to the docker image
31-
COPY . /var/www/
7+
# optional git commit hash
8+
ARG BUILD_COMMIT
9+
ENV BUILD_COMMIT=$BUILD_COMMIT
10+
ENV NODE_ENV=production
3211

33-
# set execution rights on scripts and run the build script
34-
RUN chmod +x entrypoint.sh
35-
RUN chmod +x scripts/on-build.sh
36-
RUN chmod +x scripts/on-start.sh
37-
RUN sh scripts/on-build.sh
12+
RUN mkdir -p /WebApp/
13+
WORKDIR /WebApp/
14+
# --no-cache: download package index on-the-fly, no need to cleanup afterwards
15+
# --virtual: bundle packages, remove whole bundle at once, when done
16+
RUN apk --no-cache --virtual build-dependencies add git python make g++
3817

39-
# buld application
40-
# ENV NODE_ENV=production #we seam to have issues with the production flag on install && build
41-
RUN yarn build
18+
RUN yarn global add pm2
4219

43-
ENV NODE_ENV=production
20+
COPY package.json /WebApp/
21+
COPY yarn.lock /WebApp/
22+
RUN yarn install --production=false --frozen-lockfile --non-interactive
4423

45-
# only keep production dependencies
46-
# RUN yarn install --frozen-lockfile --non-interactive
24+
COPY . /WebApp/
25+
RUN ["yarn", "run", "build"]
26+
CMD ["pm2", "start", "node", "build/main.js", "-n", "frontend", "-i", "2", "--attach"]

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ $ yarn build
3232
$ yarn start
3333
```
3434

35+
Create your individual set of environment variables:
36+
```sh
37+
$ cp .env.example .env
38+
# now open .env and change it according to your setup
39+
```
40+
3541
For detailed explanation on how things work, checkout the [Nuxt.js docs](https://github.com/nuxt/nuxt.js).
3642

3743
## Env Vars

docker-compose.override.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
version: '3'
2+
3+
services:
4+
webapp:
5+
networks:
6+
hc-network:
7+
ipv4_address: 172.25.0.20
8+
environment:
9+
- NODE_ENV=development
10+
- MAINTENANCE=${MAINTENANCE}
11+
- WEBAPP_HOST=172.25.0.20
12+
- WEBAPP_BASE_URL=http://172.25.0.20:3000
13+
- API_HOST=172.25.0.11
14+
- WEBAPP_PORT=3000
15+
- API_PORT=3030
16+
- MAPBOX_TOKEN=pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.KZ8KK9l70omjXbEkkbHGsQ
17+
- SENTRY_DNS_PUBLIC=${SENTRY_DNS_PUBLIC}
18+
- EMBED_API_URL=${EMBED_API_URL}
19+
# these secrets should only be accessible on the server:
20+
- SENTRY_DNS_PRIVATE=${SENTRY_DNS_PRIVATE}
21+
- EMBED_API_TOKEN=${EMBED_API_TOKEN}
22+
depends_on:
23+
- api
24+
mongo:
25+
image: mongo
26+
networks:
27+
- hc-network
28+
command: "--smallfiles --logpath=/dev/null"
29+
api:
30+
image: humanconnection/api-feathers
31+
depends_on:
32+
- maildev
33+
- thumbor
34+
- mongo
35+
environment:
36+
- NODE_ENV=staging
37+
ports:
38+
- "3030:3030"
39+
stdin_open: true
40+
tty: true
41+
networks:
42+
hc-network:
43+
ipv4_address: 172.25.0.11
44+
maildev:
45+
image: djfarrelly/maildev
46+
networks:
47+
- hc-network
48+
ports:
49+
- "1080:80"
50+
- "1025:25"
51+
thumbor:
52+
image: apsl/thumbor
53+
networks:
54+
- hc-network
55+
ports:
56+
- "8000:8000"
57+
58+
networks:
59+
hc-network:
60+
driver: bridge
61+
ipam:
62+
driver: default
63+
config:
64+
-
65+
subnet: 172.25.0.0/16

docker-compose.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
version: '2'
1+
version: '3'
22

33
services:
4-
frontend:
5-
build: .
6-
environment:
7-
WEBAPP_HOST: localhost
8-
WEBAPP_PORT: 3000
9-
WEBAPP_BASE_URL: http://localhost:3000
10-
API_HOST: http://localhost
11-
API_PORT: 3030
12-
MAPBOX_TOKEN:
4+
webapp:
5+
image: humanconnection/frontend-nuxt
6+
build:
7+
context: .
8+
args:
9+
BUILD_COMMIT: ${BUILD_COMMIT}
1310
stdin_open: true
1411
tty: true
1512
ports:
16-
- 3000:3000/tcp
13+
- 3000:3000/tcp

entrypoint.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)