Skip to content

Commit

Permalink
ci: make docker container wait properly for database to come up
Browse files Browse the repository at this point in the history
  • Loading branch information
muety committed Feb 6, 2021
1 parent 38ae416 commit 22260ce
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ WORKDIR /src
ADD ./go.mod .
RUN go mod download && go get github.com/markbates/pkger/cmd/pkger

RUN curl "https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh" -o wait-for-it.sh && \
chmod +x wait-for-it.sh

ADD . .
RUN go generate && go build -o wakapi

WORKDIR /app
RUN cp /src/wakapi . && \
cp /src/config.default.yml config.yml && \
sed -i 's/listen_ipv6: ::1/listen_ipv6: /g' config.yml && \
cp /src/wait-for-it.sh .
cp /src/wait-for-it.sh . && \
cp /src/entrypoint.sh .

# Run Stage

Expand Down Expand Up @@ -41,4 +45,4 @@ COPY --from=build-env /app .

VOLUME /data

ENTRYPOINT ./wait-for-it.sh
ENTRYPOINT ./entrypoint.sh
8 changes: 8 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

if [ "$WAKAPI_DB_TYPE" == "sqlite3" ] || [ "$WAKAPI_DB_TYPE" == "" ]; then
./wakapi
else
echo "Waiting for database to come up"
./wait-for-it.sh "$WAKAPI_DB_HOST:$WAKAPI_DB_PORT" -s -t 60 -- ./wakapi
fi
9 changes: 0 additions & 9 deletions wait-for-it.sh

This file was deleted.

0 comments on commit 22260ce

Please sign in to comment.