Skip to content
This repository was archived by the owner on Nov 23, 2022. It is now read-only.

Commit 3583f61

Browse files
committed
Add support for volumes for deployments
1 parent 14cd207 commit 3583f61

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/docker/start.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,18 @@ exports.start = async ({image, username, folder, resultStream, existing = []}) =
264264
},
265265
};
266266

267+
// if volumes are set - add them to config
268+
if (config.volumes && config.volumes.length) {
269+
const mounts = config.volumes
270+
.map(vol => vol.split(':'))
271+
.map(([src, dest]) => ({
272+
Type: 'volume',
273+
Source: src,
274+
Target: dest,
275+
}));
276+
containerConfig.HostConfig.Mounts = mounts;
277+
}
278+
267279
if (config.hostname && config.hostname.length) {
268280
containerConfig.NetworkingConfig = {
269281
EndpointsConfig: {

test/deploy.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ test('Should deploy simple docker project', async done => {
9393
expect(containerInfo.Labels['traefik.docker.network']).toEqual('exoframe');
9494
expect(containerInfo.Labels['traefik.enable']).toEqual('true');
9595
expect(containerInfo.NetworkSettings.Networks.exoframe).toBeDefined();
96+
expect(containerInfo.Mounts.length).toEqual(1);
97+
expect(containerInfo.Mounts[0].Type).toEqual('volume');
98+
expect(containerInfo.Mounts[0].Name).toEqual('test');
99+
expect(containerInfo.Mounts[0].Source).toEqual('/var/lib/docker/volumes/test/_data');
100+
expect(containerInfo.Mounts[0].Destination).toEqual('/volume');
96101

97102
const containerData = docker.getContainer(containerInfo.Id);
98103
const container = await containerData.inspect();

test/fixtures/docker-project/exoframe.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"name": "test-docker-deploy",
33
"hostname": "test",
44
"project": "test-project",
5-
"restart": "no"
5+
"restart": "no",
6+
"volumes": ["test:/volume"]
67
}

0 commit comments

Comments
 (0)