Skip to content

Commit 75dc023

Browse files
committed
Fix docker stop commands to fail correctly
1 parent 3f26e09 commit 75dc023

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

dev/local/Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,19 @@ CWD:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
6161
NOW:=$(shell date "+%Y-%m-%d")
6262
LOG_WEB:=delphi_web_epidata_$(NOW).log
6363
LOG_DB:=delphi_database_epidata_$(NOW).log
64+
WEB_CONTAINER_ID:=$(shell docker ps -q --filter 'name=delphi_web_epidata')
65+
DATABASE_CONTAINER_ID:=$(shell docker ps -q --filter 'name=delphi_database_epidata')
6466

6567

6668
.PHONY=web
6769
web:
6870
@# Stop container if running
69-
@-docker ps | grep delphi_web_epidata && docker stop delphi_web_epidata
71+
@if [ $(WEB_CONTAINER_ID) ]; then\
72+
docker stop $(WEB_CONTAINER_ID);\
73+
fi
7074

7175
@# Setup virtual network if it doesn't exist
72-
@-docker network ls | grep delphi-net || docker network create --driver bridge delphi-net
76+
@docker network ls | grep delphi-net || docker network create --driver bridge delphi-net
7377

7478
@# Build the web_epidata image
7579
@cd repos/delphi/delphi-epidata;\
@@ -86,10 +90,12 @@ web:
8690
.PHONY=db
8791
db:
8892
@# Stop container if running
89-
@-docker ps | grep delphi_database_epidata && docker stop delphi_database_epidata
93+
@if [ $(DATABASE_CONTAINER_ID) ]; then\
94+
docker stop $(DATABASE_CONTAINER_ID);\
95+
fi
9096

9197
@# Only build prereqs if we need them
92-
@-docker images delphi_database | grep delphi || \
98+
@docker images delphi_database | grep delphi || \
9399
docker build -t delphi_database -f repos/delphi/operations/dev/docker/database/Dockerfile .
94100

95101
@# Build the database_epidata image

0 commit comments

Comments
 (0)