Fix, update and tweak docker builds

This commit is contained in:
Jonatan Nilsson 2018-07-15 03:19:58 +00:00
parent 5b798d0693
commit 3ce1d60196
4 changed files with 37 additions and 19 deletions

View file

@ -10,11 +10,6 @@ jobs:
- run: - run:
name: Build docker image name: Build docker image
command: docker build -t nfpis/caspar-sup:build_${CIRCLE_BUILD_NUM} -t nfpis/caspar-sup:${CIRCLE_SHA1} -t nfpis/caspar-sup:latest . command: docker build -t nfpis/caspar-sup:build_${CIRCLE_BUILD_NUM} -t nfpis/caspar-sup:${CIRCLE_SHA1} -t nfpis/caspar-sup:latest .
- run:
name: Run test and lint
command: |
docker run nfpis/recording_control npm run lint
docker run nfpis/recording_control npm run test
- deploy: - deploy:
name: Push to docker name: Push to docker
command: | command: |

View file

@ -1,15 +1,40 @@
FROM node:slim ###########################
# Mithril
###########################
FROM node:8-alpine as build
ENV HOME=/app ENV HOME=/app
COPY package.json $HOME/ COPY package.json $HOME/
COPY app $HOME/app
COPY public $HOME/public
WORKDIR $HOME WORKDIR $HOME
RUN npm install RUN apk add --no-cache make gcc g++ python && \
npm install && \
npm run build
COPY . $HOME/ ###########################
# Server
###########################
FROM node:8-alpine
EXPOSE 4011 ENV HOME=/app
COPY .babelrc config.js log.js index.js package.json $HOME/
WORKDIR $HOME
RUN apk add --no-cache make gcc g++ python && \
npm install --production
COPY api $HOME/api
COPY migrations $HOME/migrations
COPY config $HOME/config
COPY script $HOME/script
COPY --from=build /app/public $HOME/public
EXPOSE 3000
CMD ["npm", "start"] CMD ["npm", "start"]

View file

@ -44,32 +44,31 @@
}, },
"homepage": "https://github.com/nfp-projects/caspar-sup#readme", "homepage": "https://github.com/nfp-projects/caspar-sup#readme",
"dependencies": { "dependencies": {
"app-root-path": "^2.0.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-register": "^6.26.0", "babel-register": "^6.26.0",
"bookshelf": "^0.11.1", "bookshelf": "^0.13.3",
"bunyan": "^1.8.12", "bunyan": "^1.8.12",
"casparcg-connection": "^4.1.0", "casparcg-connection": "4.1.0",
"dragula": "^3.7.2",
"ip": "^1.1.5", "ip": "^1.1.5",
"knex": "^0.14.2", "knex": "^0.14.2",
"koa": "^2.4.1", "koa": "^2.4.1",
"koa-better-serve": "^2.0.7", "koa-better-serve": "^2.0.7",
"koa-socket": "^4.4.0", "koa-socket": "^4.4.0",
"mithril": "^1.1.5",
"nconf": "^0.9.1", "nconf": "^0.9.1",
"socket.io": "^2.0.4", "socket.io": "^2.0.4",
"socket.io-client": "^2.0.4",
"sqlite3": "^3.1.13" "sqlite3": "^3.1.13"
}, },
"devDependencies": { "devDependencies": {
"babelify": "^8.0.0", "babelify": "^8.0.0",
"browserify": "^16.2.2", "browserify": "^16.2.2",
"dragula": "^3.7.2",
"eslint": "^4.16.0", "eslint": "^4.16.0",
"eslint-plugin-mocha": "^4.11.0", "eslint-plugin-mocha": "^4.11.0",
"mithril": "^1.1.5",
"mocha": "^4.0.1", "mocha": "^4.0.1",
"nodemon": "^1.12.1", "nodemon": "^1.12.1",
"npm-run-all": "^4.1.2", "npm-run-all": "^4.1.2",
"socket.io-client": "^2.0.4",
"stylus": "^0.54.5", "stylus": "^0.54.5",
"watchify": "^3.9.0" "watchify": "^3.9.0"
} }

View file

@ -3,9 +3,8 @@
'use strict' 'use strict'
const _ = require('lodash') const _ = require('lodash')
const appRoot = require('app-root-path') const config = require('../config')
const config = require(appRoot.resolve('/config')) let log = require('../log').default
let log = require(appRoot.resolve('/log')).default
// This is important for setup to run cleanly. // This is important for setup to run cleanly.
let knexConfig = _.cloneDeep(config.get('knex')) let knexConfig = _.cloneDeep(config.get('knex'))
@ -17,7 +16,7 @@ log.info(knexConfig, 'Connected to database')
let setup = module.exports = () => let setup = module.exports = () =>
knex.migrate.latest({ knex.migrate.latest({
directory: appRoot.resolve('/migrations'), directory: './migrations',
}) })
.then((result) => { .then((result) => {
if (result[1].length === 0) { if (result[1].length === 0) {