@@ -18,6 +18,7 @@ const {initNetwork} = require('../src/docker/network');
1818
1919// create tar streams
2020const streamDockerImage = tar . pack ( path . join ( __dirname , 'fixtures' , 'docker-image-project' ) ) ;
21+ const streamDockerImageExternal = tar . pack ( path . join ( __dirname , 'fixtures' , 'docker-image-external' ) ) ;
2122const streamDocker = tar . pack ( path . join ( __dirname , 'fixtures' , 'docker-project' ) ) ;
2223const streamNode = tar . pack ( path . join ( __dirname , 'fixtures' , 'node-project' ) ) ;
2324const streamNodeLock = tar . pack ( path . join ( __dirname , 'fixtures' , 'node-lock-project' ) ) ;
@@ -158,6 +159,52 @@ test('Should deploy simple project from image and image tar', async done => {
158159 done ( ) ;
159160} ) ;
160161
162+ test ( 'Should deploy simple project from external image' , async done => {
163+ const options = Object . assign ( optionsBase , {
164+ payload : streamDockerImageExternal ,
165+ } ) ;
166+
167+ const response = await fastify . inject ( options ) ;
168+ // parse result into lines
169+ const result = response . payload
170+ . split ( '\n' )
171+ . filter ( l => l && l . length )
172+ . map ( line => JSON . parse ( line ) ) ;
173+
174+ // find deployments
175+ const completeDeployments = result . find ( it => it . deployments && it . deployments . length ) . deployments ;
176+
177+ // check response
178+ expect ( response . statusCode ) . toEqual ( 200 ) ;
179+ expect ( completeDeployments . length ) . toEqual ( 1 ) ;
180+ expect ( completeDeployments [ 0 ] . Name . startsWith ( '/busybox' ) ) . toBeTruthy ( ) ;
181+
182+ // check docker services
183+ const allContainers = await docker . listContainers ( ) ;
184+ const containerInfo = allContainers . find ( c => c . Names . includes ( completeDeployments [ 0 ] . Name ) ) ;
185+ const name = completeDeployments [ 0 ] . Name . slice ( 1 ) ;
186+
187+ expect ( containerInfo ) . toBeDefined ( ) ;
188+ expect ( containerInfo . Labels [ 'exoframe.deployment' ] ) . toEqual ( name ) ;
189+ expect ( containerInfo . Labels [ 'exoframe.user' ] ) . toEqual ( 'admin' ) ;
190+ expect ( containerInfo . Labels [ 'exoframe.project' ] ) . toEqual ( 'test-extimage-project' ) ;
191+ expect ( containerInfo . Labels [ 'traefik.backend' ] ) . toEqual ( `${ name } .test` ) ;
192+ expect ( containerInfo . Labels [ 'traefik.docker.network' ] ) . toEqual ( 'exoframe' ) ;
193+ expect ( containerInfo . Labels [ 'traefik.enable' ] ) . toEqual ( 'true' ) ;
194+ expect ( containerInfo . NetworkSettings . Networks . exoframe ) . toBeDefined ( ) ;
195+
196+ const containerData = docker . getContainer ( containerInfo . Id ) ;
197+ const container = await containerData . inspect ( ) ;
198+ expect ( container . NetworkSettings . Networks . exoframe . Aliases . includes ( 'testextimage' ) ) . toBeTruthy ( ) ;
199+ expect ( container . HostConfig . RestartPolicy ) . toMatchObject ( { Name : 'no' , MaximumRetryCount : 0 } ) ;
200+
201+ // cleanup
202+ const instance = docker . getContainer ( containerInfo . Id ) ;
203+ await instance . remove ( { force : true } ) ;
204+
205+ done ( ) ;
206+ } ) ;
207+
161208test ( 'Should deploy simple node project' , async done => {
162209 const options = Object . assign ( optionsBase , {
163210 payload : streamNode ,
0 commit comments