Skip to content

Commit 02dc2da

Browse files
authored
Merge pull request #1006 from HSLdevcom/NitorCreations-tune-docker-build
Nitor creations tune docker build
2 parents f88db1a + be8b976 commit 02dc2da

3 files changed

Lines changed: 26 additions & 24 deletions

File tree

Dockerfile

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,41 @@ MAINTAINER Reittiopas version: 0.1
44
EXPOSE 8080
55
LABEL io.openshift.expose-services 8080:http
66

7-
# Where the app is built and run inside the docker fs
8-
ENV WORK=/opt/digitransit-ui
9-
10-
# Used indirectly for saving npm logs etc.
11-
ENV HOME=/opt/digitransit-ui
12-
13-
# App specific settings to override when the image is run
14-
ENV SENTRY_DSN=''
15-
ENV SENTRY_SECRET_DSN=''
16-
ENV PORT=8080
17-
ENV API_URL=''
18-
ENV MAP_URL=''
19-
ENV APP_PATH=''
20-
ENV CONFIG=''
21-
ENV PIWIK_ADDRESS=''
22-
ENV PIWIK_ID=''
23-
ENV NODE_ENV=''
7+
ENV \
8+
# Where the app is built and run inside the docker fs \
9+
WORK=/opt/digitransit-ui \
10+
# Used indirectly for saving npm logs etc. \
11+
HOME=/opt/digitransit-ui \
12+
# App specific settings to override when the image is run \
13+
SENTRY_DSN='' \
14+
SENTRY_SECRET_DSN='' \
15+
PORT=8080 \
16+
API_URL='' \
17+
MAP_URL='' \
18+
APP_PATH='' \
19+
CONFIG='' \
20+
PIWIK_ADDRESS='' \
21+
PIWIK_ID='' \
22+
NODE_ENV=''
2423

2524
WORKDIR ${WORK}
2625
ADD . ${WORK}
2726

2827
# Build and set permissions for arbitary non-root users in OpenShift
2928
# (https://docs.openshift.org/latest/creating_images/guidelines.html#openshift-specific-guidelines)
30-
RUN npm install && \
29+
RUN \
30+
npm install && \
3131
npm run static && \
3232
npm rebuild node-sass && \
3333
npm run build && \
34+
rm -rf static docs test /tmp/* && \
35+
npm prune --production && \
3436
npm cache clean && \
35-
chmod -R a+rwX .
37+
chmod -R a+rwX . && \
38+
chown -R 9999:9999 ${WORK}
3639

3740
# Don't run as root, because there's no reason to (https://docs.docker.com/engine/articles/dockerfile_best-practices/#user).
3841
# This also reveals permission problems on local Docker, before pushing to OpenShift.
39-
RUN chown -R 9999:9999 ${WORK}
4042
USER 9999
4143

4244
CMD npm run start

app/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ function getStringOrArrayElement(arrayOrString, index) {
4242
// Look up paths for various asset files
4343
const appRoot = `${process.cwd()}/`;
4444

45-
const svgSprite = fs.readFileSync(`${appRoot}static/svg-sprite.${config.CONFIG}.svg`).toString();
46-
const geolocationStarter = fs.readFileSync(`${appRoot}static/geolocation.js`).toString();
45+
const svgSprite = fs.readFileSync(`${appRoot}_static/svg-sprite.${config.CONFIG}.svg`).toString();
46+
const geolocationStarter = fs.readFileSync(`${appRoot}_static/geolocation.js`).toString();
4747

4848
const networkLayer = new RelayNetworkLayer([
4949
urlMiddleware({

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"scripts": {
88
"static": "mkdir -p _static/js; mkdir -p _static/css; cp -r static/* _static",
99
"win-static": "xcopy static\\* _static /e /s /y /i& if not exist _static\\js mkdir _static\\js& if not exist _static\\css mkdir _static\\css",
10+
"prestart": "npm run static",
11+
"prewin-start": "npm run win-static",
1012
"predev": "npm run static",
1113
"predev-win-hsl": "npm run win-static",
1214
"predev-win-national": "npm run win-static",
13-
"prestart": "npm run static",
14-
"prewin-start": "npm run win-static",
1515
"dev": "PID=$$; trap 'pkill -QUIT -P $PID > /dev/null' EXIT; NODE_ENV=development nodemon -e js,css,scss,html --watch ./app/ server/server.js -x \"node --harmony\" & NODE_ENV=development forever -f start server/hotLoadServer.js",
1616
"dev-win-hsl": "cd win-launch-scripts&& hsl-win-launch-script.bat",
1717
"dev-win-national": "cd win-launch-scripts&& set CONFIG=&& national-win-launch-script.bat",

0 commit comments

Comments
 (0)