mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-04-24 04:55:42 +00:00
Mount a /data directory for containers, to allow persistent storage.
This commit is contained in:
parent
a9fe6f3414
commit
3c5e856ef2
@ -117,6 +117,7 @@ exports.start = start = (app) ->
|
||||
Cmd: ['/bin/bash', '-c', '/start']
|
||||
Tty: true
|
||||
Volumes:
|
||||
'/data': {}
|
||||
'/lib/modules': {}
|
||||
Env: _.map env, (v, k) -> k + '=' + v
|
||||
ExposedPorts: ports
|
||||
@ -139,6 +140,7 @@ exports.start = start = (app) ->
|
||||
Privileged: true
|
||||
PortBindings: ports
|
||||
Binds: [
|
||||
'/resin-data/' + app.id + ':/data'
|
||||
'/lib/modules:/lib/modules'
|
||||
'/var/run/docker.sock:/run/docker.sock'
|
||||
]
|
||||
@ -199,6 +201,7 @@ exports.update = update = ->
|
||||
for envVar in app.environment_variable
|
||||
env[envVar.name] = envVar.value
|
||||
return {
|
||||
appId: '' + app.id
|
||||
commit: app.commit
|
||||
imageId: "#{process.env.REGISTRY_ENDPOINT}/#{path.basename(app.git_repository, '.git')}/#{app.commit}"
|
||||
env: JSON.stringify(env) # The env has to be stored as a JSON string for knex
|
||||
@ -210,7 +213,7 @@ exports.update = update = ->
|
||||
|
||||
console.log("Local apps")
|
||||
apps = _.indexBy(apps, 'imageId')
|
||||
localApps = _.mapValues(apps, (app) -> _.pick(app, ['commit', 'imageId', 'env']))
|
||||
localApps = _.mapValues(apps, (app) -> _.pick(app, ['appId', 'commit', 'imageId', 'env']))
|
||||
localImages = _.keys(localApps)
|
||||
console.log(localImages)
|
||||
|
||||
|
@ -7,6 +7,13 @@ knex = Knex.initialize(
|
||||
filename: '/data/database.sqlite'
|
||||
)
|
||||
|
||||
addColumn = (table, column, type) ->
|
||||
knex.schema.hasColumn(table, column)
|
||||
.then (exists) ->
|
||||
if not exists
|
||||
knex.schema.table table, (t) ->
|
||||
t[type](column)
|
||||
|
||||
knex.init = Promise.all([
|
||||
knex.schema.hasTable('config')
|
||||
.then (exists) ->
|
||||
@ -24,14 +31,14 @@ knex.init = Promise.all([
|
||||
t.string('containerId')
|
||||
t.string('commit')
|
||||
t.string('imageId')
|
||||
t.string('appId')
|
||||
t.boolean('privileged')
|
||||
t.json('env')
|
||||
else
|
||||
knex.schema.hasColumn('app', 'commit')
|
||||
.then (exists) ->
|
||||
if not exists
|
||||
knex.schema.table 'app', (t) ->
|
||||
t.string('commit')
|
||||
Promise.all [
|
||||
addColumn('app', 'commit', 'string')
|
||||
addColumn('app', 'appId', 'string')
|
||||
]
|
||||
|
||||
])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user