diff --git a/Dockerfile b/Dockerfile index 967f2d6..a8cb3f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,9 @@ 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 @@ -13,7 +16,8 @@ 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 @@ -41,4 +45,4 @@ COPY --from=build-env /app . VOLUME /data -ENTRYPOINT ./wait-for-it.sh +ENTRYPOINT ./entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..a03746a --- /dev/null +++ b/entrypoint.sh @@ -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 \ No newline at end of file diff --git a/wait-for-it.sh b/wait-for-it.sh deleted file mode 100755 index 50b69f5..0000000 --- a/wait-for-it.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -if [ "$WAKAPI_DB_TYPE" != "sqlite3" ]; then - echo "Waiting 10 Seconds for DB to start" - sleep 10; -fi - -echo "Starting Application" -./wakapi \ No newline at end of file