Skip to content

Commit

Permalink
Continuing dockerization
Browse files Browse the repository at this point in the history
updated versions of node modules that were causing installation to fail (sass stuff)
small change to a scss file that caused problems after that update
small change to karma config to stop browser launch in container
  • Loading branch information
peichins committed Sep 10, 2019
1 parent 16027ca commit 5bb9681
Show file tree
Hide file tree
Showing 6 changed files with 1,743 additions and 1,419 deletions.
28 changes: 27 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ RUN apk --update add git less openssh && \
chown node:node /home/node/workbench-client



USER node

WORKDIR /home/node/workbench-client
Expand All @@ -23,5 +22,32 @@ RUN npm i npm@latest -g && \
npm install --no-optional && \
npm cache clean --force


# temp while developing, to tweak things without npm installing every time
# ENV NODE_ENV=development
# RUN npm install

COPY . .

EXPOSE 9018 9100 8080

## Installs latest Chromium package, in case we want the karma browser to run in the container
#RUN echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories \
# && echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories \
# && apk add --no-cache \
# chromium@edge \
# harfbuzz@edge \
# nss@edge \
# freetype@edge \
# ttf-freefont@edge \
# && rm -rf /var/cache/* \
# && mkdir /var/cache/apk
#
## make node chrome's user, so it can run chrome
#RUN mkdir -p /usr/src/app \
# && chown -R node:node /usr/src/app
#
#ENV CHROME_BIN=/usr/bin/chromium-browser \
# CHROME_PATH=/usr/lib/chromium/
#
### end chrome stuff
4 changes: 3 additions & 1 deletion buildConfig/karma-unit.tpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ module.exports = function (config) {
* open and the tests will automatically occur there during the build. This has
* the aesthetic advantage of not launching a browser every time you save.
*/
configObject.browsers = [ browserToUse ];
// in docker container, don't launch browser, but map the ports so we can launch the browser manually in the host.

configObject.browsers = [ ];

config.colors = true;

Expand Down
37 changes: 37 additions & 0 deletions docker_stuff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#Notes for building and running docker image/container

## build the image

`TAG=bc`
`docker build . -t $TAG`

## run the container

run with this directory mounted so you can edit locally and have stuff updated
- note: there is no bash in alpine, so use sh
- `NODE_ENV` can be development or production.
- port 9018 is for karma and 8080 is for the client itself.
- port 9100 is mentioned in the karma file, but I am still not sure how to use it

`docker run -ti --rm --env NODE_ENV=development --mount type=bind,src="$(pwd)",dst=/home/node/workbench-client -p 9018:9018 -p 9100:9100 -p 8080:8080 $TAG sh`

or for root user (probably not necessary)
`docker run -ti --rm --env NODE_ENV=development -u root:root --mount type=bind,src="$(pwd)",dst=/home/node/workbench-client -p 9018:9018 -p 9100:9100 -p 8080:8080 $TAG sh`

## start it

Within the container interactive mode:

`npm install`

Note, I have also built the image with `RUN npm install` to save time if starting and stopping the container a lot

`npm start`

Karma is configured not to launch a browser, to save having to work with a browser in the container.
After the output `INFO [karma]: Karma v0.13.22 server started at http://localhost:9018/` on the host, open a browser
and navigate to `http://localhost:9018?id=12345678`
I am not sure if the id is necessary

After the output
Note: it seems to take a long time to get past `Build webserver directory: build`
Loading

0 comments on commit 5bb9681

Please sign in to comment.