Skip to content

Commit

Permalink
refactor: streamline Docker setup and entrypoint script (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
chikof authored Nov 10, 2024
2 parents 1302e82 + 6055345 commit 1ee84f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ARG RUST_VERSION=1.82.0@sha256:33a0ea4769482be860174e1139c457bdcb2a236a988580a28c3a48824cbc17d6

FROM rust:$RUST_VERSION
WORKDIR /app

# renovate: datasource=crate depName=diesel_cli versioning=semver
ARG DIESEL_CLI_VERSION=2.2.4
Expand All @@ -11,9 +12,9 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* \
&& cargo install diesel_cli --version $DIESEL_CLI_VERSION --no-default-features --features postgres

WORKDIR /app
COPY . /app
COPY . .

RUN chmod +x /app/docker_entrypoint.sh
RUN cargo build --release \
&& chmod +x /app/docker_entrypoint.sh

ENTRYPOINT ["/app/docker_entrypoint.sh"]
ENTRYPOINT ["/app/docker_entrypoint.sh"]
16 changes: 8 additions & 8 deletions docker_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ echo "Waiting for PostgreSQL to be ready..."

# Check for database readiness
until diesel migration run --locked-schema; do
COUNTER=$((COUNTER + 1))
if [ "$COUNTER" -ge "$RETRIES" ]; then
echo "Exceeded maximum retries, exiting."
exit 1
fi
COUNTER=$((COUNTER + 1))
if [ "$COUNTER" -ge "$RETRIES" ]; then
echo "Exceeded maximum retries, exiting."
exit 1
fi

echo "Migrations failed, retrying in 5 seconds... (Attempt $COUNTER/$RETRIES)"
sleep 5
echo "Migrations failed, retrying in 5 seconds... (Attempt $COUNTER/$RETRIES)"
sleep 5
done

echo "Migrations ran successfully, starting the application..."
exec cargo run --release
exec ./target/release/izumo

0 comments on commit 1ee84f8

Please sign in to comment.