mirror of
https://github.com/fergalmoran/onearmy-community-platform.git
synced 2026-01-06 08:54:02 +00:00
fix: add functions build wait for docker emulator
This commit is contained in:
@@ -44,7 +44,9 @@ Note - any data populated into the emulator will be deleted after the emulator h
|
||||
|
||||
## Resetting seed data
|
||||
|
||||
When the emulator is stopped the image is destroyed, so each time the emulators are restarted a clean set of data will be available
|
||||
When the emulator is stopped the image is destroyed, so each time the emulators are restarted a clean set of data will be available.
|
||||
|
||||
If using the frontend data changes may still persist due to the browser's own caching mechanisms. In this case the browser indexeddb cache will need to be manually cleared
|
||||
|
||||
## Frontend
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Dockerode from 'dockerode'
|
||||
import boxen from 'boxen'
|
||||
import logUpdate from 'log-update'
|
||||
import fs from 'fs-extra'
|
||||
import {
|
||||
CONTAINER_NAME,
|
||||
getFirebasePortMapping,
|
||||
@@ -95,11 +96,18 @@ function attachContainer(container: Dockerode.Container) {
|
||||
}
|
||||
|
||||
async function createNewContainer() {
|
||||
// ensure functions dist exists for binding
|
||||
if (!fs.existsSync(PATHS.functionsDistIndex)) {
|
||||
console.log('Waiting for functions to be built...')
|
||||
await _wait(5000)
|
||||
return createNewContainer()
|
||||
}
|
||||
// pull remote image if required
|
||||
if (REPOSITORY) {
|
||||
await pullRemoteImage(IMAGE_NAME)
|
||||
}
|
||||
const { ExposedPorts, PortBindings } = rewritePortMapping()
|
||||
return new Promise<Dockerode.Container>((resolve, reject) => {
|
||||
return new Promise<Dockerode.Container>(async (resolve, reject) => {
|
||||
docker.createContainer(
|
||||
{
|
||||
// Image: 'goatlab/firebase-emulator:latest',
|
||||
@@ -237,4 +245,11 @@ function execContainerCmd(container: Dockerode.Container, Cmd: string[]) {
|
||||
)
|
||||
}
|
||||
|
||||
/** Wait an aribitrary number of milliseconds before continuing */
|
||||
async function _wait(ms: number) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms)
|
||||
})
|
||||
}
|
||||
|
||||
start()
|
||||
|
||||
Reference in New Issue
Block a user