Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 868683d

Browse files
Setup docker based deployment
1 parent b3be569 commit 868683d

File tree

7 files changed

+41
-17
lines changed

7 files changed

+41
-17
lines changed

app.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,21 @@ const cors = require('cors')
1414
const logger = require('./src/common/logger')
1515
const HttpStatus = require('http-status-codes')
1616

17+
const buildEnvironments = ['production', 'staging']
18+
1719
// setup express app
1820
const app = express()
1921

22+
app.enable('trust proxy')
23+
24+
function forceSSL (req, res, next) {
25+
if (!req.secure && req.get('x-forwarded-proto') !== 'https' && buildEnvironments.includes(process.env.NODE_ENV)) {
26+
return res.redirect('https://' + req.get('host') + req.url)
27+
}
28+
next()
29+
}
30+
31+
app.use(forceSSL)
2032
app.use(cors())
2133
app.use(bodyParser.json())
2234
app.use(bodyParser.urlencoded({ extended: true }))

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "u-bahn-app",
2+
"name": "u-bahn-app-fe",
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {

docker/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
FROM node:12
33

44
# Copy the current directory into the Docker image
5-
COPY . /ubahn_search_ui_api
5+
COPY . /ubahn_app
66

77
# Set working directory for future use
8-
WORKDIR /ubahn_search_ui_api
8+
WORKDIR /ubahn_app
99

1010
# Install the dependencies from package.json
1111
RUN npm install
12+
RUN npm run install-client
1213
CMD npm start

docker/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
version: '3'
22
services:
3-
ubahn_search_ui_api:
4-
image: ubahn_search_ui_api:latest
3+
ubahn_app:
4+
image: ubahn_app:latest
55
build:
66
context: ../
77
dockerfile: docker/Dockerfile
88
env_file:
99
- api.env
1010
ports:
11-
- "3001:3001"
11+
- "3000:3000"

docker/sample.api.env

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
API_VERSION=
2-
AUTH_SECRET=
3-
VALID_ISSUERS=
4-
AUTH0_URL=
52
AUTH0_AUDIENCE=
6-
TOKEN_CACHE_TIME=
7-
AUTH0_CLIENT_ID=
83
AUTH0_CLIENT_SECRET=
9-
UPLOAD_CREATE_TOPIC=
4+
AUTH0_CLIENT_ID=
5+
AUTH0_PROXY_SERVER_URL=
6+
AUTH0_URL=
7+
AUTH_SECRET=
108
AWS_ACCESS_KEY_ID=
11-
AWS_SECRET_ACCESS_KEY=
129
AWS_REGION=
13-
TEMPLATE_S3_BUCKET=
14-
UPLOAD_S3_BUCKET=
10+
AWS_SECRET_ACCESS_KEY=
1511
EMSI_CLIENT_ID=
1612
EMSI_CLIENT_SECRET=
13+
NODE_ENV=
14+
REACT_APP_API_PREFIX=
15+
REACT_APP_API_URL=
16+
REACT_APP_AUTH0_AUDIENCE=
17+
REACT_APP_AUTH0_CLIENTID=
18+
REACT_APP_AUTH0_DOMAIN=
19+
REACT_APP_BULK_UPLOAD_TEMPLATE_ID=
20+
REACT_APP_EMSI_SKILLPROVIDER_ID=
21+
REACT_APP_GROUPS_API_URL=
22+
TEMPLATE_S3_BUCKET=
23+
TOKEN_CACHE_TIME=
24+
UPLOAD_CREATE_TOPIC=
25+
UPLOAD_S3_BUCKET=
26+
VALID_ISSUERS=

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
2-
"name": "ubahn-search-ui-api",
2+
"name": "ubahn-app",
33
"version": "1.0.0",
44
"description": "UBahn search ui api",
55
"main": "app.js",
66
"scripts": {
7+
"install-client": "cd client && npm install && cd ..",
78
"client": "cd client && npm start",
89
"start": "node app.js",
910
"dev": "concurrently --kill-others-on-fail \"npm start\" \"cd client && npm start\"",

src/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = {
7575
scopes: [constants.Scopes.GetSkill, constants.Scopes.AllSkill]
7676
}
7777
},
78-
'/ubahnsearchapi/health': {
78+
'/health': {
7979
get: {
8080
controller: 'HealthCheckController',
8181
method: 'check'

0 commit comments

Comments
 (0)