Wait for healthy containers in integration test
Rather than waiting 5 seconds and hoping for the best after we boot docker compose, add docker healthchecks and wait for all the containers to be healthy.
This commit is contained in:
@@ -24,4 +24,6 @@ RUN git config --global user.email "deployer@example.com"
|
||||
RUN git config --global user.name "Deployer"
|
||||
RUN git init && git add . && git commit -am "Initial version"
|
||||
|
||||
HEALTHCHECK --interval=1s CMD pgrep sleep
|
||||
|
||||
CMD ["./boot.sh"]
|
||||
|
||||
@@ -2,3 +2,4 @@ FROM nginx:1-alpine-slim
|
||||
|
||||
COPY default.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
HEALTHCHECK --interval=1s CMD pgrep nginx
|
||||
|
||||
@@ -4,4 +4,6 @@ COPY boot.sh .
|
||||
|
||||
RUN ln -s /shared/certs /certs
|
||||
|
||||
HEALTHCHECK --interval=1s CMD pgrep registry
|
||||
|
||||
ENTRYPOINT ["./boot.sh"]
|
||||
|
||||
@@ -8,7 +8,10 @@ RUN mkdir ssh && \
|
||||
ssh-keygen -t rsa -f ssh/id_rsa -N ""
|
||||
|
||||
COPY registry-dns.conf .
|
||||
COPY boot.sh .
|
||||
|
||||
RUN mkdir certs && openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key -x509 -days 365 -out certs/domain.crt -subj '/CN=registry' -extensions EXT -config registry-dns.conf
|
||||
|
||||
CMD ["bash", "-c", "cp -r * /shared"]
|
||||
HEALTHCHECK --interval=1s CMD pgrep sleep
|
||||
|
||||
CMD ["./boot.sh"]
|
||||
|
||||
7
test/integration/docker/shared/boot.sh
Executable file
7
test/integration/docker/shared/boot.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
cp -r * /shared
|
||||
|
||||
trap "pkill -f sleep" term
|
||||
|
||||
sleep infinity & wait
|
||||
@@ -9,4 +9,6 @@ RUN mkdir -p /etc/docker/certs.d/registry:4443 && ln -s /shared/certs/domain.crt
|
||||
|
||||
COPY boot.sh .
|
||||
|
||||
HEALTHCHECK --interval=1s CMD pgrep dockerd
|
||||
|
||||
CMD ["./boot.sh"]
|
||||
|
||||
Reference in New Issue
Block a user