diff --git a/server/Dockerfile b/server/Dockerfile index f61aefd..c1aee31 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -10,4 +10,7 @@ RUN npm install COPY . . -CMD [ "pm2-runtime", "start", "ecosystem.config.js" ] +ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait +RUN chmod +x /wait + +CMD [ "/wait", "&&", "pm2-runtime", "start", "ecosystem.config.js" ] diff --git a/server/docker-compose.yml b/server/docker-compose.yml index f2637ca..491a802 100644 --- a/server/docker-compose.yml +++ b/server/docker-compose.yml @@ -12,7 +12,6 @@ services: MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD} api: - # TODO: wait for mongodb to be available... image: entropychat.api build: . restart: on-failure @@ -25,6 +24,7 @@ services: ports: - ${PORT}:${PORT} environment: + WAIT_HOSTS: ${MONGO_HOST}:${MONGO_PORT} PORT: ${PORT} JWT_SECRET: ${JWT_SECRET} GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID} @@ -37,4 +37,4 @@ services: volumes: npm_cache: - node_modules: \ No newline at end of file + node_modules: